[root@k8s1 ~]# kubectl cordon k8s3
node/k8s3 cordoned
[root@k8s1 ~]# kubectl drain k8s3 --delete-local-data --ignore-daemonsets --force
node/k8s3 already cordoned
WARNING: ignoring DaemonSet-managed Pods: kube-system/kube-flannel-ds-2jc4w, kube-system/kube-proxy-dfqbv
evicting pod default/nginx-deployment-585449566-wxk2m
evicting pod default/nginx-deployment-585449566-645hr
evicting pod default/nginx-deployment-585449566-7psml
pod/nginx-deployment-585449566-645hr evicted
pod/nginx-deployment-585449566-wxk2m evicted
pod/nginx-deployment-585449566-7psml evicted
node/k8s3 evicted
查看 驱散成功:
[root@k8s1 ~]# kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx-deployment-585449566-2pzjm 1/1 Running 0 2m48s 10.244.1.145 k8s2 <none> <none>
nginx-deployment-585449566-dp7xg 1/1 Running 0 2m48s 10.244.1.144 k8s2 <none> <none>
nginx-deployment-585449566-fwvn4 0/1 ImagePullBackOff 0 2m48s 10.244.1.143 k8s2 <none> <none>