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報錯 ,請忽略
在這裏插入圖片描述

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