Is there any way to determine current service instance_id in kuberbetes service discovery?

9/23/2020

eureka analogue:

int index = 0;
Application application = this.eurekaClient.getApplication(this.environment.getProperty("spring.application.name"));
List<InstanceInfo> instanceInfoList = application.getInstances();
for (InstanceInfo instanceInfo : instanceInfoList) {
   if(instanceInfo.getInstanceId().equals(this.eurekaClient.getApplicationInfoManager().getInfo().getInstanceId())) {
      return index;
   }
}

as you can see we get a list of service instances and then compare them to one registered in eureka (this.eurekaClient.getApplicationInfoManager().getInfo().getInstanceId())

-- comrad igor
kubernetes
microservices
spring-boot

0 Answers