Introduction
A rolling upgrade of my four Talos nodes had just finished. Every node was back, Ready, on the new version. Two minutes later, one of them closed its doors:
Taints: node.kubernetes.io/disk-pressure:NoScheduleThe node was not broken and its disk was not full of data. It was full of container images, most of them for versions I had stopped running weeks ago. The kubelet has a garbage collector for exactly that. It had never run.
The reason is a coincidence between two default values. The kubelet starts cleaning images when the disk is 85 % full, and it declares an emergency when less than 15 % is free. That is the same point. This post explains the two mechanisms, why the emergency always wins the race, and the three lines of configuration that separate them.
It is the third post born from draining nodes, after the PodDisruptionBudget that blocked a drain and the lopsided cluster a drain leaves behind.
Three Concepts Before the Story
Images pile up on nodes. When a pod starts, the kubelet asks the container runtime to pull its image onto the node’s disk. When the pod goes away, the image stays. That is on purpose: the next pod using it starts without a download. Nothing removes an image when you upgrade an application from version 1.4 to 1.5. Both versions now sit on the disk.
Image garbage collection. The kubelet has a cleaner for unused images, driven by two percentages of disk usage:
| Setting | Default | Meaning |
|---|---|---|
imageGCHighThresholdPercent | 85 | Above this, start deleting unused images, oldest first |
imageGCLowThresholdPercent | 80 | Stop once usage is back under this |
imageMaximumGCAge | 0s (off) | Delete an image unused for this long, whatever the disk usage |
It checks every five minutes. An image used by any container on the node is never deleted.
Node-pressure eviction. Separately, the kubelet protects the node from running out of resources. It watches a few signals, and one of them is imagefs.available: the free space on the filesystem that holds images. The default threshold is imagefs.available<15%. When it is crossed:
- The node gets the
DiskPressurecondition and aNoScheduletaint, so no new pod lands on it. - The kubelet tries to reclaim disk space at node level, by deleting every unused image.
- If that is not enough, it starts evicting pods.
This check runs every ten seconds.
The Coincidence
Put the two defaults side by side:
- Garbage collection starts when usage reaches 85 %.
- Eviction starts when free space drops under 15 %, which is usage above 85 %.
They trigger at the same level, and one of them looks 30 times more often than the other. When a burst of image pulls pushes the disk past 85 %, the ten-second loop sees it long before the five-minute loop does. The gentle cleaner never gets its turn. Cleaning only happens as an emergency, with the node tainted.
Even when the garbage collector does get there first, it only brings usage down to 80 %. That leaves five points of margin under the alarm line, about 2.4 GiB on my disks. One more application update and the node is back at the edge.
On many distributions the images have their own partition, or the disk is large enough that 85 % is never reached. On my nodes neither is true. Talos stores everything that changes (images, container layers, logs, emptyDir volumes) on a single partition, /var, which is 47.8 GiB here. Both nodefs and imagefs signals watch that same disk, and the stricter one (imagefs, 15 %) decides.
What Happened
The numbers below come from my metrics and from the Kubernetes events my log pipeline keeps. Kubernetes itself forgets events after one hour.
Before the upgrade, disk usage on /var was uneven, and had been for weeks:
| Node | Usage before | What the kubelet did about it |
|---|---|---|
| node 1 | 40 % | nothing |
| node 2 | 42 % | nothing |
| node 3 | 56 % | nothing |
| node 4 | 72 % | nothing: 72 is below 85 |
Then the rolling upgrade drained and rebooted the nodes one at a time: node 2, node 3, node 4, and node 1 last. Each took about two minutes.
| Time | Event |
|---|---|
| 19:30 | Node 1 is drained. About 15 of its pods are recreated on node 4 |
| 19:30 to 19:34 | Node 4 pulls the images those pods need. Usage climbs from 72 % to 86 % |
| 19:32 | Node 1 is back. The upgrade is finished |
| 19:34:50 | Node 4: EvictionThresholdMet, “Attempting to reclaim ephemeral-storage” |
| 19:35 to 19:38 | The kubelet deletes 90 unused images. Usage falls to 25 % |
| about 19:40 | The taint is removed |

