[es] Also adding host IP discovery for http

This commit is contained in:
Geoff Bourne 2016-09-04 16:10:08 -05:00
parent 8cea619c13
commit c38bfb22cc
2 changed files with 17 additions and 4 deletions

View file

@ -170,7 +170,7 @@ Using the Docker Compose file above, a value of `2` is appropriate when scaling
docker-compose scale master=3
## Auto transport discovery with Swarm Mode
## Auto transport/http discovery with Swarm Mode
When using Docker Swarm mode (starting with 1.12), the overlay and ingress network interfaces are assigned
multiple IP addresses. As a result, it creates confusion for the transport publish logic even when using
@ -181,3 +181,7 @@ To resolve this, add
-e DISCOVER_TRANSPORT_IP=eth0
replacing `eth0` with another interface within the container, if needed.
The same can be done for publish/binding of the http module by adding:
-e DISCOVERY_HTTP_IP=eth2

View file

@ -18,10 +18,19 @@ OPTS="$OPTS -Des.path.conf=/conf \
-Des.transport.tcp.port=9300 \
-Des.http.port=9200"
discoverIpFromLink() {
dev=$1
mode=$2
ip=`ipaddr show dev $dev scope global|awk '$1 == "inet" { if (!match($2,"/32")) { gsub("/.*","",$2) ; print $2 } }'`
echo "Discovered $mode address $ip for $dev"
OPTS="$OPTS -Des.$mode.host=$ip"
}
if [ "$DISCOVER_TRANSPORT_IP" != "" ]; then
ip=`ipaddr show dev $DISCOVER_TRANSPORT_IP scope global|awk '$1 == "inet" { if (!match($2,"/32")) { gsub("/.*","",$2) ; print $2 } }'`
echo "Discovered address $ip for $DISCOVER_TRANSPORT_IP"
OPTS="$OPTS -Des.transport.host=$ip"
discoverIpFromLink $DISCOVER_TRANSPORT_IP transport
fi
if [ "$DISCOVER_HTTP_IP" != "" ]; then
discoverIpFromLink $DISCOVER_HTTP_IP http
fi
if [ -n "$CLUSTER" ]; then