k3s-io / k3s

Lightweight Kubernetes
https://k3s.io
Apache License 2.0
28.09k stars 2.35k forks source link

Auto-import images into the embedded registry while k3s is running #9759

Open r65535 opened 8 months ago

r65535 commented 8 months ago

Is your feature request related to a problem? Please describe. k3s can load a bunch of resources from disk:

With the new embedded registry, it'd be nice to also have a directory that can auto-load in miscellaneous OCI images (similar to k3s-airgap-images-amd64.tar.zst, but for arbitrary images). Especially in an edge/airgapped environment.

Describe alternatives you've considered A crontab that finds files in a local directory and k3s ctr images import each TAR file 😓

brandond commented 8 months ago

The Spegel embedded registry mirror only supports mirroring things that can be loaded into containerd's image store. It has no store of its own. Containerd does not, as far as I know, support storing arbitrary OCI artifacts in its image store.

Feel free to open an issue at https://github.com/XenitAB/spegel and/or https://github.com/containerd/containerd - once they support it, we can too.

brandond commented 8 months ago

Or perhaps I'm misunderstanding what you mean by "miscellaneous" / "arbitrary" OCI images. Are you just asking for periodic re-import of tarballs from the images directory, instead of only importing them on startup?

That's been asked for in the past, but hasn't been prioritized. Homebrewing something with ctr -n k8s.io image import is probably your best bet.

r65535 commented 8 months ago

As an example, I want to deploy bitnami/zookeeper to k3s in an airgapped environment.

But I can't load the zookeeper.tar containing the container image into the new embedded registry, without manually running k3s ctr images import zookeeper.tar. It'd be great if I could drop in that zookeeper.tar to a directory on the k3s server, and it auto-loads that image into the registry

brandond commented 8 months ago

Thanks for the additional context. I'll leave this on the backlog.

harsimranmaan commented 3 months ago

Autoloading approach can also help with managing image load times by deferring image imports for https://github.com/k3s-io/k3s/issues/9242