K8s踢出node

K8s踢出node

这个其实也是cka的题目之一,正好我这边也做要踢出一个节点

admin@k8s-01:~$ sudo kubectl get nodes
NAME     STATUS   ROLES                  AGE   VERSION
k8s-01   Ready    control-plane,master   15h   v1.22.3
k8s-02   Ready    control-plane,master   15h   v1.22.3
k8s-03   Ready    <none>                 14h   v1.22.3
k8s-04   Ready    <none>                 15h   v1.22.3
k8s-05   Ready    <none>                 98s   v1.22.3
admin@k8s-01:~$

设置节点不可调度,在驱逐删除那个节点

admin@k8s-01:~$ sudo kubectl cordon k8s-05
node/k8s-05 cordoned
admin@k8s-01:~$ sudo kubectl drain k8s-05 --ignore-daemonsets --force
node/k8s-05 already cordoned
WARNING: ignoring DaemonSet-managed Pods: kube-system/calico-node-zmcj5, kube-system/kube-proxy-wckb4
node/k8s-05 drained
admin@k8s-01:~$sudo kubectl delete node k8s-05

获取一个node集合

admin@k8s-01:~$ sudo kubectl get nodes
NAME     STATUS   ROLES                  AGE   VERSION
k8s-01   Ready    control-plane,master   16h   v1.22.3
k8s-02   Ready    control-plane,master   15h   v1.22.3
k8s-03   Ready    <none>                 15h   v1.22.3
k8s-04   Ready    <none>                 15h   v1.22.3
admin@k8s-01:~$
posted @ 2022-04-28 10:59  天宇轩-王  阅读(180)  评论(0编辑  收藏  举报