node-drain
Cordons a node (marks it unschedulable) and evicts all eligible pods. Simulates a planned maintenance event.
Target kind: Node
Implementation: Kubernetes API (no daemon)
Rollback: Yes — uncordons the node
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
timeout | string | No | "5m" | Max time to wait for pod eviction |
ignoreDaemonSets | string | No | "true" | Skip DaemonSet pods during eviction |
deleteEmptyDirData | string | No | "true" | Evict pods with emptyDir volumes |
Example
apiVersion: chaos.chaosplane.io/v1alpha1
kind: ChaosExperiment
metadata:
name: node-drain-example
namespace: chaosplane
spec:
target:
kind: Node
labelSelector:
matchLabels:
node-role.kubernetes.io/worker: ""
action:
type: node-drain
parameters:
timeout: "5m"
ignoreDaemonSets: "true"
deleteEmptyDirData: "true"
duration: 5m
rollback:
enabled: true
Rollback behavior
Sets spec.unschedulable: false on the node via the Kubernetes API (uncordon). Pods are not automatically rescheduled back to the node — the scheduler will place new pods there once it's uncordoned.
Implementation notes
Uses the Kubernetes API directly from the operator. No daemon involvement. The operator:
- Sets
node.Spec.Unschedulable = true(cordon) - Lists all pods on the node
- Skips mirror pods (static pods with
kubernetes.io/config.mirrorannotation) - Skips DaemonSet pods if
ignoreDaemonSets: "true" - Skips pods with emptyDir volumes if
deleteEmptyDirData: "false" - Evicts remaining pods via
PolicyV1().Evictions().Evict()
The eviction respects PodDisruptionBudgets.