eliminate dependency on pipework

...and docker-ns (though we still leave the script around since it's
handy for debugging), and arping (as I have yet to encounter a
situation where it was required)
This commit is contained in:
Matthias Radestock committed 2014-08-22 18:14:17 +01:00
1 parent 7a09d97cf5
commit 516c1363e3
4 files changed
+37 -24

No files matched your search

+6 -16
View File
@@ -8,24 +8,14 @@ multiple containers, running anywhere.
## Installation
Each host needs to have the following installed
Each host needs to have `weave` from the `weaver` sub-directory
installed in the root user's path, e.g.
- `weave` and `docker-ns` from the `weaver` sub-directory. Install
these somewhere in the root user's path, e.g. `/usr/local/bin`.
- [pipework][], by Jérôme Petazzoni. Install this in the same place as
the aforementioned scripts.
host# curl https://raw.githubusercontent.com/zettio/weave/master/weaver/weave \
> /usr/local/bin/weave; chmod a+x /usr/local/bin/weave
[pipework]: https://raw.githubusercontent.com/jpetazzo/pipework/master/pipework
e.g.
host# cp -a weaver/weave weaver/docker-ns /usr/local/bin
host# curl https://raw.githubusercontent.com/jpetazzo/pipework/master/pipework \
> /usr/local/bin/pipework; chmod a+x /usr/local/bin/pipework
We also need `ethtool` and `arping`. On most systems these are
installed already; if not then grab them via your favourite package
manager.
We also need `ethtool`. On most systems that is installed already; if
not then grab it via your favourite package manager.
## Example
-1
View File
@@ -1,2 +1 @@
weaver
pipework
-4
View File
@@ -13,10 +13,6 @@ docker-image: /tmp/weave.tar
sudo docker build -t zettio/weave .
sudo docker save zettio/weave > /tmp/weave.tar
pipework:
wget --no-check-certificate -nv https://raw.github.com/jpetazzo/pipework/master/pipework
chmod +x pipework
clean:
-sudo docker rmi zettio/weave
rm -f weaver pipework /tmp/weave.tar
+31 -3
View File
@@ -12,7 +12,7 @@ shift 2
# pre-create bridge so we can set the MTU
[ ! -d /sys/class/net/$BRIDGE ] && {
ip link add dev $BRIDGE type bridge > /dev/null 2>&1
ip link add dev $BRIDGE type bridge
ip link set dev $BRIDGE address 7a:$(od -txC -An -N5 /dev/random | tr \ : | tail -c+2)
# attempting to set the bridge MTU to a high value directly
# fails. Bridges take the lowest MTU of their interfaces. So
@@ -42,8 +42,36 @@ case "$COMMAND" in
;;
esac
${SCRIPT_DIR}/pipework $BRIDGE -i $CONTAINER_IFNAME $CONTAINER $IPADDR 1>&2
# the following borrows from https://github.com/jpetazzo/pipework
${SCRIPT_DIR}/docker-ns $CONTAINER ethtool -K $IFACE tx off > /dev/null
DOCKERPID=$(docker inspect --format='{{ .State.Pid }}' $CONTAINER)
[ "$DOCKERPID" = 0 ] && {
echo "Docker inspect returned invalid PID 0"
exit 1
}
[ "$DOCKERPID" = "<no value>" ] && {
echo "Container $CONTAINER unknown to Docker."
exit 1
}
NSPID=$DOCKERPID
[ ! -d /var/run/netns ] && mkdir -p /var/run/netns
[ -f /var/run/netns/$NSPID ] && rm -f /var/run/netns/$NSPID
ln -s /proc/$NSPID/ns/net /var/run/netns/$NSPID
LOCAL_IFNAME="v${CONTAINER_IFNAME}pl${NSPID}"
GUEST_IFNAME="v${CONTAINER_IFNAME}pg${NSPID}"
ip link add name $LOCAL_IFNAME mtu $MTU type veth peer name $GUEST_IFNAME mtu $MTU
ip link set $LOCAL_IFNAME master $BRIDGE
ip link set $LOCAL_IFNAME up
ip link set $GUEST_IFNAME netns $NSPID
ip netns exec $NSPID ip link set $GUEST_IFNAME name $CONTAINER_IFNAME
ip netns exec $NSPID ip addr add $IPADDR dev $CONTAINER_IFNAME
ip netns exec $NSPID ip link set $CONTAINER_IFNAME up
ip netns exec $NSPID ethtool -K $IFACE tx off > /dev/null
[ -f /var/run/netns/$NSPID ] && rm -f /var/run/netns/$NSPID
echo $CONTAINER