Skip to content

Instantly share code, notes, and snippets.

@mangalaman93
Last active October 12, 2015 23:09
Show Gist options
  • Save mangalaman93/6c43e38f7053e46f3ec3 to your computer and use it in GitHub Desktop.
Save mangalaman93/6c43e38f7053e46f3ec3 to your computer and use it in GitHub Desktop.
##### NETWORK SETUP #####
# we will use docker0 bridge for network connectivity
# pi is connected to the laptop over ethernet
# on host (laptop in this case)
sudo brctl addif docker0 eth0
# on pi
ifconfig eth0 172.17.42.234
ifconfig eth0 netmask 255.255.0.0
route add default gw 172.17.42.1
# etcd compilation
env GOOS=linux GOARCH=arm GOARM=7 go build
# setting up etcd cluster
export HOST_IP=172.17.42.1
export SERVER_PI=172.17.42.234
export PEER_PORT0=5999
export PEER_PORT1=6000
export CLIENT_PORT0=6001
export CLIENT_PORT1=6002
# on pi
./etcd -name etcdpi -data-dir data/ -advertise-client-urls http://${SERVER_PI}:2379 \
-listen-client-urls http://0.0.0.0:2379 \
-initial-advertise-peer-urls http://${SERVER_PI}:2380 \
-listen-peer-urls http://0.0.0.0:2380 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster etcdpi=http://${SERVER_PI}:2380,etcd0=http://${HOST_IP}:${PEER_PORT0},etcd1=http://${HOST_IP}:${PEER_PORT1} \
-initial-cluster-state new
# on host
docker run -d -p ${CLIENT_PORT0}:2379 -p ${PEER_PORT0}:2380 --name etcd0 quay.io/coreos/etcd:v2.2.0 \
-name etcd0 \
-data-dir /data \
-advertise-client-urls http://${HOST_IP}:${CLIENT_PORT0} \
-listen-client-urls http://0.0.0.0:2379 \
-initial-advertise-peer-urls http://${HOST_IP}:${PEER_PORT0} \
-listen-peer-urls http://0.0.0.0:2380 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster etcdpi=http://${SERVER_PI}:2380,etcd0=http://${HOST_IP}:${PEER_PORT0},etcd1=http://${HOST_IP}:${PEER_PORT1} \
-initial-cluster-state new
docker run -d -p ${CLIENT_PORT1}:2379 -p ${PEER_PORT1}:2380 --name etcd1 quay.io/coreos/etcd:v2.2.0 \
-name etcd1 \
-data-dir /data \
-advertise-client-urls http://${HOST_IP}:${CLIENT_PORT1} \
-listen-client-urls http://0.0.0.0:2379 \
-initial-advertise-peer-urls http://${HOST_IP}:${PEER_PORT1} \
-listen-peer-urls http://0.0.0.0:2380 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster etcdpi=http://${SERVER_PI}:2380,etcd0=http://${HOST_IP}:${PEER_PORT0},etcd1=http://${HOST_IP}:${PEER_PORT1} \
-initial-cluster-state new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment