Skip to content

Instantly share code, notes, and snippets.

@sufuf3
Last active October 8, 2018 10:54
Show Gist options
  • Save sufuf3/9aa0ac61e7ca554d6d8b29ad629e74d9 to your computer and use it in GitHub Desktop.
Save sufuf3/9aa0ac61e7ca554d6d8b29ad629e74d9 to your computer and use it in GitHub Desktop.
etcd add

On coco2

$ export ETCDCTL_API=3
$ export CA=/etc/etcd/ssl
$ etcdctl --write-out=table  --cacert=${CA}/etcd-ca.pem     --cert=${CA}/etcd.pem     --key=${CA}/etcd-key.pem --endpoints=100.67.151.2:2379 member list
+------------------+---------+-------+---------------------------+---------------------------+
|        ID        | STATUS  | NAME  |        PEER ADDRS         |       CLIENT ADDRS        |
+------------------+---------+-------+---------------------------+---------------------------+
| 23a97cc01374ffea | started | coco4 | https://100.67.151.4:2380 | https://100.67.151.4:2379 |
| 3ed68cceecd5de8a | started | coco5 | https://100.67.151.5:2380 | https://100.67.151.5:2379 |
| d119ba673571f775 | started | coco2 | https://100.67.151.2:2380 | https://100.67.151.2:2379 |
+------------------+---------+-------+---------------------------+---------------------------+

Add member

On coco6

$ export ETCDCTL_API=3
$ export CA=/etc/etcd/ssl
  1. copy keys
$ cd && wget -qO- "https://github.com/coreos/etcd/releases/download/v3.2.9/etcd-v3.2.9-linux-amd64.tar.gz" | tar -zx
$ mv etcd-v3.2.9-linux-amd64/etcd* /usr/local/bin/ && rm -rf etcd-v3.2.9-linux-amd64

On coco2

$ etcdctl --cacert=${CA}/etcd-ca.pem     --cert=${CA}/etcd.pem     --key=${CA}/etcd-key.pem --endpoints=100.67.151.2:2379,100.67.151.6:2379 member add coco6 --peer-urls=https://100.67.151.6:2380
$ etcdctl --write-out=table  --cacert=${CA}/etcd-ca.pem     --cert=${CA}/etcd.pem     --key=${CA}/etcd-key.pem --endpoints=100.67.151.2:2379 member list
+------------------+-----------+-------+---------------------------+---------------------------+
|        ID        |  STATUS   | NAME  |        PEER ADDRS         |       CLIENT ADDRS        |
+------------------+-----------+-------+---------------------------+---------------------------+
| 23a97cc01374ffea |   started | coco4 | https://100.67.151.4:2380 | https://100.67.151.4:2379 |
| 3ed68cceecd5de8a |   started | coco5 | https://100.67.151.5:2380 | https://100.67.151.5:2379 |
| 866f35d22bad070b | unstarted |       | https://100.67.151.6:2380 |                           |
| d119ba673571f775 |   started | coco2 | https://100.67.151.2:2380 | https://100.67.151.2:2379 |
+------------------+-----------+-------+---------------------------+---------------------------+

On coco6

$ etcd --trusted-ca-file=${CA}/etcd-ca.pem  --peer-trusted-ca-file=${CA}/etcd-ca.pem  --peer-cert-file=${CA}/etcd.pem  --cert-file=${CA}/etcd.pem  --key-file=${CA}/etcd-key.pem --peer-key-file=${CA}/etcd-key.pem --name coco6 --initial-advertise-peer-urls https://100.67.151.6:2380 --listen-peer-urls https://0.0.0.0:2380 --listen-client-urls https://0.0.0.0:2379 --advertise-client-urls https://100.67.151.6:2379 --initial-cluster coco2=https://100.67.151.2:2380,coco4=https://100.67.151.4:2380,coco5=https://100.67.151.5:2380,coco6=https://100.67.151.6:2380 --peer-client-cert-auth=true --client-cert-auth=true --initial-cluster-token etcd-k8s-cluster --initial-cluster-state existing

Remove member(coco6)

On coco2

$ etcdctl --write-out=table  --cacert=${CA}/etcd-ca.pem     --cert=${CA}/etcd.pem     --key=${CA}/etcd-key.pem --endpoints=100.67.151.2:2379 member list
+------------------+-----------+-------+---------------------------+---------------------------+
|        ID        |  STATUS   | NAME  |        PEER ADDRS         |       CLIENT ADDRS        |
+------------------+-----------+-------+---------------------------+---------------------------+
| 23a97cc01374ffea |   started | coco4 | https://100.67.151.4:2380 | https://100.67.151.4:2379 |
| 3ed68cceecd5de8a |   started | coco5 | https://100.67.151.5:2380 | https://100.67.151.5:2379 |
| 83123bf5c7646392 | unstarted |       | https://100.67.151.6:2380 |                           |
| d119ba673571f775 |   started | coco2 | https://100.67.151.2:2380 | https://100.67.151.2:2379 |
+------------------+-----------+-------+---------------------------+---------------------------+
$ etcdctl --cacert=${CA}/etcd-ca.pem     --cert=${CA}/etcd.pem     --key=${CA}/etcd-key.pem --endpoints=100.67.151.2:2379 member remove 83123bf5c7646392
$ etcdctl --write-out=table  --cacert=${CA}/etcd-ca.pem     --cert=${CA}/etcd.pem     --key=${CA}/etcd-key.pem --endpoints=100.67.151.2:2379 member list
+------------------+---------+-------+---------------------------+---------------------------+
|        ID        | STATUS  | NAME  |        PEER ADDRS         |       CLIENT ADDRS        |
+------------------+---------+-------+---------------------------+---------------------------+
| 23a97cc01374ffea | started | coco4 | https://100.67.151.4:2380 | https://100.67.151.4:2379 |
| 3ed68cceecd5de8a | started | coco5 | https://100.67.151.5:2380 | https://100.67.151.5:2379 |
| d119ba673571f775 | started | coco2 | https://100.67.151.2:2380 | https://100.67.151.2:2379 |
+------------------+---------+-------+---------------------------+---------------------------+

Add original member which was in config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment