kubernetes Pod驱逐迁移drain用法

example

设置node不可调度

$kubectl cordon 172.16.21.26

$ kubectl drain foo --force

$ kubectl drain foo --grace-period=900

$ kubectl drain 172.16.21.26 --delete-local-data --ignore-daemonsets --force

参数说明:

–delete-local-data: 即使pod使用了emptyDir也删除
–ignore-daemonsets: 忽略deamonset控制器的pod,如果不忽略,deamonset控制器控制的pod被删除后可能马上又在此节点上启动起来,会成为死循环;
–force: 不加force参数只会删除该NODE上由ReplicationController, ReplicaSet, DaemonSet,StatefulSet or Job创建的Pod,加了后还会删除’裸奔的pod’(没有绑定到任何replication controller)
--pod-selector="" Label selector to filter pods on the node;按标签过滤掉不驱逐得pod
-l, --selector="" Selector (label query) to filter on
--skip-wait-for-delete-timeout=0 If pod DeletionTimestamp older than N seconds, skip waiting for the pod.  Seconds must be greater than 0 to skip.
--timeout=0s The length of time to wait before giving up, zero means infinite

观察pod重建情况后,对节点进行维护操作。
维护结束后对节点重新配置可以调度。

kubectl uncordon 172.16.21.26
posted @ 2021-03-02 16:48  ainimore  阅读(1722)  评论(1编辑  收藏  举报