k0sproject / k0s

k0s - The Zero Friction Kubernetes
https://docs.k0sproject.io
Other
3.42k stars 353 forks source link

Remove pinning from outdated k0s-imported OCI images #4433

Open twz123 opened 3 months ago

twz123 commented 3 months ago

When k0s imports OCI images into containerd, it pins them to prevent them from being garbage collected. If the OCI images are replaced regularly over time, e.g. if an airgapped cluster is regularly upgraded, these images will pile up in containerd's image filesystem, potentially leading to disk pressure at some point.

K0s should be smart about this. It should unpin imported images that are no longer in the import folder. This will allow containerd to remove any old images once they are no longer in use.

ricardomaraschini commented 3 months ago

I am more than happy to work on this if no one else is acting yet.

jnummelin commented 3 months ago

❤️

One idea I had for this was to label each image with the filename where it was imported from. That way we can delete images which no more has bundle file for it. Haven't spent much time thinking about this so there might be some gaps in my idea... 😂

twz123 commented 3 months ago

I am more than happy to work on this if no one else is acting yet.

Yes, please! Go ahead :rocket:

I was thinking about adding some extra labels to the imported images, so that k0s can identify which ones have been imported previously. Then it could remove the pin label from those previously imported images that aren't part of any of the bundles in the bundle dir anymore. Or sth. along those lines. WDYT?

ricardomaraschini commented 3 months ago

I had designed a possible solution using Labels as proposed. Let me know what you think: https://github.com/k0sproject/k0s/pull/4500