From 2bd75a621d485d5f3e784fad0801172b2b7f65c8 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Thu, 6 Apr 2017 12:26:51 +0100 Subject: [PATCH] demo: Switch etcd bootstrap from discovery service to static IPs This makes the configuration simpler but requires us to be able to set IP addresses on instances. This also, for simplicity, reduces the number of nodes to 3. The script does not make assumption about specific IP addresses, but does assume that the nodes have IP addresses such as: a.b.c.200, a.b.c.201, and a.b.c.202. Signed-off-by: Rolf Neugebauer --- projects/demo/etcd/etcd.sh | 21 +++++++++++++++------ projects/demo/etcd/infrakit.json | 4 +--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/projects/demo/etcd/etcd.sh b/projects/demo/etcd/etcd.sh index 8baa9eb4b..a2d6ad05e 100755 --- a/projects/demo/etcd/etcd.sh +++ b/projects/demo/etcd/etcd.sh @@ -4,12 +4,19 @@ set -x set -v -# Needs to come from metadata -UUID=6c007a14875d53d9bf0ef5a6fc0257c817f0fb83 -DISCOVER_URL=http://192.168.65.2:2381/v2/keys/discovery/${UUID} +# --initial-cluster argument should come from meta data -IP=$(ifconfig eth0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://') -NAME=$(hostname) +# Wait till we have an IP address +IP="" +while [ -z "$IP" ]; do + IP=$(ifconfig eth0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://') + sleep 1 +done + +# Name is infra+last octet of IP address +NUM=$(echo ${IP} | cut -d . -f 4) +PREFIX=$(echo ${IP} | cut -d . -f 1,2,3) +NAME=infra${NUM} /usr/local/bin/etcd \ --name ${NAME} \ @@ -19,4 +26,6 @@ NAME=$(hostname) --listen-peer-urls http://${IP}:2380 \ --listen-client-urls http://${IP}:2379,http://127.0.0.1:2379 \ --advertise-client-urls http://${IP}:2379 \ - --discovery ${DISCOVER_URL} + --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-state new diff --git a/projects/demo/etcd/infrakit.json b/projects/demo/etcd/infrakit.json index 0e12f019a..c4844dd7e 100644 --- a/projects/demo/etcd/infrakit.json +++ b/projects/demo/etcd/infrakit.json @@ -5,9 +5,7 @@ "LogicalIDs": [ "192.168.65.200", "192.168.65.201", - "192.168.65.202", - "192.168.65.203", - "192.168.65.204" + "192.168.65.202" ] }, "Instance": {