k8s 删除 node节点
查看现有状态
1 2 3 4 5 | [root@master ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION master NotReady control-plane 72s v1.25.0 node1 NotReady <none> 11s v1.25.0 node2 NotReady <none> 7s v1.25.0 |
一、驱逐节点
1 2 3 4 5 6 7 | [root@master ~]# kubectl cordon node1 node/node1 cordoned [root@master ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION master NotReady control-plane 7m4s v1.25.0 node1 NotReady,SchedulingDisabled <none> 6m3s v1.25.0 node2 NotReady <none> 5m59s v1.25.0 |
二、删除该节点
1 2 3 4 5 6 | [root@master ~]# kubectl delete node node1 node "node1" deleted [root@master ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION master NotReady control-plane 7m13s v1.25.0 node2 NotReady <none> 6m8s v1.25.0 |
三、若需要重新部署该节点
- 在该节点上执行kubeadm reset
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | [root@node1 ~]# kubeadm reset W1123 18:03:42.930664 15464 preflight.go:55] [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 W1123 18:03:45.173129 15464 removeetcdmember.go:85] [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 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] 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. |
四、设置节点为不可调度
1 | [root@master ~]# kubectl drain 【节点名】 --ignore-daemonsets |
分类:
Kubernetes
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 上周热点回顾(3.3-3.9)
· AI 智能体引爆开源社区「GitHub 热点速览」