kubernetes:驱逐node上所有pod

背景:
有时候我们要对一个node节点进行维修,升级,需要重启开关机,那怎么才能做到应用不影响呢?
技术:
我们可以使用 命令操作

kubectl drain <node name>

官方文档:
https://kubernetes.io/docs/tasks/administer-cluster/safely-drain-node/
https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#drain
如果想维护期间将节点留在集群中。执行

kubectl uncordon <node name>

子命令

Options:
      --delete-local-data=false: Continue even if there are pods using emptyDir (local data that will be deleted when
the node is drained).
      --dry-run=false: If true, only print the object that would be sent, without sending it.
      --force=false: Continue even if there are pods not managed by a ReplicationController, ReplicaSet, Job, DaemonSet
or StatefulSet.
      --grace-period=-1: Period of time in seconds given to each pod to terminate gracefully. If negative, the default
value specified in the pod will be used.
      --ignore-daemonsets=false: Ignore DaemonSet-managed pods.
      --pod-selector='': Label selector to filter pods on the node
  -l, --selector='': Selector (label query) to filter on
      --timeout=0s: The length of time to wait before giving up, zero means infinite

Usage:
  kubectl drain NODE [options]


注意:如果执行过程中不需要驱逐 DS容器,使用–ignore-daemonsets=false
执行之后会有error报错 ,请忽略
在这里插入图片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章