kubectl-drain
Drain a node in preparation for maintenance by marking it unschedulable and evicting all pods. tldr-pages
On several platforms
Several platforms
Drain a node
kubectl drain node_nameIdentifyDrain a node, ignoring DaemonSet-managed pods
kubectl drain node_name --ignore-daemonsetsIdentify--ignore-daemonsetsIgnore DaemonSet-managed pods. kubectl referenceDrain a node and delete pods using emptyDir volumes (local data will be lost)
kubectl drain node_name --ignore-daemonsets --delete-emptydir-dataIdentify--ignore-daemonsetsIgnore DaemonSet-managed pods. kubectl reference--delete-emptydir-dataContinue even if there are pods using emptyDir (local data that will be deleted when the node is drained). kubectl referenceDrain a node, forcing eviction of pods not managed by a controller
kubectl drain node_name --forceIdentify--forceContinue even if there are pods that do not declare a controller. kubectl referenceDrain a node with a custom grace period for pod termination
kubectl drain node_name --grace-period secondsIdentify--grace-periodPeriod of time in seconds given to each pod to terminate gracefully. kubectl referenceDrain a node, evicting only pods that match a label selector
kubectl drain node_name --pod-selector label_key=label_valueIdentify--pod-selectorLabel selector to filter pods on the node kubectl referenceDrain a node with a timeout
kubectl drain node_name --timeout durationIdentify--timeoutThe length of time to wait before giving up, zero means infinite kubectl referenceSimulate the drain operation without actually evicting pods
kubectl drain node_name --dry-run=noneIdentify--dry-runMust be "none", "server", or "client". kubectl reference