参考:
- https://www.cnblogs.com/shunzi115/p/14776507.html
kubeadm reset 重置
操作方法
1.Master 节点和Work节点都需要执行:kubeadm reset
[root@k8s-master ~]# kubeadm reset
[reset] Reading configuration from the cluster...
[reset] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
[reset] WARNING: Changes made to this host by 'kubeadm init' or 'kubeadm join' will be reverted.
[reset] Are you sure you want to proceed? [y/N]:
注意:
kubeadm reset 执行后不会删除$HOME/.kube文件,执行rm -rf $HOME/.kube
子节点 ->
systemctl daemon-reload && systemctl restart kubelet
2.重新初始化K8S集群
Master 节点执行:
# kubeadm init
--apiserver-advertise-address=9.110.187.120
--image-repository registry.aliyuncs.com/google_containers
--kubernetes-version v1.19.0
--service-cidr=10.1.0.0/16
--pod-network-cidr=10.244.0.0/16
安装Pod网络插件(CNI)
# kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
配置使用kubectl工具,kubeadm init 结束会打印需要执行的操作,复制粘贴即可。
# mkdir -p $HOME/.kube
# sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
# sudo chown $(id -u):$(id -g) $HOME/.kube/config
# kubectl get nodes
Work节点加入K8S集群,kubeadm init 结束会打印需要执行的操作,复制粘贴即可。
# kubeadm join 9.110.187.120:6443 --token esce21.q6hetwm8si29qxwn
--discovery-token-ca-cert-hash sha256:00603a05805807501d7181c3d60b478788408cfe6cedefedb1f97569708be9c5
如果忘记kubeadm join 可以通过如下命令获取join命令参数:
# kubeadm token create --print-join-command