Eureka client with 2 IP address on Docker

953 views
Skip to first unread message

fernando.v...@gmail.com

unread,
May 4, 2016, 10:59:49 AM5/4/16
to eureka_netflix
Hello

I'm using Eureka Server 1 and Eureka clients as spring boot apps which runs on Docker containers orchestrated by Rancher (www.rancher.com).

Rancher adds an IP address on eth0 nic of the container (10.42.X.X) for reach other group of containers (services) on other hosts via managed network implemented with IPSec.

The problem is that eth0 holds the docker native IP address from docker0 (172.17.X.x) so the NIC has 2 IP address and eureka clients registers the 172.72.X.X IP with eureka.preferIpAddress:true so Feign clients can't reach other services.

On the other hand, when I unset eureka.preferIpAddress:true the clients register with the container hostname and they has less chances to reach each others.

Am I doing something wrong?

How can I modify eureka config for prefer other IP on the same NIC?

Thanks in advance


dl...@netflix.com

unread,
May 5, 2016, 9:08:41 PM5/5/16
to eureka_netflix, fernando.v...@gmail.com
Hi Fernando,

As of this moment, eureka does not support multiple ENIs in an AWS VPC environment. We are aware of this limitation, and as a matter of fact also have similar new requirements internally as well. There are things in the works that should help to address this, however there's currently no timeline that we can commit to.
One possible "work-around" that you can try right now, is to leverage the metadata ability within Eureka to add the additional info as custom metadata in your environment. You can see information of how to set custom metadata at: https://github.com/Netflix/eureka/wiki/Overriding-Default-Configurations.

Thanks.

fernando.v...@gmail.com

unread,
May 6, 2016, 12:32:23 PM5/6/16
to eureka_netflix, fernando.v...@gmail.com
Well I have created a script as a workaround using the rancher metadata service. I'm running Eureka on my own vms instead of AWS.

Rancher has a metadata service where I can fetch the IP address of the managed network IP assigned to the container:

As I create the containers with docker plugin for maven, the artifact is always copied with the name app.jar, so the base image has an entrypoint like this:

#!/bin/bash
echo "Setting rancher managed ip address on MANAGED_IP environment variable"
export MANAGED_IP=$(curl --retry 5 --connect-timeout 3 -s 169.254.169.250/latest/self/container/primary_ip)
echo "Rancher IP is ${MANAGED_IP}"
java -Djava.security.egd=file:/dev/./urandom -jar /app.jar

This is my config repo (I'm using config server too) with settings for eureka.yml:

eureka
instance:
preferIpAddress: true
ip-address: ${MANAGED_IP}

Now the clients register with Eureka with the managed IP address

Hope this helps others and thanks for your response

Reply all
Reply to author
Forward
0 new messages