1、下线之前,先在master01节点上创建一个测试Deployment
[root@master01 ~]# kubectl create deployment testdp2 --image=registry.cn-hangzhou.aliyuncs.com/zq-demo/nginx:1.14.2 --replicas=7
查看pod
[root@master01 ~]# kubectl get po -owide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
testdp2-6d9fbdb8cb-5bbrf 1/1 Running 0 32s 172.29.55.6 node01 <none> <none>
testdp2-6d9fbdb8cb-8bsc9 1/1 Running 0 32s 172.19.75.194 node03 <none> <none>
testdp2-6d9fbdb8cb-bx67h 1/1 Running 0 32s 172.21.231.134 node02 <none> <none>
testdp2-6d9fbdb8cb-clkdl 1/1 Running 0 32s 172.18.71.1 master03 <none> <none>
testdp2-6d9fbdb8cb-f8dbw 1/1 Running 0 32s 172.19.75.193 node03 <none> <none>
testdp2-6d9fbdb8cb-q9hf7 1/1 Running 0 32s 172.20.59.197 master02 <none> <none>
testdp2-6d9fbdb8cb-xc9hp 1/1 Running 0 32s 172.31.112.131 master01 <none> <none>
2、在master01节点上驱逐下线节点node03上的Pod,并设置不可调度
[root@master01 ~]# kubectl drain node03 --ignore-daemonsets
再次查看Pod,观察到node03节点上无Pod运行
[root@master01 ~]# kubectl get po -owide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
testdp2-6d9fbdb8cb-5bbrf 1/1 Running 0 3m20s 172.29.55.6 node01 <none> <none>
testdp2-6d9fbdb8cb-6pgv7 1/1 Running 0 4s 172.21.231.135 node02 <none> <none>
testdp2-6d9fbdb8cb-9wzdx 1/1 Running 0 4s 172.29.55.7 node01 <none> <none>
testdp2-6d9fbdb8cb-bx67h 1/1 Running 0 3m20s 172.21.231.134 node02 <none> <none>
testdp2-6d9fbdb8cb-clkdl 1/1 Running 0 3m20s 172.18.71.1 master03 <none> <none>
testdp2-6d9fbdb8cb-q9hf7 1/1 Running 0 3m20s 172.20.59.197 master02 <none> <none>
testdp2-6d9fbdb8cb-xc9hp 1/1 Running 0 3m20s 172.31.112.131 master01 <none> <none>
3、在master01节点上恢复node03节点可调度
[root@master01 ~]# kubectl uncordon node03
4、在master01节点上移除node03节点
[root@master01 ~]# kubectl delete node node03
验证查看
[root@master01 ~]# kubectl get node
NAME STATUS ROLES AGE VERSION
master01 Ready control-plane 18h v1.26.9
master02 Ready control-plane 18h v1.26.9
master03 Ready control-plane 18h v1.26.9
node01 Ready <none> 18h v1.26.9
node02 Ready <none> 18h v1.26.9