Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Move weave script into tools image with its deps #388

Merged
merged 10 commits into from
Mar 20, 2015
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ tools/build
releases
weave.tar
weavedns.tar
weavetools.tar
weaveexec.tar
weaveexec/docker*.tgz
43 changes: 19 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PUBLISH=publish_weave publish_weavedns publish_weavetools
PUBLISH=publish_weave publish_weavedns publish_weaveexec

.DEFAULT: all
.PHONY: all update tests publish $(PUBLISH) clean prerequisites build
Expand All @@ -10,15 +10,18 @@ DOCKERHUB_USER=zettio
WEAVE_VERSION=git-$(shell git rev-parse --short=12 HEAD)
WEAVER_EXE=weaver/weaver
WEAVEDNS_EXE=weavedns/weavedns
WEAVETOOLS_EXES=tools/bin
WEAVER_IMAGE=$(DOCKERHUB_USER)/weave
WEAVEDNS_IMAGE=$(DOCKERHUB_USER)/weavedns
WEAVETOOLS_IMAGE=$(DOCKERHUB_USER)/weavetools
WEAVEEXEC_IMAGE=$(DOCKERHUB_USER)/weaveexec
WEAVER_EXPORT=weave.tar
WEAVEDNS_EXPORT=weavedns.tar
WEAVETOOLS_EXPORT=weavetools.tar
WEAVEEXEC_EXPORT=weaveexec.tar

all: $(WEAVER_EXPORT) $(WEAVEDNS_EXPORT) $(WEAVETOOLS_EXPORT)
WEAVEEXEC_DOCKER_VERSION=1.3.1
DOCKER_DISTRIB=weaveexec/docker-$(WEAVEEXEC_DOCKER_VERSION).tgz
DOCKER_DISTRIB_URL=https://get.docker.com/builds/Linux/x86_64/docker-$(WEAVEEXEC_DOCKER_VERSION).tgz

all: $(WEAVER_EXPORT) $(WEAVEDNS_EXPORT) $(WEAVEEXEC_EXPORT)

