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)

Launch embedded dashboards in 10% of the time - with 100% of your standards.

Launch embedded dashboards in 10% of the time - with 100% of your standards.

Ship pixel-perfect dashboards that feel native to your app with Embeddable. It's fast, flexible, and built for devs.

Get early access

👋 Kindness is contagious

Explore this practical breakdown on DEV’s open platform, where developers from every background come together to push boundaries. No matter your experience, your viewpoint enriches the conversation.

Dropping a simple “thank you” or question in the comments goes a long way in supporting authors—your feedback helps ideas evolve.

At DEV, shared discovery drives progress and builds lasting bonds. If this post resonated, a quick nod of appreciation can make all the difference.

Okay