My metrics sample the disk once a minute, so the curve peaks just under the line. The kubelet, which looks every ten seconds, saw 86 %.
No pod was evicted, and nothing stayed Pending. I was lucky with the order. The same taint two nodes earlier in the rolling would have left two nodes out of four closed to new pods: the one being drained and the one under disk pressure.
Two details in that timeline are worth a second look.
The taint outlasted the problem. The disk was back at 25 % within three minutes, but the taint stayed for about five. The kubelet waits evictionPressureTransitionPeriod (5 minutes by default) before it clears a pressure condition, so that a node hovering around the threshold does not flip back and forth.
The emergency cleanup is all or nothing. Regular garbage collection stops at the low threshold. The eviction path does not: it removes every image that no container uses. Node 4 went from 86 % to 25 % in one go. Effective, but every one of those images has to be downloaded again the next time a pod needs it.
What Was on the Disk
Node 3 had not crossed the line. It sat at 74 % after the upgrade, so I could look at what a “normal” node was carrying: 54 of its 92 images were used by no pod at all. They made up 63 % of the image bytes.
Where did they come from?
- Old versions. Renovate updates my applications several times a week. Each update leaves the previous image behind. A node that has hosted an application for months can hold months of its versions.
- A floating tag pulled on every run. One nightly job uses a major-version tag with
imagePullPolicy: Always. Every upstream release puts a new image behind that tag, and the previous one stays on the disk, now without a name. - A retired component. The images of a storage driver I had replaced two weeks earlier were still there.
Automated updates are great for staying current. They also produce image garbage much faster than a cluster that is updated by hand twice a year. And with the defaults, nothing collects that garbage before the alarm.
The Fix
Three settings in the kubelet configuration:
imageGCHighThresholdPercent: 70
imageGCLowThresholdPercent: 60
imageMaximumGCAge: 168h- Start at 70 %. That leaves 15 points, about 7 GiB on my disks, between the moment cleaning starts and the moment eviction would. A drain made node 4 gain 14 points in four minutes. The gap has to be larger than the biggest burst of pulls that can happen between two garbage collection passes.
- Clean down to 60 %. Ten points per pass instead of five, so the collector does not run again after every single update.
- Seven days. An image that no container has used for a week is deleted even when the disk is half empty. This one removes the old versions continuously, instead of letting them accumulate until a threshold.
I did not touch the eviction threshold. Moving the alarm line would hide the problem. Moving the cleaner is what solves it.
A bigger disk would not have solved it either. With no maximum age, unused images grow until they reach 85 % of whatever size the disk is.
On Talos
Since Talos 1.14, the machine configuration is a set of documents, and the kubelet has its own. My patch is the whole file:
apiVersion: v1alpha1
kind: KubeletConfig
config:
imageGCHighThresholdPercent: 70
imageGCLowThresholdPercent: 60
imageMaximumGCAge: 168hOn older Talos versions, the same fields go under machine.kubelet.extraConfig:
machine:
kubelet:
extraConfig:
imageGCHighThresholdPercent: 70
imageGCLowThresholdPercent: 60
imageMaximumGCAge: 168hApplying it does not need a reboot. Talos restarts the kubelet and running pods are not touched.
On other distributions these are standard fields of the KubeletConfiguration file (with kubeadm: /var/lib/kubelet/config.yaml).
Checking What the Kubelet Really Uses
Never trust the file. Ask the running kubelet:
kubectl get --raw "/api/v1/nodes/<NODE_NAME>/proxy/configz" \
| jq '.kubeletconfig | {imageGCHighThresholdPercent,
imageGCLowThresholdPercent, imageMaximumGCAge, evictionHard}'{
"imageGCHighThresholdPercent": 70,
"imageGCLowThresholdPercent": 60,
"imageMaximumGCAge": "168h0m0s",
"evictionHard": {
"imagefs.available": "15%",
"imagefs.inodesFree": "5%",
"memory.available": "100Mi",
"nodefs.available": "10%",
"nodefs.inodesFree": "5%"
}
}The same API gives the disk usage as the kubelet sees it:
kubectl get --raw "/api/v1/nodes/<NODE_NAME>/proxy/stats/summary" \
| jq '.node.fs | {capacityBytes, availableBytes}'What Surprised Me After the Fix
A Warning Right After Applying
Node 3 was at 74 %, above the new 70 % threshold, so I expected the collector to get to work as soon as the new configuration was live. Instead, the first thing it produced was a warning:
FreeDiskSpaceFailed: Insufficient free disk space on the node's image
filesystem (75% of 47.8 GiB used). Failed to free sufficient space by
deleting unused images (freed 0 bytes).Zero bytes, on a node where 54 images were unused. The explanation is a fourth setting, imageMinimumGCAge, which defaults to two minutes. The kubelet does not delete an image it discovered less than two minutes ago, because a freshly pulled image is probably about to be used. Applying the configuration had restarted the kubelet, and a restarted kubelet has just “discovered” every image on the disk. The first pass found nothing old enough.
The next pass did the job. A few minutes later node 3 was at 30 %.
It went further than the 60 % target, and I have not fully explained that part. My best guess is that the kubelet counts the size the runtime reports for each image, while the disk also holds the unpacked layers, so each deletion frees more than the kubelet thinks.
The Seven Days Start When the Kubelet Starts
The kubelet keeps the “last used” time of each image in memory. A restart loses it. The Kubernetes documentation says so: after a restart, the kubelet waits the full imageMaximumGCAge before it deletes anything based on age.
So the age rule only works on nodes whose kubelet stays up longer than the configured age. If your nodes restart every week, a seven-day maximum age never fires and only the thresholds protect you.
I saw it happen. All four nodes were rebooted two days after the fix, for maintenance on the hosts underneath. The seven-day clock started again that evening and only ran out on 12 November, nine days after I had set it.
Eleven Days Later
There has been no disk pressure event since, including during those four reboots. Disk usage today:
| Node | Before the fix | Today |
|---|---|---|
| node 1 | 40 % | 36 % |
| node 2 | 42 % | 31 % |
| node 3 | 56 % (74 % after the upgrade) | 42 % |
| node 4 | 72 % (86 % at the peak) | 40 % |
Key Takeaways
| Concept | What I Learned |
|---|---|
| Same trigger point | Image GC starts at 85 % used; eviction starts under 15 % free. It is the same line |
| The fast loop wins | Eviction is checked every 10 s, image GC every 5 min; after a burst of pulls, eviction gets there first |
| Emergency cleanup | Under disk pressure the kubelet deletes every unused image, not just enough to reach the low threshold |
| The taint lingers | DiskPressure stays 5 minutes after the disk is clean; the node takes no new pod meanwhile |
| Updates make garbage | Automated updates leave one old image per bump; more than half of my images were unused |
| Leave a gap | Put the GC threshold below the eviction line by more than one drain’s worth of pulls |
| Maximum age | imageMaximumGCAge removes old versions continuously, but its clock restarts with the kubelet |
| Ask the kubelet | /configz shows the values in use, not the ones you think you set |
Conclusion
This was not a bug. Both mechanisms did what their documentation says. The defaults assume that 85 % of a disk is a lot of room and that images change rarely. A small node disk and a bot that merges updates every night break both assumptions.
What I like about the fix is its size. I had been looking at a node with a disk-pressure taint and thinking about bigger disks. The answer was to let a cleaner that already existed start fifteen points earlier.
The usual lesson from this series applies once more: a drain is the moment a cluster’s quiet imbalances become visible. The PodDisruptionBudget, the lopsided scheduling and now the image cache were all fine until pods had to move.
Useful Resources:
