Skip to content

kx drain

Cordons a node and evicts the pods running on it, waiting for each to terminate. Streams kubectl’s own progress, which can run for minutes.

One index only, unlike kx cordon: a drain evicts running workloads and blocks until they are gone, so applying it to a range of nodes in one command is a way to take a cluster down by typo.

kubectl’s own drain flags pass through — a drain usually needs --ignore-daemonsets, and often --delete-emptydir-data.

Unrecognized flags are passed through to kubectl.

Usage

kx drain [OPTIONS] <index> [kubectl flags]

Arguments

ArgumentDescription
<index>Row number from the current listing; run kx state to see it

Options

OptionDescription
--delete-emptydir-dataContinue even though pods use emptyDir volumes, whose data is lost
--forceEvict pods no controller manages, which will not come back
--grace-period intSeconds to give each pod to terminate; -1 uses the pod’s own
--ignore-daemonsetsContinue even though DaemonSet-managed pods cannot be evicted
--timeout durationGive up waiting after this long
-y, --yesSkip the confirmation prompt

Global options

OptionDescription
--no-colorDisable styled output
-h, --helpShow this message and exit

Examples

kx drain 1
kx drain 1 --ignore-daemonsets
kx drain 1 -y --ignore-daemonsets --delete-emptydir-data