外包技能--k8s增加node操作

2023-10-17 14:02:27 浏览数 (1)

node状态

代码语言:javascript复制
[root@kmaster install-k8s]# kubectl get node -o wide
NAME      STATUS     ROLES                  AGE    VERSION   INTERNAL-IP     EXTERNAL-IP   OS-IMAGE        KERNEL-VERSION               CONTAINER-RUNTIME
kmaster   Ready      control-plane,master   101d   v1.21.0   192.168.31.10   <none>        Rocky Linux 8   4.18.0-240.22.1.el8.x86_64   docker://20.10.6
knode01   NotReady   <none>                 101d   v1.21.0   192.168.31.11   <none>        Rocky Linux 8   4.18.0-240.22.1.el8.x86_64   docker://20.10.6
knode02   NotReady   <none>                 101d   v1.21.0   192.168.31.12   <none>        Rocky Linux 8   4.18.0-240.22.1.el8.x86_64   docker://20.10.6
[root@kmaster install-k8s]# 

删除node

此操作在master节点上进行

代码语言:javascript复制
 [root@kmaster install-k8s]# kubectl delete node knode02
node "knode02" deleted
[root@kmaster install-k8s]# 

方法一

获取master的join token

代码语言:javascript复制
[root@kmaster install-k8s]# kubeadm token create --print-join-command
kubeadm join 192.168.31.10:6443 --token pm9leu.t0bewk26hqy8i0no --discovery-token-ca-cert-hash sha256:7ed828dca7f359279bfa12940dd2cb05f498a4543c01c5ef2d77e9563aecc512 
[root@kmaster install-k8s]# 

方法二

重置node节点

代码语言:javascript复制
[root@knode02 ~]# kubeadm reset
[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]: y
[preflight] Running pre-flight checks
W0820 22:57:08.552896    1651 removeetcdmember.go:79] [reset] No kubeadm config, using etcd pod spec to get data directory
[reset] No etcd config found. Assuming external etcd
[reset] Please, manually reset etcd to prevent further issues
[reset] Stopping the kubelet service
[reset] Unmounting mounted directories in "/var/lib/kubelet"
[reset] Deleting contents of config directories: [/etc/kubernetes/manifests /etc/kubernetes/pki]
[reset] Deleting files: [/etc/kubernetes/admin.conf /etc/kubernetes/kubelet.conf /etc/kubernetes/bootstrap-kubelet.conf /etc/kubernetes/controller-manager.conf /etc/kubernetes/scheduler.conf]
[reset] Deleting contents of stateful directories: [/var/lib/kubelet /var/lib/dockershim /var/run/kubernetes /var/lib/cni]
​
The reset process does not clean CNI configuration. To do so, you must remove /etc/cni/net.d
​
The reset process does not reset or clean up iptables rules or IPVS tables.
If you wish to reset iptables, you must do so manually by using the "iptables" command.
​
If your cluster was setup to utilize IPVS, run ipvsadm --clear (or similar)
to reset your system's IPVS tables.
​
The reset process does not clean your kubeconfig files and you must remove them manually.
Please, check the contents of the $HOME/.kube/config file.
[root@knode02 ~]# 

0 人点赞