Fix NotReady nodes and disk pressure
In this task you'll find out why a node is NotReady or under pressure, and move work off it safely.
A node turns NotReady when its kubelet stops reporting in: the kubelet or container runtime has stopped, the node is out of memory or disk, its network is broken, or its certificates have expired. After about 5 minutes (the default tolerationSeconds of 300), Kubernetes evicts its pods so they're recreated elsewhere.
DiskPressure means the node is short of disk (by default under 10% free for the node, or 15% for images). The kubelet first deletes unused images, then evicts pods, and taints the node so nothing new lands there. Cordon stops new pods landing on a node; drain moves its pods off politely, respecting disruption budgets.
Example. Kestwick Hotels' AKS node showed DiskPressure every Friday. A pod wrote debug logs to an emptyDir with no size limit. They added sizeLimit and sent logs to stdout, and the pressure stopped.
Before you start
You need: Docker Desktop and kind on your computer (both free). Time: 35 minutes.
Where to look
- Terminal
- kubectl
- docker
Steps
- Run
kubectl get nodesandkubectl describe node lab-worker, and read the Conditions table (Ready, MemoryPressure, DiskPressure, PIDPressure). - Simulate a dead node:
docker stop lab-worker. Within a minute,kubectl get nodesshows it NotReady. - Check its taints:
kubectl describe node lab-worker | grep -i taint. Thendocker start lab-workerand watch it recover. - Cordon and drain the other worker:
kubectl cordon lab-worker2thenkubectl drain lab-worker2 --ignore-daemonsets --delete-emptydir-data. - Bring it back with
kubectl uncordon lab-worker2.
Commands
kubectl get nodes
kubectl describe node <node> | sed -n '/Conditions:/,/Addresses:/p'
kubectl cordon <node>
kubectl drain <node> --ignore-daemonsets --delete-emptydir-data
kubectl uncordon <node>
Watch out for
- Cost
- Free on kind. On AKS, a node that stays NotReady can often be fixed by reimaging it, or deleting it and letting the node pool replace it.
- Security
- Node access (SSH or
kubectl debug node) is very powerful: restrict who can do it. - Common mistakes
- Draining without
--ignore-daemonsets, which stops it, and forgetting to uncordon afterwards.
Clean up
Start any stopped node container and uncordon the nodes, or delete the kind cluster.
Words to know
- NotReady
- A node whose kubelet has stopped reporting healthy; its pods are evicted after a grace period.
- DiskPressure
- A node condition: disk space is low, so the kubelet cleans up images and evicts pods.
- Cordon
- Mark a node unschedulable so no new pods are placed on it.
- Drain
- Evict a node's pods (respecting disruption budgets) so it can be maintained.
- Taint
- A mark on a node that keeps pods off it unless they tolerate it.
Tick off each step and track your progress in the guide.
Open this task in DevOps, Hands On