2

My app consists of several microservices. I want to use NetFlix Eureka as discovery server and I want to deploy my apps as Docker containers. I want to set up communication between my services, but there are few problems:

  1. Beanstalk always using nginx as reverse-proxy for container and by default routes all requests to port 80. Ok, I've beaten that using some tricky script.
  2. I have several network interfaces on my EC2 Beanstalk instance - docker0 which is bridge for docker and eth0 which is host IP. The problem is, that I cannot dynamically determine host IP address inside the container so I cannot pass it to the Eureka discovery server (which is also running as a Docker image) without hardcoding. Using code or configuration I can only expose internal Docker interface and not bridged.

So, bottom line - I want to build microservices-enabled application using Docker, Beanstalk and Eureka. Solution should be scalable and there shouldn't be any hardcoded values except of Eureka host IP's.

Thanks.

Vova Rozhkov
  • 1,582
  • 2
  • 19
  • 27
  • This is possible duplicate of http://stackoverflow.com/questions/29971909/use-eureka-despite-having-random-external-port-of-docker-containers – Vova Rozhkov Jul 02 '15 at 05:06
  • Ok, i've found an answer - need to use AmazonDataCenterInfo to get proper IP's. Will write full answer later. – Vova Rozhkov Sep 23 '15 at 14:56
  • Possible duplicate of [How to let different Docker containers talk to each other without exposing the ports to the whole world](https://stackoverflow.com/questions/35194761/how-to-let-different-docker-containers-talk-to-each-other-without-exposing-the-p) – Paul Sweatte Jun 09 '17 at 13:14
  • @PaulSweatte – no, this is completely different question. It's about providing proper IP for Eureka configuration in app running inside Docker on Elastic Beanstalk. – Vova Rozhkov Jun 10 '17 at 14:27

1 Answers1

0
  1. Do not use Elastic Beanstalk – use ECS for Docker deployments instead.
  2. To tell Eureka which IP should be used, as described in https://github.com/spring-cloud/spring-cloud-netflix/issues/30, use following snippet:

    public EurekaInstanceConfigBean eurekaInstanceConfig() { InetUtilsProperties inetUtilsProperties = new InetUtilsProperties(); inetUtilsProperties.setDefaultHostname(EC2MetadataUtils.getLocalHostName()); inetUtilsProperties.setDefaultIpAddress(EC2MetadataUtils.getPrivateIpAddress()); EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(new InetUtils(inetUtilsProperties)); AmazonInfo info = AmazonInfo.Builder.newBuilder().autoBuild("eureka"); config.setDataCenterInfo(info); info.getMetadata().put(AmazonInfo.MetaDataKey.publicHostname.getName(), EC2MetadataUtils.getLocalHostName()); config.setHostname(EC2MetadataUtils.getLocalHostName()); config.setIpAddress(EC2MetadataUtils.getPrivateIpAddress()); config.setNonSecurePort(port); return config; }

Vova Rozhkov
  • 1,582
  • 2
  • 19
  • 27