K8S节点下线

设置节点不可调度:
kubectl cordon node1

驱逐节点上的pod:
kubectl drain node1  --ignore-daemonsets  --delete-local-data

--ignore-daemonsets 如果node节点上存在daemonsets控制器创建的pod,则需要使用--ignore-daemonsets忽略错误错误警告
--delete-local-data 如果有数据挂载。需要使用此选项。否则删除失败

删除节点:
kubectl delete node node1 

设置节点可调度:
kubectl uncordon k8s-node2

案例:
[root@woker-cn-hangzhou-172-18-0-106 ~]#kubectl cordon cn-hangzhou.172.16.2.27
[root@woker-cn-hangzhou-172-18-0-106 ~]# kubectl drain cn-hangzhou.172.16.2.27  --ignore-daemonsets --delete-local-data
node/cn-hangzhou.172.16.2.27 already cordoned
WARNING: ignoring DaemonSet-managed Pods: kruise-system/kruise-daemon-xnnb8, kube-system/ack-node-problem-detector-daemonset-cgx9n, kube-system/flexvolume-vjbkf, kube-system/kube-flannel-ds-fw7pw, kube-system/kube-proxy-worker-slbrh, kube-system/log-pilot-w8v9z, kube-system/node-resource-agent-ghpz5, kube-system/resource-controller-cpwgg, monitoring/ack-prometheus-operator-prometheus-node-exporter-rqtsw
evicting pod "flyby-web-proxy-765d8bdc95-7grz4"
evicting pod "nginx-ingress-controller-6bf9868cd5-vf626"
pod/flyby-web-proxy-765d8bdc95-7grz4 evicted
pod/nginx-ingress-controller-6bf9868cd5-vf626 evicted
node/cn-hangzhou.172.16.2.27 evicted
[root@woker-cn-hangzhou-172-18-0-106 ~]#kubectl delete no cn-hangzhou.172.16.2.27
posted @ 2023-06-12 10:56  安生丶  阅读(33)  评论(0编辑  收藏  举报