etcd 添加节点
由于master2 节点重新克隆了,造成etcd异常, 恢复过程
1. 从etcd集群中删除 master2 etcd
# 登录集群的任意 ETCD Pod kubectl exec -it etcd-master sh -n kube-system # Pod 中设置登录 ETCD 的命令 export ETCDCTL_API=3 alias etcdctl='etcdctl --endpoints=https://127.0.0.1:2379 --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/server.crt --key=/etc/kubernetes/pki/etcd/server.key' # 查看集群节点列表 etcdctl member list # 删除etcd2节点 etcdctl member remove 58372e8d4ff228e
2. master2 etcd 操作
1. 删除etcd 静态pod cd /etc/kubernetes mv manifests/etcd.yaml ./ 2. 观察etcd pod 是否删除 crictl ps -a | grep etcd 3. 删除/var/lib/etcd/ 目录中数据(最好备份) rm /var/lib/etcd/* -rf
4. 修改配置etcd.yaml 文件,添加 --initial-cluster-state=existing
3. 在etcd1 节点添加 etcd2 节点
# 查看集群节点列表 etcdctl member add # 添加etcd2节点 etcdctl member remove master2 http://1.1.1.1.2:2380
4. 恢复master2 etcd 配置文件
1. copy文件 cd /etc/kubernetes mv etcd.yaml ./manifests/
5. 查看etcd 状态