diff --git a/projects/demo/README.md b/projects/demo/README.md index 18f1bcaca..e62e07024 100644 --- a/projects/demo/README.md +++ b/projects/demo/README.md @@ -6,7 +6,7 @@ Most of the scripts/files assume you are on a Mac. - Recent Docker for Mac installed (edge, nightly, master channel) - Currently, you need a *custom* version of VPNKit installed in Docker - for Mac. Contact @magnus or @rneugeba. + for Mac (see below) - For the GCP portion: `brew install google-cloud-sdk` - For `etcd`: `brew install etcd` - Infrakit: Clone [infrakit](https://github.com/docker/infrakit) and @@ -14,6 +14,32 @@ Most of the scripts/files assume you are on a Mac. infrakit. For each, `make build-in-container` and then copy the contents of `./build` somewhere in your path. +For some of the demos, you currently need an updated version of VPNKit +for Docker for Mac. Hopefully this version will ship as default soon. + +Quit docker for Mac +``` +curl -fsSL --retry 10 -z vpnkit.tgz -o vpnkit.tgz https://circle-artifacts.com/gh/docker/vpnkit/708/artifacts/0/Users/distiller/vpnkit/vpnkit.tgz + +tar xzvf vpnkit.tgz +cp Contents/MacOS/vpnkit /Applications/Docker.app/Contents/Resources/bin/ +``` +Restart Docker for Mac. + + +# Local setup + +We use a `socat` container to forward ports from the VM to localhost (via Docker for Mac), to make it easier to access some VMs. To build +``` +(cd dockerfiles; docker build -t socat -f Dockerfile.socat .) +``` +And then run: +``` +docker run --rm -t -d -p 8080:8080 socat tcp-listen:8080,reuseaddr,fork tcp:192.168.65.100:80 +``` +This forwards local port `8080` to `192.168.65.100:80`, so if you start, say the `intro` image, run `moby run -ip 196.168.65.100 intro` + + # GCP Setup You probably want to change the project/zone diff --git a/projects/demo/dockerfiles/Dockerfile.socat b/projects/demo/dockerfiles/Dockerfile.socat new file mode 100644 index 000000000..8f1c78731 --- /dev/null +++ b/projects/demo/dockerfiles/Dockerfile.socat @@ -0,0 +1,8 @@ +# A dockerfile to build a socat container +# +# It sets the environment to talk to the local cluster +FROM alpine:edge + +RUN apk add --no-cache socat + +ENTRYPOINT [ "/usr/bin/socat" ] diff --git a/projects/demo/etcd/Dockerfile.local b/projects/demo/etcd/Dockerfile.local new file mode 100644 index 000000000..c614418ac --- /dev/null +++ b/projects/demo/etcd/Dockerfile.local @@ -0,0 +1,6 @@ +# A dockerfile to build an etcd container image from the upstream one +# +# It sets the environment to talk to the local cluster +FROM quay.io/coreos/etcd:v3.1.5 + +ENV ETCDCTL_ENDPOINTS="http://192.168.65.200:2379,http://192.168.65.201:2379,http://192.168.65.202:2379,http://192.168.65.203:2379,http://192.168.65.204:2379" diff --git a/projects/demo/etcd/README.md b/projects/demo/etcd/README.md index 8b93ceab2..9acd91471 100644 --- a/projects/demo/etcd/README.md +++ b/projects/demo/etcd/README.md @@ -15,7 +15,7 @@ moby build etcd ## InfraKit cluster setup (OUTDATED) -This should create a HyperKit based, InfraKit managed `etcd` cluster with 3 `etcd` instances. +This should create a HyperKit based, InfraKit managed `etcd` cluster with 5 `etcd` instances. Start InfraKit: ``` diff --git a/projects/demo/etcd/build-pkg.sh b/projects/demo/etcd/build-pkg.sh index 1142c2133..a1da2c2f5 100755 --- a/projects/demo/etcd/build-pkg.sh +++ b/projects/demo/etcd/build-pkg.sh @@ -1,2 +1,4 @@ #! /bin/sh docker build -t mobylinux/etcd . + +docker build -t etcd.local -f Dockerfile.local . diff --git a/projects/demo/etcd/etcd.sh b/projects/demo/etcd/etcd.sh index 8003145d9..e93641c0c 100755 --- a/projects/demo/etcd/etcd.sh +++ b/projects/demo/etcd/etcd.sh @@ -4,8 +4,6 @@ set -x set -v -# --initial-cluster argument should come from meta data - # Wait till we have an IP address IP="" while [ -z "$IP" ]; do @@ -18,6 +16,10 @@ NUM=$(echo ${IP} | cut -d . -f 4) PREFIX=$(echo ${IP} | cut -d . -f 1,2,3) NAME=infra${NUM} +# This should come from Metadata +INIT_CLUSTER=infra200=http://${PREFIX}.200:2380,infra201=http://${PREFIX}.201:2380,infra202=http://${PREFIX}.202:2380,infra203=http://${PREFIX}.203:2380,infra204=http://${PREFIX}.204:2380 + +# Try to start in *new* cluster mode /usr/local/bin/etcd \ --name ${NAME} \ --debug \ @@ -27,13 +29,12 @@ NAME=infra${NUM} --listen-client-urls http://${IP}:2379,http://127.0.0.1:2379 \ --advertise-client-urls http://${IP}:2379 \ --initial-cluster-token etcd-cluster-1 \ - --initial-cluster infra200=http://${PREFIX}.200:2380,infra201=http://${PREFIX}.201:2380,infra202=http://${PREFIX}.202:2380 \ + --initial-cluster ${INIT_CLUSTER} \ --initial-cluster-state new -echo "Returned $?" +[ $? -eq 0 ] && exit 0 -# If we get here, joining a new cluster failed. Let's try joining an -# existing cluster +# Joining the new cluster failed. Let's try joining an *existing* cluster /usr/local/bin/etcd \ --name ${NAME} \ --debug \ @@ -42,5 +43,5 @@ echo "Returned $?" --listen-peer-urls http://${IP}:2380 \ --listen-client-urls http://${IP}:2379,http://127.0.0.1:2379 \ --advertise-client-urls http://${IP}:2379 \ - --initial-cluster infra200=http://${PREFIX}.200:2380,infra201=http://${PREFIX}.201:2380,infra202=http://${PREFIX}.202:2380 \ + --initial-cluster ${INIT_CLUSTER} \ --initial-cluster-state existing diff --git a/projects/demo/etcd/etcd.yml b/projects/demo/etcd/etcd.yml index 3cbcfad17..2fc4605bf 100644 --- a/projects/demo/etcd/etcd.yml +++ b/projects/demo/etcd/etcd.yml @@ -20,7 +20,7 @@ daemon: oomScoreAdj: -800 readonly: true - name: dhcpcd - image: "mobylinux/dhcpcd:d01a17d211218f289e2bac601bfe9787d4fabaf2" + image: "mobylinux/dhcpcd:3eb32da7ff8051f61e0f18edd90dd0fbfcf148ea" binds: - /var:/var - /tmp/etc:/etc @@ -41,7 +41,7 @@ daemon: net: host outputs: - format: kernel+initrd - - format: gce - project: docker4x - bucket: rolf - replace: true +# - format: gcp +# project: docker4x +# bucket: rolf +# replace: true diff --git a/projects/demo/etcd/infrakit-gce.json b/projects/demo/etcd/infrakit-gcp.json similarity index 89% rename from projects/demo/etcd/infrakit-gce.json rename to projects/demo/etcd/infrakit-gcp.json index da19092c4..7a952e298 100644 --- a/projects/demo/etcd/infrakit-gce.json +++ b/projects/demo/etcd/infrakit-gcp.json @@ -1,11 +1,13 @@ { - "ID": "etcd", + "ID": "etcd.gcp", "Properties": { "Allocation": { "LogicalIDs": [ "10.132.0.200", "10.132.0.201", - "10.132.0.202" + "10.132.0.202", + "10.132.0.203", + "10.132.0.204" ] }, "Instance": { diff --git a/projects/demo/etcd/infrakit.json b/projects/demo/etcd/infrakit.json index d0d709e91..412333065 100644 --- a/projects/demo/etcd/infrakit.json +++ b/projects/demo/etcd/infrakit.json @@ -5,7 +5,9 @@ "LogicalIDs": [ "192.168.65.200", "192.168.65.201", - "192.168.65.202" + "192.168.65.202", + "192.168.65.203", + "192.168.65.204" ] }, "Instance": { diff --git a/projects/demo/etcd/start-infrakit.sh b/projects/demo/etcd/start-infrakit.sh new file mode 100755 index 000000000..0cf4162f2 --- /dev/null +++ b/projects/demo/etcd/start-infrakit.sh @@ -0,0 +1,18 @@ +# !/bin/sh + +# Start the infrakit plugins, save their PID + +INFRAKIT_HOME=~/.infrakit +IK_PLUGINS=$INFRAKIT_HOME/plugins + +rm -rf $INFRAKIT_HOME + +infrakit-flavor-vanilla & +infrakit-instance-hyperkit & +infrakit-instance-gcp --project docker4x --zone europe-west1-d & + +# start the group plugin in the foreground. If it exits, it will take +# the others down as well. +infrakit-group-default + +rm -rf $INFRAKIT_HOME diff --git a/projects/demo/intro/intro.yml b/projects/demo/intro/intro.yml index 2f89cede3..f71e6492f 100644 --- a/projects/demo/intro/intro.yml +++ b/projects/demo/intro/intro.yml @@ -14,7 +14,7 @@ system: readonly: true daemon: - name: dhcpcd - image: "mobylinux/dhcpcd:d01a17d211218f289e2bac601bfe9787d4fabaf2" + image: "mobylinux/dhcpcd:3eb32da7ff8051f61e0f18edd90dd0fbfcf148ea" binds: - /var:/var - /tmp/etc:/etc