Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eureka on spring-cloud-netflix with DNS based config, all instances showing up as unavailable

I'm trying to setup a eureka cluster on aws with DNS-based EIP configuration as described at https://github.com/Netflix/eureka/wiki/Configuring-Eureka-in-AWS-Cloud

Everything seems to work, but the eureka dashboard insists that the eureka instances are unavailable. I'm now wondering if this is only an ui problem (i think so) or if i'm missing something.

As i understand the "unavailable-replicas" logic in the dashboard this is because eureka is comparing the registration hostname and the replica hostname. The instances register with their internal VPC ip at the discovery client but with their EIP when looking for replica peers (strange enough, in the eureka log i can see internaly they are also using the internal VPC ip).

The question is: Is that only some cosmetic ui problem that i shouldn't worry about or are bigger problems waiting to step in because of some misconfiguration? If it's only an ui thing: can i "repair" that somehow?

enter image description here

Edit:

Maybe related https://github.com/spring-cloud/spring-cloud-netflix/issues/102#issuecomment-74446709

like image 701
Dirk Lachowski Avatar asked Mar 29 '16 12:03

Dirk Lachowski


People also ask

Is Netflix Eureka deprecated?

Deprecated by Netflix and no longer maintained by Pivotal/VMware.

How do I use Netflix on Eureka?

Implementing a Eureka Server for service registry is as easy as: adding spring-cloud-starter-netflix-eureka-server to the dependencies. enabling the Eureka Server in a @SpringBootApplication by annotating it with @EnableEurekaServer. configuring some properties.

How do I enable Eureka server in spring boot?

After downloading the project in main Spring Boot Application class file, we need to add @EnableEurekaServer annotation. The @EnableEurekaServer annotation is used to make your Spring Boot application acts as a Eureka Server. Make sure Spring cloud Eureka server dependency is added in your build configuration file.

Which mode of Eureka server has multiple Eureka servers?

The Eureka server works in two modes: Standalone: in local, we configure a stand-alone mode where we have only one Eureka server (localhost) and the same cloning property from itself. Clustered: we have multiple Eureka servers, each cloning its states from its peer.


1 Answers

With the help of @rozhok in the related github issue i now have a working solution. If anyone is facing the same problem, here's what i've done:

application.yml

eureka:
  datacenter: cloud
  client:
    eurekaServerDNSName: your.dns.name
    eurekaServerPort: 8761
    eurekaServerURLContext: eureka
    region: eu-west-1
    registerWithEureka: true
    fetchRegistry: true
    useDnsForFetchingServiceUrls: true
  server:
    waitTimeInMsWhenSyncEmpty: 0
    enableSelfPreservation: true

EurekaServer

@SpringBootApplication
@EnableEurekaServer
@EnableDiscoveryClient
public class EurekaServer {

    @Value("${server.port:8761}") 
    private int port;

    public static void main(String[] args) {
        SpringApplication.run(EurekaServer.class, args);
    }

    @Bean
    @Autowired
    public EurekaInstanceConfigBean eurekaInstanceConfigBean(InetUtils inetUtils) {
      EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);
      AmazonInfo info = AmazonInfo.Builder.newBuilder().autoBuild("eureka");

      // Don't use spring cloud's hostname here. 
      // See comment below by Michal
      config.setHostname(
          info.get(AmazonInfo.MetaDataKey.publicHostname));

      config.setIpAddress(info.get(AmazonInfo.MetaDataKey.publicIpv4));
      config.setNonSecurePort(port);
      config.setDataCenterInfo(info);
      return config;
    }

}

With that configuration each eureka server sees only the other servers as available replicas:

enter image description here

like image 110
Dirk Lachowski Avatar answered Oct 02 '22 00:10

Dirk Lachowski