Merge pull request #1009 from awh/weave_launch_all_the_things

Weave launch all the things

Closes #962.
This commit is contained in:
Matthias Radestock committed 2015-06-26 13:21:44 +01:00
commit 55fbffef75
12 files changed
+147 -92

No files matched your search

-2
View File
@@ -141,10 +141,8 @@ Let's begin by configuring weave's allocator to manage multiple
subnets: subnets:
host1$ weave launch -iprange 10.2.0.0/16 -ipsubnet 10.2.1.0/24 host1$ weave launch -iprange 10.2.0.0/16 -ipsubnet 10.2.1.0/24
host1$ weave launch-dns && weave launch-proxy
host1$ eval $(weave proxy-env) host1$ eval $(weave proxy-env)
host2$ weave launch -iprange 10.2.0.0/16 -ipsubnet 10.2.1.0/24 $HOST1 host2$ weave launch -iprange 10.2.0.0/16 -ipsubnet 10.2.1.0/24 $HOST1
host2$ weave launch-dns && weave launch-proxy
host2$ eval $(weave proxy-env) host2$ eval $(weave proxy-env)
This delegates the entire 10.2.0.0/16 subnet to weave, and instructs This delegates the entire 10.2.0.0/16 subnet to weave, and instructs
+13 -4
View File
@@ -23,11 +23,18 @@ instead of `weave run`.
## <a name="setup"></a>Setup ## <a name="setup"></a>Setup
The proxy sits between the Docker client (command line or API) and the The proxy sits between the Docker client (command line or API) and the
Docker daemon, intercepting the communication between the two. Docker daemon, intercepting the communication between the two. You can
start it simultaneously with the router and weaveDNS via `launch`:
To start the proxy, run host1$ weave launch
host1$ weave launch-proxy or independently via `launch-proxy`:
host1$ weave launch-router && weave launch-dns && weave launch-proxy
The first form is more convenient, however you can only pass proxy
related configuration arguments to `launch-proxy` so if you need to
modify the default behaviour you will have to use the latter.
By default, the proxy listens on port 12375, on all network By default, the proxy listens on port 12375, on all network
interfaces. This can be adjusted with the `-H` argument, e.g. interfaces. This can be adjusted with the `-H` argument, e.g.
@@ -49,10 +56,12 @@ Alternatively, the proxy host can be set on a per-command basis with
host1$ docker $(weave proxy-config) ps host1$ docker $(weave proxy-config) ps
The proxy can be stopped with The proxy can be stopped independently with
host1$ weave stop-proxy host1$ weave stop-proxy
or in conjunction with the router and weaveDNS via `stop`.
If you set your `DOCKER_HOST` to point at the proxy, remember to If you set your `DOCKER_HOST` to point at the proxy, remember to
revert to the original setting. revert to the original setting.
+19 -5
View File
@@ -28,13 +28,23 @@ hosts.
WeaveDNS is deployed as a set of containers that communicate with each WeaveDNS is deployed as a set of containers that communicate with each
other over the weave network. One such container needs to be started other over the weave network. One such container needs to be started
on every weave host, by invoking the weave script command on every weave host, either simultaneously with the router and proxy
`launch-dns`: via `launch`:
```bash ```bash
host1$ weave launch && weave launch-dns && weave launch-proxy host1$ weave launch
host1$ eval $(weave proxy-env) host1$ eval $(weave proxy-env)
``` ```
or independently via `launch-dns`:
```bash
host1$ weave launch-router && weave launch-dns && weave launch-proxy
host1$ eval $(weave proxy-env)
```
The first form is more convenient, however you can only pass weaveDNS
related configuration arguments to `launch-dns` so if you need to
modify the default behaviour you will have to use the latter.
Application containers will use weaveDNS automatically if it is Application containers will use weaveDNS automatically if it is
running at the point when they are started. They will use it for name running at the point when they are started. They will use it for name
@@ -67,7 +77,11 @@ however specify an address in CIDR format manually. In this case you
are responsible for ensuring that the IP addresses specified are are responsible for ensuring that the IP addresses specified are
uniquely allocated and not in use by any other container. uniquely allocated and not in use by any other container.
Finally, WeaveDNS containers can be stopped with `stop-dns`. Finally, weaveDNS can be stopped independently with
host1$ weave stop-dns
or in conjunction with the router and proxy via `stop`.
## <a name="how-it-works"></a>How it works ## <a name="how-it-works"></a>How it works
@@ -112,7 +126,7 @@ Returning to our earlier example, let us start an additional `pingme`
container, this time on the 2nd host, and then run some ping tests... container, this time on the 2nd host, and then run some ping tests...
```bash ```bash
host2$ weave launch && weave launch-dns && weave launch-proxy host2$ weave launch
host2$ eval $(weave proxy-env) host2$ eval $(weave proxy-env)
host2$ docker run -dti --name=pingme ubuntu host2$ docker run -dti --name=pingme ubuntu
+4 -4
View File
@@ -15,8 +15,8 @@ assert_peers() {
start_suite "Connecting and forgetting routers after launch" start_suite "Connecting and forgetting routers after launch"
weave_on $HOST1 launch weave_on $HOST1 launch-router
weave_on $HOST2 launch weave_on $HOST2 launch-router
start_container $HOST1 $C1/24 --name=c1 start_container $HOST1 $C1/24 --name=c1
start_container $HOST2 $C2/24 --name=c2 start_container $HOST2 $C2/24 --name=c2
@@ -33,8 +33,8 @@ assert_raises "exec_on $HOST1 c1 $PING $C2"
# Forget everyone and disonnect # Forget everyone and disonnect
assert_raises "weave_on $HOST2 forget $HOST1 $HOST2" assert_raises "weave_on $HOST2 forget $HOST1 $HOST2"
assert_raises "weave_on $HOST1 stop" assert_raises "weave_on $HOST1 stop-router"
assert_raises "weave_on $HOST1 launch" assert_raises "weave_on $HOST1 launch-router"
assert_peers $HOST2 "" assert_peers $HOST2 ""
assert_raises "exec_on $HOST1 c1 sh -c '! $PING $C2'" assert_raises "exec_on $HOST1 c1 sh -c '! $PING $C2'"
+2 -2
View File
@@ -29,8 +29,8 @@ check() {
start_suite "Resolve names across hosts (with and without IPAM), and repopulate on restart" start_suite "Resolve names across hosts (with and without IPAM), and repopulate on restart"
weave_on $HOST1 launch -iprange $UNIVERSE weave_on $HOST1 launch-router -iprange $UNIVERSE
weave_on $HOST2 launch -iprange $UNIVERSE $HOST1 weave_on $HOST2 launch-router -iprange $UNIVERSE $HOST1
start_container $HOST2 $C2/24 --name=c2 -h $NAME2 start_container $HOST2 $C2/24 --name=c2 -h $NAME2
start_container_with_dns $HOST1 $C1/24 --name=c1 start_container_with_dns $HOST1 $C1/24 --name=c1
+1 -1
View File
@@ -20,7 +20,7 @@ assert_resolution() {
start_suite "With or without DNS test" start_suite "With or without DNS test"
weave_on $HOST1 launch weave_on $HOST1 launch-router
DNS_IP=$(weave_on $HOST1 docker-bridge-ip) DNS_IP=$(weave_on $HOST1 docker-bridge-ip)
+1 -1
View File
@@ -73,7 +73,7 @@ start_suite "Weave run/start/attach/detach/expose/hide with multiple cidr argume
# specific address, i.e. we are assuming that IPAM always returns the # specific address, i.e. we are assuming that IPAM always returns the
# lowest available address in the subnet # lowest available address in the subnet
weave_on $HOST1 launch -debug -iprange 10.2.3.0/24 weave_on $HOST1 launch-router -debug -iprange 10.2.3.0/24
launch_dns_on $HOST1 10.254.254.254/24 launch_dns_on $HOST1 10.254.254.254/24
# Run container with three cidrs # Run container with three cidrs
+1 -1
View File
@@ -26,7 +26,7 @@ run_container "grep ^1$ /sys/class/net/ethwe/carrier"
build_image false '["/bin/false"]' '' build_image false '["/bin/false"]' ''
run_container "--entrypoint='grep' false ^1$ /sys/class/net/ethwe/carrier" run_container "--entrypoint='grep' false ^1$ /sys/class/net/ethwe/carrier"
weave_on $HOST1 launch -iprange 10.2.2.0/24 weave_on $HOST1 launch-router -iprange 10.2.2.0/24
docker_on $HOST1 kill weaveproxy docker_on $HOST1 kill weaveproxy
weave_on $HOST1 launch-proxy weave_on $HOST1 launch-proxy
+1 -1
View File
@@ -13,6 +13,6 @@ assert_raises "docker $(weave_on $HOST1 proxy-config) $CMD"
# Check we can use the weave script through the proxy # Check we can use the weave script through the proxy
assert_raises "eval '$(weave_on $HOST1 proxy-env)' ; $WEAVE version" assert_raises "eval '$(weave_on $HOST1 proxy-env)' ; $WEAVE version"
assert_raises "eval '$(weave_on $HOST1 proxy-env)' ; $WEAVE ps" assert_raises "eval '$(weave_on $HOST1 proxy-env)' ; $WEAVE ps"
assert_raises "eval '$(weave_on $HOST1 proxy-env)' ; $WEAVE launch" assert_raises "eval '$(weave_on $HOST1 proxy-env)' ; $WEAVE launch-router"
end_suite end_suite
+2 -2
View File
@@ -17,8 +17,8 @@ assert_no_ethwe() {
start_suite "Ping proxied containers over cross-host weave network (with IPAM)" start_suite "Ping proxied containers over cross-host weave network (with IPAM)"
weave_on $HOST1 launch -iprange $UNIVERSE weave_on $HOST1 launch-router -iprange $UNIVERSE
weave_on $HOST2 launch -iprange $UNIVERSE $HOST1 weave_on $HOST2 launch-router -iprange $UNIVERSE $HOST1
weave_on $HOST1 launch-proxy weave_on $HOST1 launch-proxy
weave_on $HOST2 launch-proxy --no-default-ipam weave_on $HOST2 launch-proxy --no-default-ipam
+1 -1
View File
@@ -6,7 +6,7 @@ start_suite "Boot the proxy with TLS-enabled Docker support"
PWD=$($SSH $HOST1 pwd) PWD=$($SSH $HOST1 pwd)
weave_on $HOST1 launch weave_on $HOST1 launch-router
weave_on $HOST1 launch-proxy \ weave_on $HOST1 launch-proxy \
--tlsverify \ --tlsverify \
--tlscacert $PWD/tls/ca.pem \ --tlscacert $PWD/tls/ca.pem \
+102 -68
View File
@@ -28,6 +28,8 @@ usage() {
echo "weave setup" echo "weave setup"
echo "weave launch [-password <password>] [-nickname <nickname>] [-nodiscovery]" echo "weave launch [-password <password>] [-nickname <nickname>] [-nodiscovery]"
echo " [-iprange <cidr> [-ipsubnet <cidr>]] <peer> ..." echo " [-iprange <cidr> [-ipsubnet <cidr>]] <peer> ..."
echo "weave launch-router [-password <password>] [-nickname <nickname>] [-nodiscovery]"
echo " [-iprange <cidr> [-ipsubnet <cidr>]] <peer> ..."
echo "weave launch-dns [<addr>]" echo "weave launch-dns [<addr>]"
echo "weave launch-proxy [-H <endpoint>] [--with-dns | --without-dns]" echo "weave launch-proxy [-H <endpoint>] [--with-dns | --without-dns]"
echo " [--no-default-ipam]" echo " [--no-default-ipam]"
@@ -47,6 +49,7 @@ usage() {
echo "weave proxy-config" echo "weave proxy-config"
echo "weave version" echo "weave version"
echo "weave stop" echo "weave stop"
echo "weave stop-router"
echo "weave stop-dns" echo "weave stop-dns"
echo "weave stop-proxy" echo "weave stop-proxy"
echo "weave reset" echo "weave reset"
@@ -933,67 +936,11 @@ proxy_addr() {
return 1 return 1
} }
########################################################################################## ######################################################################
# launch helpers
######################################################################
[ $(id -u) = 0 ] || { launch_router() {
echo "weave must be run as 'root' when run locally" >&2
exit 1
}
uname -s -r | sed -n -e 's|^\([^ ]*\) \([0-9][0-9]*\)\.\([0-9][0-9]*\).*|\1 \2 \3|p' | {
if ! read sys maj min ; then
echo "ERROR: Unable to parse operating system version $(uname -s -r)" >&2
exit 1
fi
if [ "$sys" != 'Linux' ] ; then
echo "ERROR: Operating systems other than Linux are not supported (you have $(uname -s -r))" >&2
exit 1
fi
if ! [ \( "$maj" -eq 3 -a "$min" -ge 8 \) -o "$maj" -gt 3 ] ; then
echo "WARNING: Linux kernel version 3.8 or newer is required (you have ${maj}.${min})" >&2
fi
}
if ! command_exists ip ; then
echo "ERROR: ip utility is missing. Please install it." >&2
exit 1
fi
if ! ip netns list >/dev/null 2>&1 ; then
echo "ERROR: $(ip -V) does not support network namespaces." >&2
echo " Please install iproute2-ss111010 or later." >&2
exit 1
fi
if ! command_exists nsenter ; then
echo "ERROR: nsenter utility missing. Please install it." >&2
exit 1
fi
check_docker_version
DOCKER_VERSION_MAJOR=$(echo "$DOCKER_VERSION" | cut -d. -f 1)
DOCKER_VERSION_MINOR=$(echo "$DOCKER_VERSION" | cut -d. -f 2)
DOCKER_VERSION_PATCH=$(echo "$DOCKER_VERSION" | cut -d. -f 3)
[ $# -gt 0 ] || usage
COMMAND=$1
shift 1
case "$COMMAND" in
setup)
for img in $IMAGE $DNS_IMAGE $EXEC_IMAGE ; do
docker pull $img
done
;;
# intentionally undocumented since it assumes knowledge of weave
# internals
create-bridge)
create_bridge --without-ethtool
;;
launch)
check_not_running $CONTAINER_NAME $BASE_IMAGE
create_bridge create_bridge
# We set the router name to the bridge mac since that is # We set the router name to the bridge mac since that is
# stable across re-creations of the containers. # stable across re-creations of the containers.
@@ -1060,13 +1007,12 @@ case "$COMMAND" in
# Tell the newly-started weave IP allocator about existing weave IPs # Tell the newly-started weave IP allocator about existing weave IPs
with_container_addresses ipam_claim weave:expose $(docker ps -q --no-trunc) with_container_addresses ipam_claim weave:expose $(docker ps -q --no-trunc)
fi fi
echo $CONTAINER }
;;
launch-dns) launch_dns() {
collect_cidr_args "$@" collect_cidr_args "$@"
[ $CIDR_ARG_COUNT -lt 2 ] || usage [ $CIDR_ARG_COUNT -lt 2 ] || usage
shift $CIDR_ARG_COUNT shift $CIDR_ARG_COUNT
check_not_running $DNS_CONTAINER_NAME $BASE_DNS_IMAGE
create_bridge create_bridge
docker_bridge_ip docker_bridge_ip
# Set WEAVEDNS_DOCKER_ARGS in the environment in order to supply # Set WEAVEDNS_DOCKER_ARGS in the environment in order to supply
@@ -1080,10 +1026,9 @@ case "$COMMAND" in
ipam_cidrs_or_die $DNS_CONTAINER $CIDR_ARGS ipam_cidrs_or_die $DNS_CONTAINER $CIDR_ARGS
with_container_netns_or_die $DNS_CONTAINER attach $ALL_CIDRS with_container_netns_or_die $DNS_CONTAINER attach $ALL_CIDRS
populate_dns populate_dns
echo $DNS_CONTAINER }
;;
launch-proxy) launch_proxy() {
check_not_running $PROXY_CONTAINER_NAME $EXEC_IMAGE
# Set WEAVEPROXY_DOCKER_ARGS in the environment in order to supply # Set WEAVEPROXY_DOCKER_ARGS in the environment in order to supply
# additional parameters, such as resource limits, to docker # additional parameters, such as resource limits, to docker
# when launching the weaveproxy container. # when launching the weaveproxy container.
@@ -1097,6 +1042,88 @@ case "$COMMAND" in
--entrypoint=/home/weave/weaveproxy \ --entrypoint=/home/weave/weaveproxy \
$WEAVEPROXY_DOCKER_ARGS $EXEC_IMAGE $PROXY_ARGS) $WEAVEPROXY_DOCKER_ARGS $EXEC_IMAGE $PROXY_ARGS)
wait_for_log $PROXY_CONTAINER_NAME "proxy listening" wait_for_log $PROXY_CONTAINER_NAME "proxy listening"
}
##########################################################################################
[ $(id -u) = 0 ] || {
echo "weave must be run as 'root' when run locally" >&2
exit 1
}
uname -s -r | sed -n -e 's|^\([^ ]*\) \([0-9][0-9]*\)\.\([0-9][0-9]*\).*|\1 \2 \3|p' | {
if ! read sys maj min ; then
echo "ERROR: Unable to parse operating system version $(uname -s -r)" >&2
exit 1
fi
if [ "$sys" != 'Linux' ] ; then
echo "ERROR: Operating systems other than Linux are not supported (you have $(uname -s -r))" >&2
exit 1
fi
if ! [ \( "$maj" -eq 3 -a "$min" -ge 8 \) -o "$maj" -gt 3 ] ; then
echo "WARNING: Linux kernel version 3.8 or newer is required (you have ${maj}.${min})" >&2
fi
}
if ! command_exists ip ; then
echo "ERROR: ip utility is missing. Please install it." >&2
exit 1
fi
if ! ip netns list >/dev/null 2>&1 ; then
echo "ERROR: $(ip -V) does not support network namespaces." >&2
echo " Please install iproute2-ss111010 or later." >&2
exit 1
fi
if ! command_exists nsenter ; then
echo "ERROR: nsenter utility missing. Please install it." >&2
exit 1
fi
check_docker_version
DOCKER_VERSION_MAJOR=$(echo "$DOCKER_VERSION" | cut -d. -f 1)
DOCKER_VERSION_MINOR=$(echo "$DOCKER_VERSION" | cut -d. -f 2)
DOCKER_VERSION_PATCH=$(echo "$DOCKER_VERSION" | cut -d. -f 3)
[ $# -gt 0 ] || usage
COMMAND=$1
shift 1
case "$COMMAND" in
setup)
for img in $IMAGE $DNS_IMAGE $EXEC_IMAGE ; do
docker pull $img
done
;;
# intentionally undocumented since it assumes knowledge of weave
# internals
create-bridge)
create_bridge --without-ethtool
;;
launch)
check_not_running $CONTAINER_NAME $BASE_IMAGE
check_not_running $DNS_CONTAINER_NAME $BASE_DNS_IMAGE
check_not_running $PROXY_CONTAINER_NAME $EXEC_IMAGE
launch_router "$@"
launch_dns
launch_proxy
;;
launch-router)
check_not_running $CONTAINER_NAME $BASE_IMAGE
launch_router "$@"
echo $CONTAINER
;;
launch-dns)
check_not_running $DNS_CONTAINER_NAME $BASE_DNS_IMAGE
launch_dns "$@"
echo $DNS_CONTAINER
;;
launch-proxy)
check_not_running $PROXY_CONTAINER_NAME $EXEC_IMAGE
launch_proxy "$@"
echo $PROXY_CONTAINER echo $PROXY_CONTAINER
;; ;;
proxy-env) proxy-env)
@@ -1275,6 +1302,13 @@ case "$COMMAND" in
show_addrs $ALL_CIDRS show_addrs $ALL_CIDRS
;; ;;
stop) stop)
[ $# -eq 0 ] || usage
stop $PROXY_CONTAINER_NAME "Proxy"
stop $DNS_CONTAINER_NAME "WeaveDNS"
stop $CONTAINER_NAME "Weave"
conntrack -D -p udp --dport $PORT >/dev/null 2>&1 || true
;;
stop-router)
[ $# -eq 0 ] || usage [ $# -eq 0 ] || usage
stop $CONTAINER_NAME "Weave" stop $CONTAINER_NAME "Weave"
conntrack -D -p udp --dport $PORT >/dev/null 2>&1 || true conntrack -D -p udp --dport $PORT >/dev/null 2>&1 || true