Merge pull request #2688 from weaveworks/issues/2684-exec-weaver
Exec weaver from weave-kube launch rather than running in background
This commit is contained in:
commit
635191970f
1 file changed
+38
-41
+38
-41
@@ -65,24 +65,6 @@ if [ -z "$IPALLOC_INIT" ]; then
|
|||||||
IPALLOC_INIT="consensus=$(peer_count $KUBE_PEERS)"
|
IPALLOC_INIT="consensus=$(peer_count $KUBE_PEERS)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
/home/weave/weaver $EXTRA_ARGS --port=6783 $BRIDGE_OPTIONS \
|
|
||||||
--http-addr=$HTTP_ADDR --status-addr=$STATUS_ADDR --docker-api='' --no-dns \
|
|
||||||
--ipalloc-range=$IPALLOC_RANGE $NICKNAME_ARG \
|
|
||||||
--ipalloc-init $IPALLOC_INIT \
|
|
||||||
"$@" \
|
|
||||||
$KUBE_PEERS &
|
|
||||||
WEAVE_PID=$!
|
|
||||||
|
|
||||||
# Wait for weave process to become responsive
|
|
||||||
while true ; do
|
|
||||||
curl $HTTP_ADDR/status >/dev/null 2>&1 && break
|
|
||||||
if ! kill -0 $WEAVE_PID >/dev/null 2>&1 ; then
|
|
||||||
echo Weave process has died >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
|
|
||||||
reclaim_ips() {
|
reclaim_ips() {
|
||||||
ID=$1
|
ID=$1
|
||||||
shift
|
shift
|
||||||
@@ -91,30 +73,45 @@ reclaim_ips() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Tell the newly-started weave about existing weave bridge IPs
|
post_start_actions() {
|
||||||
/usr/bin/weaveutil container-addrs weave weave:expose | while read ID IFACE MAC IPS; do
|
# Wait for weave process to become responsive
|
||||||
reclaim_ips "weave:expose" $IPS
|
while true ; do
|
||||||
done
|
curl $HTTP_ADDR/status >/dev/null 2>&1 && break
|
||||||
# Tell weave about existing weave process IPs
|
sleep 1
|
||||||
/usr/bin/weaveutil process-addrs weave | while read ID IFACE MAC IPS; do
|
done
|
||||||
reclaim_ips "_" $IPS
|
|
||||||
done
|
|
||||||
|
|
||||||
# Install CNI plugin binary to typical CNI bin location
|
# Tell the newly-started weave about existing weave bridge IPs
|
||||||
# with fall-back to CNI directory used by kube-up on GCI OS
|
/usr/bin/weaveutil container-addrs weave weave:expose | while read ID IFACE MAC IPS; do
|
||||||
if ! mkdir -p $HOST_ROOT/opt/cni/bin ; then
|
reclaim_ips "weave:expose" $IPS
|
||||||
if mkdir -p $HOST_ROOT/home/kubernetes/bin ; then
|
done
|
||||||
export WEAVE_CNI_PLUGIN_DIR=$HOST_ROOT/home/kubernetes/bin
|
# Tell weave about existing weave process IPs
|
||||||
else
|
/usr/bin/weaveutil process-addrs weave | while read ID IFACE MAC IPS; do
|
||||||
echo "Failed to install the Weave CNI plugin" >&2
|
reclaim_ips "_" $IPS
|
||||||
exit 1
|
done
|
||||||
|
|
||||||
|
# Install CNI plugin binary to typical CNI bin location
|
||||||
|
# with fall-back to CNI directory used by kube-up on GCI OS
|
||||||
|
if ! mkdir -p $HOST_ROOT/opt/cni/bin ; then
|
||||||
|
if mkdir -p $HOST_ROOT/home/kubernetes/bin ; then
|
||||||
|
export WEAVE_CNI_PLUGIN_DIR=$HOST_ROOT/home/kubernetes/bin
|
||||||
|
else
|
||||||
|
echo "Failed to install the Weave CNI plugin" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
mkdir -p $HOST_ROOT/etc/cni/net.d
|
||||||
mkdir -p $HOST_ROOT/etc/cni/net.d
|
export HOST_ROOT
|
||||||
export HOST_ROOT
|
/home/weave/weave --local setup-cni
|
||||||
/home/weave/weave --local setup-cni
|
|
||||||
|
|
||||||
# Expose the weave network so host processes can communicate with pods
|
# Expose the weave network so host processes can communicate with pods
|
||||||
/home/weave/weave --local expose $WEAVE_EXPOSE_IP
|
/home/weave/weave --local expose $WEAVE_EXPOSE_IP
|
||||||
|
}
|
||||||
|
|
||||||
wait $WEAVE_PID
|
post_start_actions &
|
||||||
|
|
||||||
|
exec /home/weave/weaver $EXTRA_ARGS --port=6783 $BRIDGE_OPTIONS \
|
||||||
|
--http-addr=$HTTP_ADDR --status-addr=$STATUS_ADDR --docker-api='' --no-dns \
|
||||||
|
--ipalloc-range=$IPALLOC_RANGE $NICKNAME_ARG \
|
||||||
|
--ipalloc-init $IPALLOC_INIT \
|
||||||
|
"$@" \
|
||||||
|
$KUBE_PEERS
|
||||||
Reference in new issue
Block a user