Molet

解决 Kubeadm 添加新 Master 节点到集群出现 ETCD 健康检查失败错误

Molet linux 2023-01-25 545浏览 0

一、问题描述
删除master节点后,重新将服务器加入到master集群,会一直卡在健康检查,内容如下:

$ [check-etcd] Checking that the etcd cluster is healthy

二、问题分析
其他正常master主机上,kubeadm-config中还存在之前删除的信息,所以无法重新加入

三、问题解决
1、首先获取集群中的 etcd pod 列表

$ kubectl get pods -n kube-system | grep etcd

2、进入 Etcd 容器并删除节点信息(任意一台正常的maseter)

kubectl exec -it etcd-k8s-master1 sh -n kube-system

3、容器内操作删除之前被删除的master信息

## 配置环境
$ 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'

## 查看 etcd 集群成员列表
$ etcdctl member list

63bfe05c4646fb08, started, k8s-master-2-11, https://192.168.2.11:2380, https://192.168.2.11:2379, false
8e41efd8164c6e3d, started, k8s-master-2-12, https://192.168.2.12:2380, https://192.168.2.12:2379, false
a61d0bd53c1cbcb6, started, k8s-master-2-13, https://192.168.2.13:2380, https://192.168.2.13:2379, false

## 删除 etcd 集群成员 k8s-master-2-11
$ etcdctl member remove 63bfe05c4646fb08

Member 63bfe05c4646fb08 removed from cluster ed984b9o8w35cap2

## 再次查看 etcd 集群成员列表
$ etcdctl member list

8e41efd8164c6e3d, started, k8s-master-2-12, https://192.168.2.12:2380, https://192.168.2.12:2379, false
a61d0bd53c1cbcb6, started, k8s-master-2-13, https://192.168.2.13:2380, https://192.168.2.13:2379, false

## 退出容器
$ exit

4、节点重新接入master

$kubeadm reset
$kubeadm join mydlq.club:16443 --token 6w0nwi.zag57qgfcdhi76vd --discovery-token-ca-cert-hash sha256:efa49231e4ffd836ff996921741c98ac4c5655dc729d7c32aa48c608232f0f08 --control-plane --certificate-key a64e9da7346153bd64dba1e5126a644a97fdb63c878bb73de07911d1add8e26b

继续浏览有关 LINUX技术 的文章
发表评论