diff --git a/README.adoc b/README.adoc index 20c0ea1c..4e68a8bb 100644 --- a/README.adoc +++ b/README.adoc @@ -112,6 +112,8 @@ This client lets you query Kubernetes endpoints (see https://kubernetes.io/docs/ A service is typically exposed by the Kubernetes API server as a collection of endpoints that represent `http` and `https` addresses and that a client can access from a Spring Boot application running as a pod. +DiscoveryClient can also find services of type `ExternalName` (see https://kubernetes.io/docs/concepts/services-networking/service/#externalname[ExternalName services]). At the moment, external name support type of services is only available if the following property `spring.cloud.kubernetes.discovery.include-external-name-services` is set to `true` and only in the `fabric8` implementation. In a later release, support will be added for the kubernetes native client also. + This is something that you get for free by adding the following dependency inside your project: ==== @@ -218,6 +220,8 @@ Please make sure to configure your service and/or application accordingly. By default all of the ports and their names will be added to the metadata of the `ServiceInstance`. +As said before, if you want to get the list of `ServiceInstance` to also include the `ExternalName` type services, you need to enable that support via: `spring.cloud.kubernetes.discovery.include-external-name-services=true`. As such, when calling `DiscoveryClient::getInstances` those will be returned also. You can distinguish between `ExternalName` and any other types by inspecting `ServiceInstance::getMetadata` and lookup for a field called `type`. This will be the type of the service returned : `ExternalName`/`ClusterIP`, etc. + If, for any reason, you need to disable the `DiscoveryClient`, you can set the following property in `application.properties`: ==== diff --git a/docs/src/main/asciidoc/_configprops.adoc b/docs/src/main/asciidoc/_configprops.adoc index fa1fc6f0..6cab6ef3 100644 --- a/docs/src/main/asciidoc/_configprops.adoc +++ b/docs/src/main/asciidoc/_configprops.adoc @@ -62,6 +62,7 @@ |spring.cloud.kubernetes.discovery.cache-loading-timeout-seconds | `+++60+++` | |spring.cloud.kubernetes.discovery.enabled | `+++true+++` | |spring.cloud.kubernetes.discovery.filter | | +|spring.cloud.kubernetes.discovery.include-external-name-services | `+++false+++` | |spring.cloud.kubernetes.discovery.include-not-ready-addresses | `+++false+++` | |spring.cloud.kubernetes.discovery.known-secure-ports | `+++[443, 8443]+++` | |spring.cloud.kubernetes.discovery.metadata.add-annotations | `+++true+++` | diff --git a/spring-cloud-kubernetes-client-loadbalancer/src/main/java/org/springframework/cloud/kubernetes/client/loadbalancer/KubernetesClientLoadBalancerClientConfiguration.java b/spring-cloud-kubernetes-client-loadbalancer/src/main/java/org/springframework/cloud/kubernetes/client/loadbalancer/KubernetesClientLoadBalancerClientConfiguration.java index 8bb716d7..2a058530 100644 --- a/spring-cloud-kubernetes-client-loadbalancer/src/main/java/org/springframework/cloud/kubernetes/client/loadbalancer/KubernetesClientLoadBalancerClientConfiguration.java +++ b/spring-cloud-kubernetes-client-loadbalancer/src/main/java/org/springframework/cloud/kubernetes/client/loadbalancer/KubernetesClientLoadBalancerClientConfiguration.java @@ -36,8 +36,8 @@ public class KubernetesClientLoadBalancerClientConfiguration { ServiceInstanceListSupplier kubernetesServicesListSupplier(Environment environment, CoreV1Api coreV1Api, KubernetesClientServiceInstanceMapper mapper, KubernetesDiscoveryProperties discoveryProperties, KubernetesNamespaceProvider kubernetesNamespaceProvider, ConfigurableApplicationContext context) { - return ServiceInstanceListSupplier.builder().withBase(new KubernetesClientServicesListSupplier(environment, mapper, discoveryProperties, coreV1Api, - kubernetesNamespaceProvider)).withCaching().build(context); + return ServiceInstanceListSupplier.builder().withBase(new KubernetesClientServicesListSupplier(environment, + mapper, discoveryProperties, coreV1Api, kubernetesNamespaceProvider)).withCaching().build(context); } } diff --git a/spring-cloud-kubernetes-fabric8-loadbalancer/src/main/java/org/springframework/cloud/kubernetes/fabric8/loadbalancer/Fabric8LoadBalancerClientConfiguration.java b/spring-cloud-kubernetes-fabric8-loadbalancer/src/main/java/org/springframework/cloud/kubernetes/fabric8/loadbalancer/Fabric8LoadBalancerClientConfiguration.java index af100173..7d73a768 100644 --- a/spring-cloud-kubernetes-fabric8-loadbalancer/src/main/java/org/springframework/cloud/kubernetes/fabric8/loadbalancer/Fabric8LoadBalancerClientConfiguration.java +++ b/spring-cloud-kubernetes-fabric8-loadbalancer/src/main/java/org/springframework/cloud/kubernetes/fabric8/loadbalancer/Fabric8LoadBalancerClientConfiguration.java @@ -37,7 +37,9 @@ public class Fabric8LoadBalancerClientConfiguration { ServiceInstanceListSupplier kubernetesServicesListSupplier(Environment environment, KubernetesClient kubernetesClient, Fabric8ServiceInstanceMapper mapper, KubernetesDiscoveryProperties discoveryProperties, ConfigurableApplicationContext context) { - return ServiceInstanceListSupplier.builder().withBase(new Fabric8ServicesListSupplier(environment, kubernetesClient, mapper, discoveryProperties)).withCaching().build(context); + return ServiceInstanceListSupplier.builder() + .withBase(new Fabric8ServicesListSupplier(environment, kubernetesClient, mapper, discoveryProperties)) + .withCaching().build(context); } }