Class AbstractKubernetesServiceInstanceProvider
java.lang.Object
io.micronaut.kubernetes.discovery.AbstractKubernetesServiceInstanceProvider
- All Implemented Interfaces:
KubernetesServiceInstanceProvider
- Direct Known Subclasses:
AbstractV1EndpointsProvider
,AbstractV1ServiceProvider
public abstract class AbstractKubernetesServiceInstanceProvider
extends Object
implements KubernetesServiceInstanceProvider
Abstract implementation of kubernetes service instance provider.
- Since:
- 2.3
- Author:
- Pavol Gressa
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Utility class for transparent access toCoreV1EndpointPort
andV1ServicePort
. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic io.micronaut.discovery.ServiceInstance
buildServiceInstance
(String serviceId, AbstractKubernetesServiceInstanceProvider.PortBinder servicePort, String address, io.kubernetes.client.openapi.models.V1ObjectMeta metadata) Builds service instance.static Predicate<io.kubernetes.client.common.KubernetesObject>
compositePredicate
(Predicate<io.kubernetes.client.common.KubernetesObject>... predicates) Creates composite of predicates.protected static Predicate<io.kubernetes.client.common.KubernetesObject>
discoveryConfigurationFilter
(KubernetesConfiguration.KubernetesDiscoveryConfiguration discoveryConfiguration) Creates filter predicate for Kubernetes objects based on providedKubernetesConfiguration.KubernetesDiscoveryConfiguration
.static boolean
hasValidPortConfiguration
(List<AbstractKubernetesServiceInstanceProvider.PortBinder> ports, KubernetesServiceConfiguration serviceConfiguration) Validates the necessity of having port configuration based on number of declaredports
.static boolean
isMetadataSecure
(io.kubernetes.client.openapi.models.V1ObjectMeta objectMeta) static boolean
Attempts to guess whether this port should be connected to using SSL.protected static Predicate<io.kubernetes.client.common.KubernetesObject>
serviceConfigurationDiscoveryFilter
(KubernetesServiceConfiguration serviceConfiguration, KubernetesConfiguration.KubernetesDiscoveryConfiguration discoveryConfiguration) Creates service specific filter based onKubernetesServiceConfiguration
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.kubernetes.discovery.KubernetesServiceInstanceProvider
getInstances, getMode, getServiceIds
-
Field Details
-
SECURE_LABEL
- See Also:
-
LOG
protected static final org.slf4j.Logger LOG
-
-
Constructor Details
-
AbstractKubernetesServiceInstanceProvider
public AbstractKubernetesServiceInstanceProvider()
-
-
Method Details
-
discoveryConfigurationFilter
protected static Predicate<io.kubernetes.client.common.KubernetesObject> discoveryConfigurationFilter(KubernetesConfiguration.KubernetesDiscoveryConfiguration discoveryConfiguration) Creates filter predicate for Kubernetes objects based on providedKubernetesConfiguration.KubernetesDiscoveryConfiguration
.- Parameters:
discoveryConfiguration
- configuration- Returns:
- predicate
-
serviceConfigurationDiscoveryFilter
protected static Predicate<io.kubernetes.client.common.KubernetesObject> serviceConfigurationDiscoveryFilter(KubernetesServiceConfiguration serviceConfiguration, KubernetesConfiguration.KubernetesDiscoveryConfiguration discoveryConfiguration) Creates service specific filter based onKubernetesServiceConfiguration
.- Parameters:
serviceConfiguration
- service configurationdiscoveryConfiguration
- discovery configuration- Returns:
- filter predicate
-
buildServiceInstance
public static io.micronaut.discovery.ServiceInstance buildServiceInstance(String serviceId, @Nullable AbstractKubernetesServiceInstanceProvider.PortBinder servicePort, String address, io.kubernetes.client.openapi.models.V1ObjectMeta metadata) Builds service instance.- Parameters:
serviceId
- service idservicePort
- servicePortaddress
- addressmetadata
- metadata- Returns:
- service instance
-
isPortSecure
public static boolean isPortSecure(AbstractKubernetesServiceInstanceProvider.PortBinder servicePort) Attempts to guess whether this port should be connected to using SSL. By default, port numbers ending in 443 or port named "https" are considered secure- Parameters:
servicePort
- theAbstractKubernetesServiceInstanceProvider.PortBinder
- Returns:
- Whether the port is considered secure
-
isMetadataSecure
public static boolean isMetadataSecure(io.kubernetes.client.openapi.models.V1ObjectMeta objectMeta) - Parameters:
objectMeta
- theV1ObjectMeta
- Returns:
- true if there is a label within
V1ObjectMeta.getLabels()
namedSECURE_LABEL
and with value "true"; false otherwise
-
hasValidPortConfiguration
public static boolean hasValidPortConfiguration(@Nullable List<AbstractKubernetesServiceInstanceProvider.PortBinder> ports, KubernetesServiceConfiguration serviceConfiguration) Validates the necessity of having port configuration based on number of declaredports
.- Parameters:
ports
- list of portsserviceConfiguration
- service configuration- Returns:
- true if the port configuration is valid otherwise false
-
compositePredicate
@SafeVarargs public static Predicate<io.kubernetes.client.common.KubernetesObject> compositePredicate(Predicate<io.kubernetes.client.common.KubernetesObject>... predicates) Creates composite of predicates.- Parameters:
predicates
- predicates- Returns:
- predicate
-