DEV Community

Cover image for MicroK8s: Configure Garbage Collection to reduce used space
Sergio Peris
Sergio Peris

Posted on • Originally published at sertxu.dev

MicroK8s: Configure Garbage Collection to reduce used space

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
Enter fullscreen mode Exit fullscreen mode
--image-gc-high-threshold=50
--image-gc-low-threshold=40
--maximum-dead-containers=0
Enter fullscreen mode Exit fullscreen mode

You can adjust the thresholds to your needs.

Then we should restart MicroK8s by running:

snap restart microk8s
Enter fullscreen mode Exit fullscreen mode

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

Top comments (0)