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
| Argument | Description |
|---|---|
<index> | Row number from the current listing; run kx state to see it |
Options
| Option | Description |
|---|---|
--delete-emptydir-data | Continue even though pods use emptyDir volumes, whose data is lost |
--force | Evict pods no controller manages, which will not come back |
--grace-period int | Seconds to give each pod to terminate; -1 uses the pod’s own |
--ignore-daemonsets | Continue even though DaemonSet-managed pods cannot be evicted |
--timeout duration | Give up waiting after this long |
-y, --yes | Skip the confirmation prompt |
Global options
| Option | Description |
|---|---|
--no-color | Disable styled output |
-h, --help | Show this message and exit |
Examples
kx drain 1
kx drain 1 --ignore-daemonsets
kx drain 1 -y --ignore-daemonsets --delete-emptydir-data