Add peer discovery for Docker Swarm

The peer discovery relies on "GET /info" API call which returns
list of master nodes. The peer list is passed to weaver when
launching it.

If node is a master, then we pass "--ipalloc-alloc
consensus=$(MASTER_NODES_COUNT)" to weaver. Otherwise, we pass
"--ipalloc-alloc observer".
This commit is contained in:
Martynas Pumputis authored and Bryan Boreham committed 2017-04-12 13:05:39 +00:00
1 parent 889dc856af
commit 82b56848a9
4 files changed
+89 -4

No files matched your search

+12
View File
@@ -21,6 +21,18 @@
"destination": "/procmount",
"type": "proc",
"source": "proc"
},
{
"destination": "/var/run/docker.sock",
"source": "/var/run/docker.sock",
"type": "bind",
"options": ["rbind"]
},
{
"destination": "/var/lib/weave",
"source": "/var/lib/weave",
"type": "bind",
"options": ["rbind"]
}
],
"network": {
+11 -4
View File
@@ -7,13 +7,16 @@ IPALLOC_RANGE=${IPALLOC_RANGE:-10.32.0.0/12}
HTTP_ADDR=${WEAVE_HTTP_ADDR:-127.0.0.1:6784}
STATUS_ADDR=${WEAVE_STATUS_ADDR:-0.0.0.0:6782}
HOST_ROOT=${HOST_ROOT:-/host}
LOG_FILE=/tmp/weaver.log
LOG_FILE=/var/lib/weave/weaver.log
echo "Starting launch.sh" >>$LOG_FILE
# Check if the IP range overlaps anything existing on the host
/usr/bin/weaveutil netcheck $IPALLOC_RANGE weave
SWARM_PEERS=$(/usr/bin/weaveutil swarm-manager-peers 2>>$LOG_FILE)
! /usr/bin/weaveutil is-swarm-manager 2>>$LOG_FILE || IS_SWARM_MANAGER=1
/home/weave/weave --local create-bridge --force >>$LOG_FILE 2>&1
BRIDGE_OPTIONS="--datapath=datapath"
@@ -29,8 +32,11 @@ if [ "$(/home/weave/weave --local bridge-type)" = "bridge" ]; then
fi
if [ -z "$IPALLOC_INIT" ]; then
# ideally we would know the peer count
IPALLOC_INIT="consensus"
if [ $IS_SWARM_MANAGER == "1" ]; then
IPALLOC_INIT="consensus=$(echo $SWARM_PEERS | wc -l)"
else
IPALLOC_INIT="observer"
fi
fi
/home/weave/weaver $EXTRA_ARGS --port=6783 $BRIDGE_OPTIONS \
@@ -38,6 +44,7 @@ fi
--ipalloc-range=$IPALLOC_RANGE \
--ipalloc-init $IPALLOC_INIT \
--nickname "$(hostname)" \
$(echo $SWARM_PEERS | tr '\n' ' ') \
>>$LOG_FILE 2>&1 &
WEAVE_PID=$!
@@ -51,7 +58,7 @@ while true; do
sleep 1
done
/home/weave/plugin --meshsocket='' --docker-api='' >/tmp/plugin.log 2>&1 &
/home/weave/plugin --meshsocket='' --docker-api='' >/var/lib/weave/plugin.log 2>&1 &
echo "End of launch.sh" >>$LOG_FILE