I am a confused as to what is the proper setup for my spring-cloud-kubernetes project to use kubernetes native discovery and make use of the discoveryclient when the kuberbetes service fronts mult
I can get things working by using the discoveryClient and referencing just the service by name. So far so good. However, i then need to pick one of the service instances (which looks like an actual pod ip+port) which I clearly don't want to do since i want to rely on native service discovery. Should I not be using the discoveryClient when using kubernetes service discovery?
I can also connect to the rest service with the restTemplate using http://{service-name}.{namespace}.svc.{cluster}.local:{service-port}. As far as I can tell, restTemplate will also use discoveryClient and pick a serviceInstance (particularly when using @LoadBalanced annotation). However, based on the behavior i described above , this suggests that one service instance is selected rather than hitting the actual kubernetes service.
I feel I am not understanding what the semantics of discovery client when dealing with native kubernetes discovery. I also don't understand why i would need to reference the service in my restTemplate using {service-name}.{namespace}.svc.{cluster}.local:{service-port} rather than just {service-name) (given that seems to be plenty when using client side load balancing)?
Thanks for clarifying.
I've been experiencing the same issue as you. From my understanding changing the loadbalancer to SERVICE mode, as @spencergibb mentioned, should allow you to connect with the service URL over the pod IP address but it doesn't seem to work or I'm using it incorrectly. I created an issue on Spring Cloud's GitHub https://github.com/spring-cloud/spring-cloud-kubernetes/issues/783.