Thank you for reading this post, don't forget to subscribe!
cat 1.yaml
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 |
version: '3.4' services: etcd-00: image: quay.io/coreos/etcd:v3.2.17 hostname: etcd-00 command: - etcd - --name=etcd-00 - --data-dir=data.etcd - --advertise-client-urls=http://etcd-00:2379 - --listen-client-urls=http://0.0.0.0:2379 - --initial-advertise-peer-urls=http://etcd-00:2380 - --listen-peer-urls=http://0.0.0.0:2380 - --initial-cluster=etcd-00=http://etcd-00:2380,etcd-01=http://etcd-01:2380,etcd-02=http://etcd-02:2380,etcd-03=http://etcd-03:2380,etcd-04=http://etcd-04:2380 - --initial-cluster-state=new - --initial-cluster-token=${ETCD_TOKEN} volumes: - etcd-00vol:/data.etcd networks: - etcd ports: - 2379:2379 deploy: replicas: 1 etcd-01: image: quay.io/coreos/etcd:v3.2.17 hostname: etcd-01 command: - etcd - --name=etcd-01 - --data-dir=data.etcd - --advertise-client-urls=http://etcd-01:2379 - --listen-client-urls=http://0.0.0.0:2379 - --initial-advertise-peer-urls=http://etcd-01:2380 - --listen-peer-urls=http://0.0.0.0:2380 - --initial-cluster=etcd-00=http://etcd-00:2380,etcd-01=http://etcd-01:2380,etcd-02=http://etcd-02:2380,etcd-03=http://etcd-03:2380,etcd-04=http://etcd-04:2380 - --initial-cluster-state=new - --initial-cluster-token=${ETCD_TOKEN} volumes: - etcd-01vol:/data.etcd networks: - etcd deploy: replicas: 1 etcd-02: image: quay.io/coreos/etcd:v3.2.17 hostname: etcd-02 command: - etcd - --name=etcd-02 - --data-dir=data.etcd - --advertise-client-urls=http://etcd-02:2379 - --listen-client-urls=http://0.0.0.0:2379 - --initial-advertise-peer-urls=http://etcd-02:2380 - --listen-peer-urls=http://0.0.0.0:2380 - --initial-cluster=etcd-00=http://etcd-00:2380,etcd-01=http://etcd-01:2380,etcd-02=http://etcd-02:2380,etcd-03=http://etcd-03:2380,etcd-04=http://etcd-04:2380 - --initial-cluster-state=new - --initial-cluster-token=${ETCD_TOKEN} volumes: - etcd-02vol:/data.etcd networks: - etcd deploy: replicas: 1 volumes: etcd-00vol: driver: local etcd-01vol: driver: local etcd-02vol: driver: local networks: etcd: driver: overlay driver_opts: encrypted: "true" internal: true |
docker stack deploy -c 1.yaml etcd
1 2 3 4 5 |
docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION chk7zhfhf7sbvvbtjh21wh7nu * cluster-nfs1 Ready Active Leader 20.10.7 xuje5tlplu1bbok89dla9ack1 cluster-nfs2 Ready Active 20.10.7 |
1 2 3 4 5 |
docker exec -it etcd_etcd-01.1.16a13rhhmzb09x2hzl5hqzds2 etcdctl member list 1c2164feaff355dc: name=etcd-02 peerURLs=http://etcd-02:2380 clientURLs=http://etcd-02:2379 isLeader=false 70f71ecf7dfb681a: name=etcd-01 peerURLs=http://etcd-01:2380 clientURLs=http://etcd-01:2379 isLeader=false f05ec268fbc96c37: name=etcd-00 peerURLs=http://etcd-00:2380 clientURLs=http://etcd-00:2379 isLeader=true |