spring-cloud-kubernetes
spring-cloud-kubernetes copied to clipboard
Using ExternalName service type with KubernetesDiscoveryClient
Imagine you have a setup when services running in K8S need to access services running outside.
I want to create an ExternalName service:
apiVersion: v1
kind: Service
metadata:
name: my-service
namespace: prod
spec:
type: ExternalName
externalName: my.service.example.com
After that I should be able to resolve service call http://my-service/doCall into http://my.service.example.com/doCall
So instead of relying only on endpoints in KubernetesDiscoveryClient, check if service type is ExternalName, then return single service instance with hostname: my.service.example.com.
Does it make sense to contribute this enhancement?
very much needed feature
is this related? https://github.com/spring-cloud/spring-cloud-kubernetes/issues/344
I am using Spring Cloud Hoxton.RELEASE (i.e., with Spring Cloud Kubernetes 1.1.0.RELEASE) and the following configuration is not working, so I don't think what you're asking for is covered by #344
ExternalName service:
kind: Service
metadata:
name: my-service
namespace: my-namespace
spec:
type: ExternalName
externalName: my.service.example.com
My client application is using ribbon with : @FeignClient(name = my-service)
Spring Sloud Kubernetes Ribbon config is: spring.cloud.kubernetes.ribbon.mode : SERVICE
KubernetesServicesServerList reports that it finds the service, but no ribbons:
o.s.b.f.s.DefaultListableBeanFactory : Autowiring by type from bean name 'ribbonRule' via factory method to bean named 'ribbonClientConfig'
c.netflix.config.ChainedDynamicProperty : Flipping property: my-service.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'ribbonPing'
o.s.b.f.s.DefaultListableBeanFactory : Autowiring by type from bean name 'ribbonPing' via factory method to bean named 'ribbonClientConfig'
o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'ribbonServerListUpdater'
o.s.b.f.s.DefaultListableBeanFactory : Autowiring by type from bean name 'ribbonServerListUpdater' via factory method to bean named 'ribbonClientConfig'
o.s.b.f.s.DefaultListableBeanFactory : Autowiring by type from bean name 'ribbonLoadBalancer' via factory method to bean named 'ribbonClientConfig'
o.s.b.f.s.DefaultListableBeanFactory : Autowiring by type from bean name 'ribbonLoadBalancer' via factory method to bean named 'ribbonServerList'
o.s.b.f.s.DefaultListableBeanFactory : Autowiring by type from bean name 'ribbonLoadBalancer' via factory method to bean named 'ribbonServerListFilter'
o.s.b.f.s.DefaultListableBeanFactory : Autowiring by type from bean name 'ribbonLoadBalancer' via factory method to bean named 'ribbonRule'
o.s.b.f.s.DefaultListableBeanFactory : Autowiring by type from bean name 'ribbonLoadBalancer' via factory method to bean named 'ribbonPing'
o.s.b.f.s.DefaultListableBeanFactory : Autowiring by type from bean name 'ribbonLoadBalancer' via factory method to bean named 'ribbonServerListUpdater'
c.netflix.loadbalancer.BaseLoadBalancer : Client: my-service instantiated a LoadBalancer: DynamicServerListLoadBalancer:{NFLoadBalancer:name=my-service,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:null
c.n.l.DynamicServerListLoadBalancer : Using serverListUpdater PollingServerListUpdater
o.s.c.k.r.KubernetesServicesServerList : Found Service[my-service]
o.s.c.k.r.KubernetesServicesServerList : Did not find any service in ribbon in namespace [my-namespace] for name [my-service] and portName [null]
c.n.l.DynamicServerListLoadBalancer : DynamicServerListLoadBalancer for client my-service initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=my-service,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:org.springframework.cloud.kubernetes.ribbon.KubernetesServicesServerList@48ffce4d
@michaelaplante, not sure about ribbon, but should work with blocking load balancer provided by spring cloud load balancer.
With Ribbon, you can consider this: https://github.com/spring-cloud/spring-cloud-kubernetes/pull/512#issuecomment-572561485
We are all for enhancements!
@ryanjbaxter I would like to contribute to this feature.. can you guide me here
That would be great!
I would start by looking at the class KubernetesDiscoveryClient.
@muralidharan-rade there is already a PR open here https://github.com/spring-cloud/spring-cloud-kubernetes/pull/512
@muralidharan-rade there is already a PR open here #512
sure let me work on that
I stumbled across the same problem. Are there still any plans on making this work?
this is my next thing to take care of, but for the initial phase, I'll add such support for the fabric8 client only (there are other features that will be ported to k8s client in the nearest future, this one included).
imo, such support for ExternalName services should be allowed only by opting into it via a property. The first reason is compatibility: we were not returning such services until now, so we should keep it that way; unless you want this explicitly. The second reason is that this will introduce more calls to the api-server, so having it optional is only reasonable to me.
Otherwise I will present a proposal PR in the upcoming days.
@ryanjbaxter FYI and blessing. thank you.
Agree on the opt in
@ryanjbaxter this can be closed now. thank you.
Lets leave it open until the k8s client implementation is done
this can be closed now as the implementation is both part of fabric8 and k8s-client