Files
linuxkit/projects/demo/etcd/etcd.sh
Rolf Neugebauer 2bd75a621d 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 <rolf.neugebauer@docker.com>
2017-04-06 17:22:56 +01:00

32 lines
923 B
Bash
Executable File

#! /bin/sh
# debug
set -x
set -v
# --initial-cluster argument should come from meta data
# 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} \
--debug \
--log-package-levels etcdmain=DEBUG,etcdserver=DEBUG \
--initial-advertise-peer-urls http://${IP}:2380 \
--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-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