Spring boot 在kuberbetes服务发现中,是否有任何方法可以确定当前服务实例的id?

Spring boot 在kuberbetes服务发现中,是否有任何方法可以确定当前服务实例的id?,spring-boot,kubernetes,microservices,Spring Boot,Kubernetes,Microservices,尤里卡类似物: int index = 0; Application application = this.eurekaClient.getApplication(this.environment.getProperty("spring.application.name")); List<InstanceInfo> instanceInfoList = application.getInstances(); for (InstanceInfo instanceIn

尤里卡类似物:

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;
   }
}
int索引=0;
Application Application=this.eurekaClient.getApplication(this.environment.getProperty(“spring.Application.name”);
List instanceinfo=application.getInstances();
对于(InstanceInfo InstanceInfo:InstanceInfo列表){
如果(instanceInfo.getInstanceId().equals(this.eurekaClient.getApplicationInfoManager().getInfo().getInstanceId())){
收益指数;
}
}

正如您所见,我们获得了一个服务实例列表,然后将它们与在eureka中注册的服务实例进行比较(this.eurekaClient.getApplicationInfoManager().getInfo().getInstanceId())

一个想法,看看Kubernetes Java客户机,看看您是否可以对它做同样的事情。@akuma8,谢谢您的评论!我将尝试几种KubernetesClient方法