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
| Command | Effect |
|---|---|
cordon | Marks node Unschedulable. Existing pods keep running |
drain | Evicts all pods AND marks node Unschedulable |
uncordon | Marks 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 healthyMemoryPressureβ node is low on memoryDiskPressureβ node is low on diskPIDPressureβ too many processesNetworkUnavailableβ CNI not configured