Skip to main content
Course/Security & Scale/Node Management β€” Cordon, Drain & Maintenance
7/860 min
Security & Scale

Node Management β€” Cordon, Drain & Maintenance

Safely remove nodes from rotation for maintenance without disrupting running workloads.

intermediate60 minRead β†’ Lab β†’ Quiz β†’ Practice
🧠 Brain Warm-Up
🧠 Brain Warm-Up: You need to reboot a node for a kernel upgrade. 5 pods are running on it. How do you ensure the pods are safely rescheduled before you reboot, without any downtime?

The Maintenance Workflow

1. kubectl cordon <node>   β†’ mark Unschedulable (no NEW pods)
2. kubectl drain <node>    β†’ evict all pods + cordon
3. [perform maintenance]
4. kubectl uncordon <node> β†’ re-enable scheduling

Cordon vs Drain

CommandEffect
cordonMarks node Unschedulable. Existing pods keep running
drainEvicts all pods AND marks node Unschedulable
uncordonMarks node Schedulable again

kubectl drain Flags

kubectl drain node-1 \
  --ignore-daemonsets \   # DaemonSet pods cannot be moved β€” skip them
  --delete-emptydir-data  # Allow draining pods with emptyDir volumes

Without --ignore-daemonsets, drain fails if DaemonSet pods are present.

Taints and Tolerations

Taints repel pods from nodes. Tolerations allow pods to be scheduled on tainted nodes.

Node taint: key=value:effect
  - NoSchedule: new pods without toleration not scheduled
  - PreferNoSchedule: soft preference against scheduling
  - NoExecute: existing pods without toleration are evicted

Pod toleration:
  key: "key"
  operator: "Equal"
  value: "value"
  effect: "NoSchedule"

Node Conditions

kubectl describe node shows:

  • Ready β€” node is healthy
  • MemoryPressure β€” node is low on memory
  • DiskPressure β€” node is low on disk
  • PIDPressure β€” too many processes
  • NetworkUnavailable β€” CNI not configured