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
  • Field Details

    • SECURE_LABEL

      public static final String 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 provided KubernetesConfiguration.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 on KubernetesServiceConfiguration.
      Parameters:
      serviceConfiguration - service configuration
      discoveryConfiguration - 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 id
      servicePort - servicePort
      address - address
      metadata - 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 - the AbstractKubernetesServiceInstanceProvider.PortBinder
      Returns:
      Whether the port is considered secure
    • isMetadataSecure

      public static boolean isMetadataSecure(io.kubernetes.client.openapi.models.V1ObjectMeta objectMeta)
      Parameters:
      objectMeta - the V1ObjectMeta
      Returns:
      true if there is a label within V1ObjectMeta.getLabels() named SECURE_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 declared ports.
      Parameters:
      ports - list of ports
      serviceConfiguration - 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