From c660ca5ac48d0a24ec46d906b056eb8e915ff001 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Fri, 7 Apr 2017 13:17:59 +0100 Subject: [PATCH] demo: Create a cluster of 5 etcd daemons Also tweak the shell script a little and give the local and GCP infrakit group different names. Signed-off-by: Rolf Neugebauer --- projects/demo/etcd/README.md | 2 +- projects/demo/etcd/etcd.sh | 15 ++++++++------- projects/demo/etcd/etcd.yml | 8 ++++---- projects/demo/etcd/infrakit-gcp.json | 6 ++++-- projects/demo/etcd/infrakit.json | 4 +++- 5 files changed, 20 insertions(+), 15 deletions(-) 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/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..ef9508f68 100644 --- a/projects/demo/etcd/etcd.yml +++ b/projects/demo/etcd/etcd.yml @@ -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-gcp.json b/projects/demo/etcd/infrakit-gcp.json index da19092c4..7a952e298 100644 --- a/projects/demo/etcd/infrakit-gcp.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": {