Created
April 27, 2017 15:08
-
-
Save dfukunaga/f69c736878985ded7a1e00cc2894c925 to your computer and use it in GitHub Desktop.
join new member to etcd cluster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -eu | |
: $1 $2 | |
LOCAL_IP=$1 | |
REMOTE_IP=$2 | |
set -o pipefail | |
INITIAL_CLUSTER=$( \ | |
curl -s http://${REMOTE_IP}:2379/v2/members \ | |
| jq -r 'reduce .members[] as $s (""; . + $s.name + "=" + $s.peerURLs[0] + ",")' \ | |
) | |
RESPONSE_CODE=$( \ | |
curl -s -XPOST http://${REMOTE_IP}:2379/v2/members \ | |
-H "Content-Type: application/json" \ | |
-d "{\"peerURLs\":[\"http://${LOCAL_IP}:2380\"]}" \ | |
) | |
./etcd --name ${LOCAL_IP} \ | |
--initial-advertise-peer-urls http://${LOCAL_IP}:2380 \ | |
--listen-peer-urls http://0.0.0.0:2380 \ | |
--advertise-client-urls http://${LOCAL_IP}:2379 \ | |
--listen-client-urls http://0.0.0.0:2379 \ | |
--initial-cluster ${LOCAL_IP}=http://${LOCAL_IP}:2380,${INITIAL_CLUSTER} \ | |
--initial-cluster-token cluster1 \ | |
--initial-cluster-state existing &>${LOCAL_IP}.etcd.log & | |
echo $! > ${LOCAL_IP}.etcd.pid | |
echo "Join new member to etcd cluster (LOGFILE=${LOCAL_IP}.etcd.log, PIDFILE=${LOCAL_IP}.etcd.pid)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment