前提是要有备份,需要备份的文件如下
一、备份
1.1 etcd(所有节点)
查看etcd信息登录master的节点
cat /etc/kubernetes/manifests/kube-apiserver.json |grep etcd
etcd v2备份
注意:所有节点都要备份(5个节点备份5个)
systemctl stop etcd
tar zvcf etcd-data-hostname
.tar.gz /var/lib/etcd
1.2 kubernetes配置(备份kubernetes所有节点)
需要备份master和node的信息
systemctl stop docker && systemctl stop kubelet
tar zcvf kubernetes-conf-hostname
.tar.gz /etc/kubernetes /etc/cni /etc/systemd/system/kubelet.service.d/ /lib/systemd/system/kubelet.service /var/lib/kubelet
二、恢复
1.恢复etcd集群(所有节点)
systemctl stop etcd
rm -f /var/lib/etcd
tar xf etcd-data* -C /
systemctl start etcd
2.恢复kubernets集群(所有节点)
systemctl stop docker && systemctl stop kubelet
systemctl start docker
kubeadm reset
rm -rf etc/kubernetes/ /var/lib/kubelet/ /etc/systemd/system/kubelet.service.d
tar xf kubernetes-conf-hostname
.tar.gz -C /
#先启动master节点,在启动其它节点
systemctl restart docker && systemctl restart kubelet
原文地址:https://blog.51cto.com/3138583/2381557