docker

关注公众号 jb51net

关闭
首页 > 网站技巧 > 服务器 > 云和虚拟化 > docker > K8s集群重启与恢复-Node节点启停

K8s集群重启与恢复-Node节点启停方式

作者:临江仙我亦是行人

这篇文章主要介绍了K8s集群重启与恢复-Node节点启停方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教

1 应用场景

场景

注意

2 操作步骤

2.1 停止 Worker 节点调度

# 查看信息
root@sh-gpu091:~# kubectl get node
NAME                 STATUS     ROLES   AGE    VERSION
172.19.13.31         Ready      node    403d   v1.14.1
sh-cpu032.aibee.cn   Ready      node    403d   v1.14.1
sh-cpu033.aibee.cn   Ready      node    403d   v1.14.1
sh-gpu091.aibee.cn   Ready      node    403d   v1.14.1
sh-gpu101.aibee.cn   Ready      node    403d   v1.14.1
# 停止 Worker 节点调度
root@sh-gpu091:~# kubectl cordon sh-gpu101.aibee.cn
node/sh-gpu101.aibee.cn cordoned
root@sh-gpu091:~# kubectl get node
NAME                 STATUS                     ROLES   AGE    VERSION
172.19.13.31         Ready                      node    403d   v1.14.1
sh-cpu032.aibee.cn   Ready                      node    403d   v1.14.1
sh-cpu033.aibee.cn   Ready                      node    403d   v1.14.1
sh-gpu091.aibee.cn   Ready                      node    403d   v1.14.1
sh-gpu101.aibee.cn   Ready,SchedulingDisabled   node    403d   v1.14.1

2.2 驱逐 Worker 节点上的工作负载

# --ignore-daemonsets 驱逐 pod 时忽略 daemonset
# --delete-local-data 驱逐 pod 时删除 pod 的临时数据,该参数不会删除持久化数据
root@sh-gpu091:~# kubectl drain sh-gpu101.aibee.cn --delete-local-data --ignore-daemonsets --force
node/sh-gpu101.aibee.cn already cordoned
WARNING: ignoring DaemonSet-managed Pods: cattle-system/cattle-node-agent-8wcvs, kube-system/kube-flannel-ds-kqzhc, kube-system/nvidia-device-plugin-daemonset-rr2lf, monitoring/prometheus-node-exporter-xtbxp
evicting pod "model-server-0"
evicting pod "singleview-proxy-client-pbdownloader-0"
evicting pod "singleview-proxy-service-0"
pod/singleview-proxy-client-pbdownloader-0 evicted
pod/singleview-proxy-service-0 evicted
pod/model-server-0 evicted
node/sh-gpu101.aibee.cn evicted

2.3 停止 Docker、Kubelet 等服务

systemctl stop kubelet 
systemctl stop docker
kubectl get pod -A -o wide |grep sh-gpu101.aibee.cn
root@sh-gpu091:~# kubectl delete node sh-gpu101.aibee.cn
node "sh-gpu101.aibee.cn" deleted
root@sh-gpu091:~# kubectl get node
NAME                 STATUS     ROLES   AGE    VERSION
172.19.13.31         Ready      node    403d   v1.14.1
sh-cpu032.aibee.cn   Ready      node    403d   v1.14.1
sh-cpu033.aibee.cn   Ready      node    403d   v1.14.1
sh-gpu091.aibee.cn   Ready      node    403d   v1.14.1
root@sh-gpu091:~#

2.4 恢复 Worker 节点

systemctl start docker
systemctl status docker
systemctl start kubelet
systemctl status kubelet

2.5 允许 Worker 节点调度

# 取消不可调度
kubectl uncordon sh-gpu101.aibee.cn

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:
阅读全文