加载中...
kubernetes1.23版 重置
发表于:2021-12-25 | 分类: kubernetes系列
字数统计: 4.1k | 阅读时长: 4 mins.分钟 | 阅读量:

kubernetes 重置

  • 为什么需要初始化

是因为flannel 网络插件需要在初始化的时候需要指定 –pod-network-cidr 10.244.0.0/167

如果不指定可以使用CrashLoopBackOff 这一种状态

kube-system   kube-flannel-ds-5tjjw                0/1     CrashLoopBackOff    69 (2m19s ago)   16h
kube-system   kube-flannel-ds-9lq64                0/1     CrashLoopBackOff    61 (2m45s ago)   16h
kube-system   kube-flannel-ds-mrhdn                0/1     CrashLoopBackOff    57 (2m14s ago)   16h

一、 重置master

## 移出node
kubectl drain k8s-node01 --delete-emptydir-data --force --ignore-daemonsets
kubectl drain k8s-node02 --delete-emptydir-data --force --ignore-daemonsets
##查看node 
kubectl get node -A
##重置master
kubeadm reset
##清除iptables规则
iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X

## 重新初始化kubernetes
kubeadm init --pod-network-cidr 10.244.0.0/16
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config
export KUBECONFIG=/etc/kubernetes/admin.conf

二、 重置node(所有node节点)

加入节点报错

[root@k8s-node01 ~]# kubeadm join 172.18.252.35:6443 --token mt5lr5.z6yr8vkcowsqazqf   --discovery-token-ca-cert-hash sha256:1c0dbef451646a3bebe880242d785a503e74f5644f0b789d81750b765208ea2f 
[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
	[ERROR FileAvailable--etc-kubernetes-kubelet.conf]: /etc/kubernetes/kubelet.conf already exists
	[ERROR FileAvailable--etc-kubernetes-bootstrap-kubelet.conf]: /etc/kubernetes/bootstrap-kubelet.conf already exists
	[ERROR Port-10250]: Port 10250 is in use
	[ERROR FileAvailable--etc-kubernetes-pki-ca.crt]: /etc/kubernetes/pki/ca.crt already exists
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher

需要重置node节点…执行以下的⬇️再次加入节点

[root@k8s-node01 ~]# kubeadm reset
[root@k8s-node01 ~]# kubeadm join 172.18.252.35:6443 --token mt5lr5.z6yr8vkcowsqazqf \
>   --discovery-token-ca-cert-hash sha256:1c0dbef451646a3bebe880242d785a503e74f5644f0b789d81750b765208ea2f 

三、查看是否加入

[root@k8s-master ~]# kubectl get nodes -A
NAME         STATUS   ROLES                  AGE   VERSION
k8s-master   Ready    control-plane,master   18h   v1.23.0
k8s-node01   Ready    <none>                 22m   v1.23.0
k8s-node02   Ready    <none>                 22m   v1.23.0
上一篇:
Linux发展历史
下一篇:
kubernetes构建efk日志系统
本文目录
本文目录