Skip to main content

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

NameTypeRequiredDefaultDescription
timeoutstringNo"5m"Max time to wait for pod eviction
ignoreDaemonSetsstringNo"true"Skip DaemonSet pods during eviction
deleteEmptyDirDatastringNo"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:

  1. Sets node.Spec.Unschedulable = true (cordon)
  2. Lists all pods on the node
  3. Skips mirror pods (static pods with kubernetes.io/config.mirror annotation)
  4. Skips DaemonSet pods if ignoreDaemonSets: "true"
  5. Skips pods with emptyDir volumes if deleteEmptyDirData: "false"
  6. Evicts remaining pods via PolicyV1().Evictions().Evict()

The eviction respects PodDisruptionBudgets.