'SpringBoot Eureka Discovey not working when used in Kubernetes
The Setup here is two SpringBoot REST Services built on SpringBoot 2.6.4 and also a SpringBoot Eureka Netflix Server built on 2.6.4. All of these lives on separate Docker images built with JIB.
One of the Services takes call from a web gui (not part of the problem) and that service calls the second service to get some information. It is this calls, that in a Kubernetes setup does not work.
When I put the Docker images together via Docker Compose on my own machine the setup works fine and service one gets answers from service two.
When we use the setup on Kubernets, that we have set up in our AWS, the call from Service one to Service two results in:
java.net.UnknownHostException
I can see that both Services are registered in the Eureka server, so the registration part seems to work.
Then I found on Spring page https://cloud.spring.io/spring-cloud-netflix/multi/multi__service_discovery_eureka_clients.html that
You can do so by customizing the EurekaInstanceConfigBean as follows:
@Bean
@Profile("!default")
public EurekaInstanceConfigBean eurekaInstanceConfig(InetUtils inetUtils) {
EurekaInstanceConfigBean b = new EurekaInstanceConfigBean(inetUtils);
AmazonInfo info = AmazonInfo.Builder.newBuilder().autoBuild("eureka");
b.setDataCenterInfo(info);
return b;
}
When I try this, I get the following exception in runtime.
Caused by: java.lang.ClassNotFoundException: com.netflix.config.DynamicPropertyFactory
Have we missed something? Is this setup of Spring Boot broken with Eureka? (I can see hints around the web about deprecation) Should we try another approach for Discovery? (even if it seems on Spring that Eureka is the approach to use) And in that case, what do you suggest?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
