Interview Prep/Kubernetes/Nodes, kubelet and container runtime

kubelet logs say `failed to garbage collect required amount of images. Attempted to free 4.2GB, but only found 0 bytes eligible to free`.

AdvancedTroubleshootingNodes, kubelet and container runtime
Answer

Likely causes → Image GC cannot help because the disk is filled by something that is not an unused image: images in use by running Pods, logs, emptyDirs, or files outside containerd (journals, old kernels, data written by a hostPath Pod).

Diagnose →

sudo du -xh --max-depth=2 / 2>/dev/null | sort -h | tail -20
sudo du -sh /var/lib/kubelet/pods/*/volumes/kubernetes.io~empty-dir/* 2>/dev/null | sort -h | tail
journalctl --disk-usage

Fix → Remove the actual space hog: vacuum journals (journalctl --vacuum-size=500M), clean the hostPath data, evict the Pod with the huge emptyDir. Only then can the node recover.

Prevent → Separate data volumes from the root disk, limit journald size, block hostPath writes via policy.

All Kubernetes questions

More on Nodes, kubelet and container runtime