Install
go install github.com/Blackman99/drainready/cmd/drainready@latest
As a kubectl plugin (krew-index submission pending): kubectl krew install drainready, then kubectl drainready NODE. Any kubectl-drainready binary on your PATH also works.
Or download a single static binary (linux, macOS, windows; amd64/arm64) from Releases. It uses your normal kubeconfig, like kubectl.
Usage
drainready NODE [NODE...] # check named nodes drainready -l LABEL_SELECTOR # every node matching a label drainready --all # every node in the cluster --context NAME kubeconfig context --kubeconfig PATH --force assume drain runs with --force --delete-emptydir-data assume drain runs with --delete-emptydir-data --server-dry-run confirm with server-side dry-run evictions (nothing is evicted) --json machine-readable output --markdown report for a change ticket or PR comment -v also list OK and skipped pods
Verdicts and exit codes
| Verdict | Meaning |
|---|---|
| OK | Eviction admitted now. |
| WAIT | More pods of one PDB on this node than disruptionsAllowed. Drain completes as replacements turn ready elsewhere, if there is room. |
| FLAG | Bare pod (no controller) or emptyDir: drain refuses unless you pass --force / --delete-emptydir-data. |
| BLOCKED | PDB allows 0 disruptions, its controller cannot compute it (SyncFailed), pod matches more than one PDB, or the server dry-run refused. Drain would retry forever. |
| SKIP | DaemonSet, mirror/static, finished or terminating pods. |
Exit code 0 ready (OK/WAIT) · 1 blocked · 3 needs a flag · 2 error.
How it works
drainready lists the pods on each node (spec.nodeName) and every PodDisruptionBudget, matches budgets to pods by selector in the same namespace, and applies the rules the Eviction API uses: status.disruptionsAllowed, multiple-PDB rejection, unhealthyPodEvictionPolicy for not-ready pods, stale PDB status (observedGeneration), and the DisruptionAllowed=False / SyncFailed condition the disruption controller sets when it cannot compute a budget. For each blocked pod it explains the cause: already-unhealthy replicas, minAvailable equal to the replica count (or 100%), or maxUnavailable: 0 / 0%.
Node-pinned volumes. If a pod's PersistentVolume has node affinity that no other schedulable node satisfies (a local volume on this node, or a zonal disk whose zone has only cordoned nodes left), its replacement stays Pending until the node is back. Each such eviction spends one disruption of its budget for good, so when a node holds more pinned pods of a PDB than it allows, drain retries forever and drainready reports BLOCKED. Within budget it stays OK but warns that the next node of that workload may stall. This check needs list on nodes, PersistentVolumeClaims and PersistentVolumes; without it drainready skips it silently.
SyncFailed budgets. maxUnavailable and percentage minAvailable need every selected pod to belong to a controller with a scale subresource. Pods owned by an operator CRD without /scale make the controller give up and pin disruptionsAllowed at 0; because it also never records observedGeneration, the budget looks merely "stale" while every eviction gets 429 forever. drainready reports these as BLOCKED with the controller's own message. Fix: an integer minAvailable, a /scale subresource on the CRD, or a narrower selector.
The PDB status can lag reality by a few seconds. --server-dry-run sends a real eviction with dryRun=All for every pod predicted OK, which also catches admission webhooks. Nothing is evicted or cordoned.
RBAC
rules: - apiGroups: [""] resources: [nodes, pods] verbs: [get, list] - apiGroups: [policy] resources: [poddisruptionbudgets] verbs: [list] # only for --server-dry-run: - apiGroups: [""] resources: [pods/eviction] verbs: [create]
In upgrade scripts
drainready -l eks.amazonaws.com/nodegroup=old || { echo "fix PDBs before upgrading"; exit 1; }
Use --json to feed results to other tools, or --markdown to attach a report to the change ticket:
drainready --markdown -l eks.amazonaws.com/nodegroup=old > drain-check.md
See the roadmap.