Kubernetes节点调度与驱逐

Kubernetes节点调度与驱逐

1. 迁移Pod

1.1. 设置节点是否可调度

确定需要迁移和被迁移的节点,将不允许被迁移的节点设置为不可调度。

1
2
3
4
5
6
7
8
# 查看节点
kubectl get nodes

# 设置节点为不可调度
kubectl cordon <NodeName>

# 设置节点为可调度
kubectl uncordon <NodeName>

1.2. 执行kubectl drain命令

1
kubectl drain <NodeName> --force --ignore-daemonsets

示例:

1
2
3
4
5
6
$ kubectl drain bjzw-prek8sredis-99-40 --force --ignore-daemonsets
node "bjzw-prek8sredis-99-40" already cordoned
WARNING: Deleting pods not managed by ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet: kube-proxy-bjzw-prek8sredis-99-40; Ignoring DaemonSet-managed pods: calicoopsmonitor-mfpqs, arachnia-agent-j56n8
pod "pre-test-pro2-r-0-redis-2-8-19-1" evicted
pod "pre-test-hwh1-r-8-redis-2-8-19-2" evicted
pod "pre-eos-hdfs-vector-eos-hdfs-redis-2-8-19-0" evicted