


























作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
[root@master231 ~]# kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
master231 Ready control-plane 15h v1.33.10 10.0.0.231 <none> Ubuntu 24.04.4 LTS 6.8.0-117-generic containerd://2.1.6
master232 Ready control-plane 15h v1.33.10 10.0.0.232 <none> Ubuntu 24.04.4 LTS 6.8.0-117-generic containerd://2.1.6
master233 Ready control-plane 15h v1.33.10 10.0.0.233 <none> Ubuntu 24.04.4 LTS 6.8.0-117-generic containerd://2.1.6
worker66 Ready <none> 15h v1.33.10 10.0.0.66 <none> Ubuntu 24.04.4 LTS 6.8.0-117-generic containerd://2.1.6
worker77 Ready <none> 15h v1.33.10 10.0.0.77 <none> Ubuntu 24.04.4 LTS 6.8.0-117-generic containerd://2.1.6
[root@master231 ~]#
1.驱逐要下线的worker节点
[root@master231 ~]# kubectl drain worker66 --ignore-daemonsets --delete-emptydir-data
node/worker66 cordoned
Warning: ignoring DaemonSet-managed Pods: kube-system/calico-node-wdrkf, kube-system/kube-proxy-2b7xl, kube-system/nodelocaldns-7w8ns
evicting pod kube-system/coredns-594cbfb5fd-9gdmp
pod/coredns-594cbfb5fd-9gdmp evicted
node/worker66 drained
[root@master231 ~]#
[root@master231 ~]#
[root@master231 ~]# kubectl drain worker77 --ignore-daemonsets --delete-emptydir-data
node/worker77 cordoned
Warning: ignoring DaemonSet-managed Pods: kube-system/calico-node-67lgs, kube-system/kube-proxy-wl2ht, kube-system/nodelocaldns-jxq2d
evicting pod kube-system/dns-autoscaler-8558dbc749-28z2g
evicting pod kube-system/calico-kube-controllers-6b48c55b44-b5wr7
evicting pod kube-system/coredns-594cbfb5fd-klpr9
pod/dns-autoscaler-8558dbc749-28z2g evicted
pod/calico-kube-controllers-6b48c55b44-b5wr7 evicted
pod/coredns-594cbfb5fd-klpr9 evicted
node/worker77 drained
[root@master231 ~]#
2.再次查看节点列表
[root@master231 ~]# kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
master231 Ready control-plane 16h v1.33.10 10.0.0.231 <none> Ubuntu 24.04.4 LTS 6.8.0-117-generic containerd://2.1.6
master232 Ready control-plane 16h v1.33.10 10.0.0.232 <none> Ubuntu 24.04.4 LTS 6.8.0-117-generic containerd://2.1.6
master233 Ready control-plane 16h v1.33.10 10.0.0.233 <none> Ubuntu 24.04.4 LTS 6.8.0-117-generic containerd://2.1.6
worker66 Ready,SchedulingDisabled <none> 16h v1.33.10 10.0.0.66 <none> Ubuntu 24.04.4 LTS 6.8.0-117-generic containerd://2.1.6
worker77 Ready,SchedulingDisabled <none> 16h v1.33.10 10.0.0.77 <none> Ubuntu 24.04.4 LTS 6.8.0-117-generic containerd://2.1.6
[root@master231 ~]#
[root@master231 ~]#
参考链接:
https://kubespray.io/#/docs/getting_started/getting-started?id=remove-nodes
1.删除指定的多个节点
(venv) [root@ansible99 kubespray]# ansible-playbook -i inventory/yinzhengjie-k8s/inventory.ini remove-node.yml -b -v --extra-vars "node=worker66,worker77"
2.查看删除后的效果【删除过程比较耗时间,删除过程中并没有出现停机的情况】
[root@master232 ~]# kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
master231 Ready control-plane 18h v1.33.10 10.0.0.231 <none> Ubuntu 24.04.4 LTS 6.8.0-117-generic containerd://2.1.6
master232 Ready control-plane 18h v1.33.10 10.0.0.232 <none> Ubuntu 24.04.4 LTS 6.8.0-117-generic containerd://2.1.6
master233 Ready control-plane 18h v1.33.10 10.0.0.233 <none> Ubuntu 24.04.4 LTS 6.8.0-117-generic containerd://2.1.6
[root@master232 ~]#
参考链接:
https://kubespray.io/#/docs/getting_started/getting-started?id=adding-nodes
(venv) [root@ansible99 kubespray]# ansible-playbook -i inventory/yinzhengjie-k8s/inventory.ini scale.yml -b -v --extra-vars "node=worker66,worker77"
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。