MicroK8s: Configure Garbage Collection to reduce used space

Published at 25 Jun 2025

The folder io.containerd.snapshotter.v1.overlayfs contains the different image layers used by containerd. If the server starts running out of space, kubelet has the ability to garbage collect unused images.

We can change it's configuration to make it more aggressive, so less space is used by unused image layers.

Edit the /var/snap/microk8s/current/args/kubelet file by adding the following parameters.

vi /var/snap/microk8s/current/args/kubelet
--image-gc-high-threshold=50
--image-gc-low-threshold=40
--maximum-dead-containers=0

You can adjust the thresholds to your needs.

Then we should restart MicroK8s by running:

snap restart microk8s

After few minutes, the garbage collector should have deleted all the unused image layers from our server.