docker运行etcd集群

基本配置

准备为k3s配置etcd存储,以docker的形式,运行一套etcd集群,作为存储后端

机器1

etcd.env

ALLOW_NONE_AUTHENTICATION=yes
ETCD_NAME=etcd0
ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380
ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379
ETCD_ADVERTISE_CLIENT_URLS=http://10.1.30.153:2379
ETCD_INITIAL_ADVERTISE_PEER_URLS=http://10.1.30.153:2380
ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster
ETCD_INITIAL_CLUSTER=etcd0=http://10.1.30.153:2380,etcd1=http://10.1.30.154:2380,etcd2=http://10.1.30.155:2380
ETCD_INITIAL_CLUSTER_STATE=new

docker命令

docker run -d --env-file=./etcd.env --net=host -v /opt/etcd:/var/lib/etcd:rw --memory=512M --blkio-weight=1000 --name=etcd1 bitnami/etcd:3.4.15

机器2

etcd.env

ALLOW_NONE_AUTHENTICATION=yes
ETCD_NAME=etcd0
ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380
ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379
ETCD_ADVERTISE_CLIENT_URLS=http://10.1.30.154:2379
ETCD_INITIAL_ADVERTISE_PEER_URLS=http://10.1.30.154:2380
ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster
ETCD_INITIAL_CLUSTER=etcd0=http://10.1.30.153:2380,etcd1=http://10.1.30.154:2380,etcd2=http://10.1.30.155:2380
ETCD_INITIAL_CLUSTER_STATE=new

docker命令

docker run -d --env-file=./etcd.env --net=host -v /opt/etcd:/var/lib/etcd:rw --memory=512M --blkio-weight=1000 --name=etcd2 bitnami/etcd:3.4.15

机器3

etcd.env

ALLOW_NONE_AUTHENTICATION=yes
ETCD_NAME=etcd0
ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380
ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379
ETCD_ADVERTISE_CLIENT_URLS=http://10.1.30.155:2379
ETCD_INITIAL_ADVERTISE_PEER_URLS=http://10.1.30.155:2380
ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster
ETCD_INITIAL_CLUSTER=etcd0=http://10.1.30.153:2380,etcd1=http://10.1.30.154:2380,etcd2=http://10.1.30.155:2380
ETCD_INITIAL_CLUSTER_STATE=new

docker命令

docker run -d --env-file=./etcd.env --net=host -v /opt/etcd:/var/lib/etcd:rw --memory=512M --blkio-weight=1000 --name=etcd3 bitnami/etcd:3.4.15

验证

[root@master1 ~]# export ETCDCTL_API=3
[root@master1 ~]# /usr/local/bin/etcdctl member list
34b43803c331e98a, started, etcd0, http://10.1.30.153:2380, http://10.1.30.153:2379
556065e9d9efb641, started, etcd1, http://10.1.30.154:2380, http://10.1.30.154:2379
87c349e4d04e94ad, started, etcd2, http://10.1.30.155:2380, http://10.1.30.155:2379

TODO

cfssl生成证书,配置https访问etcd

你可能感兴趣的:(docker运行etcd集群)