TL;dr

example run etcd use docker

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
docker network create my-net

docker run -itd \
--name etcd1 \
--network my-net quay.io/coreos/etcd:v3.4.7 /usr/local/bin/etcd \
--name etcd1 \
--data-dir /var/lib/etcd/ \
--initial-advertise-peer-urls http://etcd1:2380 \
--listen-peer-urls http://0.0.0.0:2380 \
--listen-client-urls http://0.0.0.0:2379 \
--advertise-client-urls http://etcd1:2379 \
--initial-cluster-token etcd-cluster \
--initial-cluster etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380 \
--initial-cluster-state new


docker run -itd \
--name etcd2 \
--network my-net quay.io/coreos/etcd:v3.4.7 /usr/local/bin/etcd \
--name etcd2 \
--data-dir /var/lib/etcd/ \
--initial-advertise-peer-urls http://etcd2:2380 \
--listen-peer-urls http://0.0.0.0:2380 \
--listen-client-urls http://0.0.0.0:2379 \
--advertise-client-urls http://etcd2:2379 \
--initial-cluster-token etcd-cluster \
--initial-cluster etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380 \
--initial-cluster-state new

docker run -itd \
--name etcd3 \
--network my-net quay.io/coreos/etcd:v3.4.7 /usr/local/bin/etcd \
--name etcd3 \
--data-dir /var/lib/etcd/ \
--initial-advertise-peer-urls http://etcd3:2380 \
--listen-peer-urls http://0.0.0.0:2380 \
--listen-client-urls http://0.0.0.0:2379 \
--advertise-client-urls http://etcd3:2379 \
--initial-cluster-token etcd-cluster \
--initial-cluster etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380 \
--initial-cluster-state new


docker run -it \
--network my-net \
--rm quay.io/coreos/etcd:v3.4.7 /usr/local/bin/etcdctl \
endpoint health --endpoints "http://etcd1:2379,http://etcd2:2379,http://etcd3:2379"



docker run -d \
--network my-net \
--name etcdv3-browser -p 8081:8081  \
-e ETCD=etcd1:2379 rustyx/etcdv3-browser:v0.5.0


ETCDCTL_API=3 etcdctl --endpoints "etcd1:2379,etcd2:2379,etcd3:2379" member list -w table

ETCDCTL_API=3 etcdctl --endpoints "etcd1:2379,etcd2:2379,etcd3:2379" endpoint status -w table

ETCDCTL_API=3 etcdctl --endpoints "etcd1:2379,etcd2:2379,etcd3:2379" get a --print-value-only

docker ps |grep etcd
docker logs etcd1
docker logs etcd2
docker logs etcd3
docker logs etcd-browser


etcdctl --endpoints "https://192.168.33.11:2379" \
--cacert=/etc/etcd/etcd-ca.pem \
--cert=/etc/etcd/etcd-client.pem \
--key=/etc/etcd/etcd-client-key.pem \
--prefix \
--keys-only=true \
get /



etcdctl --endpoints "https://192.168.33.11:2379" \
--cacert=/etc/etcd/etcd-ca.pem \
--cert=/etc/etcd/etcd-client.pem \
--key=/etc/etcd/etcd-client-key.pem \
--prefix \
--print-value-only \
get /registry/apiregistration.k8s.io/apiservices/v1.apps |jq

ref