update:
go get -u -f -v -tags -netgo ./$(dir $(WEAVER_EXE)) ./$(dir $(WEAVEDNS_EXE))
Expand All @@ -38,18 +41,6 @@ $(WEAVER_EXE) $(WEAVEDNS_EXE): common/*.go
$(WEAVER_EXE): router/*.go weaver/main.go
$(WEAVEDNS_EXE): nameserver/*.go weavedns/main.go

build_weavetools_exes_in_container=yes

$(WEAVETOOLS_EXES): tools/build.sh
ifdef build_weavetools_exes_in_container
$(SUDO) docker run --rm -t -v $(realpath $(<D)):/home/weave ubuntu sh /home/weave/build.sh
else
rm -rf tools/build
mkdir tools/build
cd tools/build && sh ../../$<
rm -rf tools/build
endif

$(WEAVER_EXPORT): weaver/Dockerfile $(WEAVER_EXE)
$(SUDO) docker build -t $(WEAVER_IMAGE) weaver
$(SUDO) docker save $(WEAVER_IMAGE):latest > $@
Expand All @@ -58,9 +49,14 @@ $(WEAVEDNS_EXPORT): weavedns/Dockerfile $(WEAVEDNS_EXE)
$(SUDO) docker build -t $(WEAVEDNS_IMAGE) weavedns
$(SUDO) docker save $(WEAVEDNS_IMAGE):latest > $@

$(WEAVETOOLS_EXPORT): tools/Dockerfile $(WEAVETOOLS_EXES)
$(SUDO) docker build -t $(WEAVETOOLS_IMAGE) tools
$(SUDO) docker save $(WEAVETOOLS_IMAGE):latest > $@
$(WEAVEEXEC_EXPORT): weaveexec/Dockerfile $(DOCKER_DISTRIB) weave
cp weave weaveexec/weave
cp $(DOCKER_DISTRIB) weaveexec/docker.tgz
$(SUDO) docker build -t $(WEAVEEXEC_IMAGE) weaveexec
$(SUDO) docker save $(WEAVEEXEC_IMAGE):latest > $@

$(DOCKER_DISTRIB):
curl -o $(DOCKER_DISTRIB) $(DOCKER_DISTRIB_URL)

# Add more directories in here as more tests are created
tests:
Expand All @@ -75,11 +71,10 @@ $(PUBLISH): publish_%:
publish: $(PUBLISH)

clean:
-$(SUDO) docker rmi $(WEAVER_IMAGE) $(WEAVEDNS_IMAGE) $(WEAVETOOLS_IMAGE)
rm -f $(WEAVER_EXE) $(WEAVEDNS_EXE) $(WEAVER_EXPORT) $(WEAVEDNS_EXPORT) $(WEAVETOOLS_EXPORT)
$(SUDO) rm -rf $(WEAVETOOLS_EXES)
-$(SUDO) docker rmi $(WEAVER_IMAGE) $(WEAVEDNS_IMAGE) $(WEAVEEXEC_IMAGE)
rm -f $(WEAVER_EXE) $(WEAVEDNS_EXE) $(WEAVER_EXPORT) $(WEAVEDNS_EXPORT) $(WEAVEEXEC_EXPORT)

build:
$(SUDO) go clean -i net
$(SUDO) go install -tags netgo std
$(MAKE) build_weavetools_exes_in_container=
$(MAKE)
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ Ensure you are running Linux (kernel 3.5 or later) and have Docker

CoreOS users see [here](https://github.com/fintanr/weave-gs/blob/master/coreos-simple/user-data) for an example of installing weave using cloud-config.

Weave respects the environment variable `DOCKER_HOST`, so you can run
it locally to control a weave network on a remote host.

## Quick Start Screencast

<a href="http://youtu.be/k6r7yuSr0hE" alt="Click to watch the screencast" target="_blank">
Expand Down
4 changes: 2 additions & 2 deletions site/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ $ make

This will build the weave components and package them into three
Docker images (`zettio/weave`, `zettio/weavedns`, and
`zettio/weavetools`). These are then exported (as
`weave.tar`, `weavedns.tar` and `weavetools.tar`).
`zettio/weaveexec`). These are then exported (as `weave.tar`,
`weavedns.tar` and `weaveexec.tar`).

## Building in a Docker container

Expand Down
12 changes: 6 additions & 6 deletions test/100_cross_hosts_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ C2=10.2.1.7
start_suite "Ping over cross-host weave network"

for HOST in $HOST1 $HOST2; do
run_on $HOST sudo $WEAVE stop || true
run_on $HOST sudo $WEAVE stop-dns || true
weave_on $HOST stop || true
weave_on $HOST stop-dns || true
docker_on $HOST rm -f c1 c2 || true
done

run_on $HOST1 sudo $WEAVE launch
run_on $HOST2 sudo $WEAVE launch $HOST1
weave_on $HOST1 launch
weave_on $HOST2 launch $HOST1

run_on $HOST2 sudo $WEAVE run $C2/24 -t --name=c2 ubuntu
run_on $HOST1 sudo $WEAVE run $C1/24 -t --name=c1 ubuntu
weave_on $HOST2 run $C2/24 -t --name=c2 ubuntu
weave_on $HOST1 run $C1/24 -t --name=c1 ubuntu
ok=$(docker -H tcp://$HOST1:2375 exec -i c1 sh -c "ping -q -c 4 $C2 >&2 && echo ok")
assert "echo $ok" "ok"

Expand Down
12 changes: 6 additions & 6 deletions test/110_encryption_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ C2=10.2.1.7
start_suite "Ping over encrypted cross-host weave network"

for HOST in $HOST1 $HOST2; do
run_on $HOST sudo $WEAVE stop || true
run_on $HOST sudo $WEAVE stop-dns || true
weave_on $HOST stop || true
weave_on $HOST stop-dns || true
docker_on $HOST rm -f c1 c2 || true
done

run_on $HOST1 sudo $WEAVE launch -password notverysecure
run_on $HOST2 sudo $WEAVE launch -password notverysecure $HOST1
weave_on $HOST1 launch -password notverysecure
weave_on $HOST2 launch -password notverysecure $HOST1

run_on $HOST2 sudo $WEAVE run $C2/24 -t --name=c2 ubuntu
run_on $HOST1 sudo $WEAVE run $C1/24 -t --name=c1 ubuntu
weave_on $HOST2 run $C2/24 -t --name=c2 ubuntu
weave_on $HOST1 run $C1/24 -t --name=c1 ubuntu
ok=$(docker -H tcp://$HOST1:2375 exec -i c1 sh -c "ping -q -c 4 $C2 >&2 && echo ok")
assert "echo $ok" "ok"

Expand Down
10 changes: 5 additions & 5 deletions test/200_dns_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ C2=10.2.0.34

start_suite "Resolve names on a single host"

run_on $HOST1 sudo $WEAVE stop || true
run_on $HOST1 sudo $WEAVE stop-dns || true
run_on $HOST1 sudo $WEAVE launch-dns 10.2.254.1/24
weave_on $HOST1 stop || true
weave_on $HOST1 stop-dns || true
weave_on $HOST1 launch-dns 10.2.254.1/24

docker_on $HOST1 rm -f c1 c2 || true

run_on $HOST1 sudo $WEAVE run $C2/24 -t --name=c2 -h seetwo.weave.local ubuntu
run_on $HOST1 sudo $WEAVE run --with-dns $C1/24 -t --name=c1 aanand/docker-dnsutils /bin/sh
weave_on $HOST1 run $C2/24 -t --name=c2 -h seetwo.weave.local ubuntu
weave_on $HOST1 run --with-dns $C1/24 -t --name=c1 aanand/docker-dnsutils /bin/sh

ok=$(docker -H tcp://$HOST1:2375 exec -i c1 sh -c "dig +short seetwo.weave.local")
assert "echo $ok" "$C2"
Expand Down
16 changes: 8 additions & 8 deletions test/210_dns_multicast_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ C2=10.2.3.34
start_suite "Resolve names across hosts"

for host in $HOST1 $HOST2; do
run_on $host sudo $WEAVE stop || true
run_on $host sudo $WEAVE stop-dns || true
weave_on $host stop || true
weave_on $host stop-dns || true
docker_on $host rm -f c1 c2 || true
done

run_on $HOST1 sudo $WEAVE launch
run_on $HOST2 sudo $WEAVE launch $HOST1
weave_on $HOST1 launch
weave_on $HOST2 launch $HOST1

run_on $HOST1 sudo $WEAVE launch-dns 10.2.254.1/24 -debug
run_on $HOST2 sudo $WEAVE launch-dns 10.2.254.2/24 -debug
weave_on $HOST1 launch-dns 10.2.254.1/24 -debug
weave_on $HOST2 launch-dns 10.2.254.2/24 -debug

run_on $HOST2 sudo $WEAVE run $C2/24 -t --name=c2 -h seetwo.weave.local ubuntu
run_on $HOST1 sudo $WEAVE run --with-dns $C1/24 --name=c1 -t aanand/docker-dnsutils /bin/sh
weave_on $HOST2 run $C2/24 -t --name=c2 -h seetwo.weave.local ubuntu
weave_on $HOST1 run --with-dns $C1/24 --name=c1 -t aanand/docker-dnsutils /bin/sh

ok=$(docker -H tcp://$HOST1:2375 exec -i c1 dig +short seetwo.weave.local)
assert "echo $ok" "$C2"
Expand Down
10 changes: 5 additions & 5 deletions test/220_dns_custom_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ C2=10.2.54.91

start_suite "Resolve names in custom domain"

run_on $HOST1 sudo $WEAVE stop || true
run_on $HOST1 sudo $WEAVE stop-dns || true
run_on $HOST1 sudo $WEAVE launch-dns 10.2.254.1/24 --localDomain foo.bar.
weave_on $HOST1 stop || true
weave_on $HOST1 stop-dns || true
weave_on $HOST1 launch-dns 10.2.254.1/24 --localDomain foo.bar.

docker_on $HOST1 rm -f c1 c2 || true

run_on $HOST1 sudo $WEAVE run $C2/24 -t --name=c2 -h seetwo.foo.bar ubuntu
run_on $HOST1 sudo $WEAVE run --with-dns $C1/24 -t --name=c1 aanand/docker-dnsutils /bin/sh
weave_on $HOST1 run $C2/24 -t --name=c2 -h seetwo.foo.bar ubuntu
weave_on $HOST1 run --with-dns $C1/24 -t --name=c1 aanand/docker-dnsutils /bin/sh

ok=$(docker -H tcp://$HOST1:2375 exec -i c1 sh -c "dig +short seetwo.foo.bar.")
assert "echo $ok" "$C2"
Expand Down
6 changes: 3 additions & 3 deletions test/300_fallback_dns_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

start_suite "Resolve a non-weave address"

run_on $HOST1 sudo $WEAVE stop-dns || true
run_on $HOST1 sudo $WEAVE launch-dns 10.2.254.1/24 -debug
weave_on $HOST1 stop-dns || true
weave_on $HOST1 launch-dns 10.2.254.1/24 -debug
docker_on $HOST1 rm -f c1 || true

run_on $HOST1 sudo $WEAVE run --with-dns 10.2.1.5/24 --name=c1 -t aanand/docker-dnsutils /bin/sh
weave_on $HOST1 run --with-dns 10.2.1.5/24 --name=c1 -t aanand/docker-dnsutils /bin/sh

ok=$(docker -H tcp://$HOST1:2375 exec -i c1 dig +short -t MX weave.works)
assert "test -n \"$ok\" && echo pass" "pass"
Expand Down
19 changes: 19 additions & 0 deletions test/400_weave_local_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

. ./config.sh

start_suite "Run weave with --local"

run_on $HOST1 sudo ./weave --local reset

run_on $HOST1 sudo ./weave --local launch
assert_raises "docker_on $HOST1 ps | grep weave" 0

docker_on $HOST1 rm -f c1 || true
run_on $HOST1 sudo ./weave --local run 10.2.6.5/24 -ti --name=c1 ubuntu
ok=$(docker -H tcp://$HOST1:2375 exec -i c1 sh -c "ifconfig | grep ethwe")
assert "test -n \"$ok\" && echo pass" "pass"

docker_on $HOST1 rm -f c1 || true

end_suite
2 changes: 1 addition & 1 deletion test/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ip_prefix = "192.168.48"
ip_suffix_base = 10

def configure_docker(host, hostname, ip)
pkgs = "lxc-docker"
pkgs = "lxc-docker ethtool"

host.vm.box = "phusion/ubuntu-14.04-amd64"
host.vm.box_url = "https://oss-binaries.phusionpassenger.com/vagrant/boxes/latest/ubuntu-14.04-amd64-vbox.box"
Expand Down
9 changes: 8 additions & 1 deletion test/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ docker_on() {
docker -H tcp://$host:2375 $@
}

weave_on() {
host=$1
shift 1
greyly echo "Weave on $host: $@"
DOCKER_HOST=tcp://$host:2375 $WEAVE $@
}

start_suite() {
whitely echo $@
}
Expand All @@ -57,5 +64,5 @@ end_suite() {
whitely assert_end
}

WEAVE=./bin/weave
WEAVE=../weave
DOCKER_NS=./bin/docker-ns
9 changes: 4 additions & 5 deletions test/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ echo Copying weave images and script to hosts
for HOST in $HOSTS; do
docker_on $HOST load -i ../weave.tar
docker_on $HOST load -i ../weavedns.tar
docker_on $HOST load -i ../weavetools.tar
run_on $HOST mkdir -p `dirname $WEAVE`
cat ../weave | run_on $HOST sh -c "cat > $WEAVE"
docker_on $HOST load -i ../weaveexec.tar
run_on $HOST mkdir -p bin
cat ../bin/docker-ns | run_on $HOST sh -c "cat > $DOCKER_NS"
run_on $HOST chmod a+x $WEAVE
run_on $HOST chmod a+x $DOCKER_NS
cat ../weave | run_on $HOST sh -c "cat > ./weave"
run_on $HOST chmod a+x $DOCKER_NS ./weave
run_on $HOST sudo service docker restart
done
3 changes: 0 additions & 3 deletions tools/Dockerfile

This file was deleted.

62 changes: 0 additions & 62 deletions tools/build.sh

This file was deleted.

Loading