k8s etcd集群维护
1、集群etcd节点故障恢复
注意事项:
下属操作顺序不能乱,配置文件注意格式,操作前备份
删除故障节点
alias ectl='etcdctl --endpoints=https://10.88.112.42:2379,https://10.88.112.208:2379,https://10.88.112.22 6:2379 --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/server.crt --key=/etc/ku bernetes/pki/etcd/server.key' ectl member list -w table #查询集群信息,后去故障节点ID
ectl member remove 故障节点集群ID
停止ectd节点上kubelet
systemctl stop kubelet
删除故障etcd节点数据
cp /var/lib/etcd /var/lib/etcd-bak rm -rf /var/lib/etcd/*
更新配置
注意配置文件格式,不要出现空格,断行否则pod会无法启动
vi /etc/kubernetes/manifests/etcd.yaml - --initial-cluster-state=existing # 这里必须是existing而不是new,kubeadm初始化搭建集群的时候,第一个mater节点是new,注意更改
#配置集群所有节点地址,而不是只有本节点地址 - --initial-cluster=tst-k8s-adse-zj-master-03=https://10.26.88.42:2380,tst-k8s-adse-zj-master-01=https://10.26.88.226:2380,tst-k8s-adse-zj-master-02=https://10.26.88.208:2380
添加etcd节点
ectl member add tst-k8s-adse-zj-master-03 --peer-urls=https://10.26.88.42:2380
ectl endpoint status --cluster -w table #查看集群状态,节点信息
启动故障节点kubelet
systemctl start kubelet