I have a microservice written in Spring Boot and leveraging Spring Cloud Kubernetes that runs in Kubernetes as follows:
- a Kubernetes service (
foo-service
) - two instances of
foo-service
(pods) sitting behind the service, each running the Spring Boot application
I can list all of the instances of the service by using the Spring Cloud Kubernetes DiscoveryClient
as follows:
List<ServiceInstance> allInstances = discoveryClient.getInstances("foo-service")
How do I get the instanceId of the instance that is executing this code?