-
Notifications
You must be signed in to change notification settings - Fork 404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Golang implementation of image-builder with buildkit backend #1633
Comments
cc @t-lo to see how systemd-sysext fits here |
Some quick thoughts...
|
@rajaskakodkar Thanks for pulling me in! Tl;dr, sysexts would blend well with just about any image building approach you chose. We would preferably compose sysexts into the system at provisioning time. This way, we can provision stock distro images instead of being required to host our own, self-built images. However, we absolutely recognise use cases where pre-built images are preferred, and the additional overhead of self-hosting images is acceptable. In these cases, using sysexts would be as easy as adding 2 or 3 files to well-known locations in the disk image. This should be very straightforward and does not require any exotic actions like e.g. running tools from inside the disk image (as it's currently the case with image-builder). Given the flexibility of sysexts, this could either be done at step 2 or step 3/4 of your process - without losing the ability of updating the Kubernetes bits independently. Re: using OCI images, @AverageMarcus raises a good point - you need to figure out the boot process. There's some prior work for that in the bootc project, which specialises in bootable containers, and requires (to my understanding) special-crafted container images with kernel and bootloader: https://containers.github.io/bootc/intro.html. Re: Marcus' 2nd point, there are minor differences but for Kubernetes specifically, these are negligible - Kubernetes already does a great job at being self-contained. Providers would need to adjust service management (likely systemd on most systems) and maybe logging. I'm not sure about Windows though. I also wouldn't under-estimate vendor support - providing images for cloud vendors will need integration work of the base os, as well as continued testing. This too is a reason we prefer provisioning-time composition as we can directly benefit from the upstream distros' integration work for various clouds :) Lastly, and just out of curiosity, did you have a look at mkosi? It seems to be the go-to tool for building distro images nowadays: https://github.com/systemd/mkosi/ and I know of at least one Kubernetes distro - Edgeless' "Constellation" - that uses mkosi and is happy with it. It currently doesn't support Windows though, and I personally don't have much experience with it (the tooling we use in Flatcar to build vendor images predates mkosi by several years, and we didn't investigate integrating mkosi with Flatcar yet). |
Thanks @AverageMarcus and @t-lo for your feedback!
I have done some experiments that can be PoC'd. The idea is to create a raw disk with things mounted from the host filesystem. The OCI images will provide overlays for what is dictated by image-builder for OS and Kubernetes bits. And then using grub to help with the boot process.
As @t-lo has pointed out, Kubernetes is self contained and the differences per OS are negligible. Alternatively, there can be another OCI layer to make room for these differences. E.g OS -> Kubernetes -> Niche-OS-and-Kubernetes
I think this sums up the idea pretty well!
I haven't and thanks for bringing that up! For next steps, I will try to PoC something and then we can whip out a well crafted proposal. |
There's a lot of prior art in the history of this project, but deleted in #1175 Personally, it feels like bootc is a good wave to ride. |
That sounds like we'd still need Packer to provision machines with each of the OSs we want to build for? Or am I misunderstanding? I'm very keen to see a very basic PoC that can create a VM image based on Ubuntu, Flatcar and Windows (without Kubernetes) just to get a feel for what this will look like in practice and what would be required from the host system etc. |
For a Flatcar PoC please have a look at bake_flatcar_image.sh in our sysext bakery. This script can be used to embed any given sysext into a stock Flatcar OS image. It supports producing "generic" images as well as vendor images for all 35 vendors currently supported by Flatcar (public and private clouds, bare metal, etc.). It's not in Go though, it's in Bash 😅 A brief intro to the OS image bake script is here. E.g. for integrating Flatcar into the PoC we can leverage that script to embed the Kubernetes sysext, like so: wget https://raw.githubusercontent.com/flatcar/sysext-bakery/refs/heads/main/bake_flatcar_image.sh
chmod 755 bake_flatcar_image.sh
./bake_flatcar_image.sh --fetch kubernetes:kubernetes-v1.31.3-x86-64.raw This will produce a Flatcar disk image with Kubernetes embedded - and since it's a sysext, it can still be in-place updated. The sysext will be fetched from the Bakery - for a full list of Kubernetes sysexts available check out the Bakery releases. We could of course also "bake" an OS image with a local (custom built) sysext - the create_kubernetes_sysext.sh bakery script would come in helpful here. We can also produce a vendor image - a ready-made cloud image with guest tools for a specific cloud. For AWS e.g. run ./bake_flatcar_image.sh --fetch --vendor ami kubernetes:kubernetes-v1.31.3-x86-64.raw which will produce Deployments would merely need to add a kubelet config at |
Oh and, with the new The main issue was that as soon as you merge a sysext, the whole of This way, we can cover Ubuntu with sysexts too, and only Windows is left as a special case. |
I suspect that will always be the case to some degree so not too worried about that. 😁 |
This is great, @t-lo
We won't need packer, @AverageMarcus! I think things will be clear with some PoC! I am going to find some time to get that out but I expect some delay due to prior commitments. |
Sounds good! There's no rush. It's also coming up to the holiday season so I don't know about others but I'm going to be away for the next ~1 month anyway 😆 |
Is your feature request related to a problem? Please describe.
Currently, there are bunch of issues with the build and test of image-builder
Describe the solution you'd like
One liner pitch: A Golang implementation of image builder with buildkit at its backend providing OCI layers for OS and Kubernetes related actions.
Slightly more detailed version: The idea is to transform the build system of image builder to start with
2.1. To create this filesystem, start with an OCI Image of the OS and implement all the tasks done by image-builder at an OS level in golang with buildkit llb at its backend https://github.com/moby/buildkit/blob/c1dacbc5ce0544ff72f7dc8acd9b99f015c2021a/docs/dev/dockerfile-llb.md
This enables clear demarkation between the OS and the Kubernetes layers as well as moves to a golang implementation. This can then be extended to write an e2e suite with inspect tests for automated testing.
This also moves away from packer.
This is distro agnostic and can work for windows as well.
Describe alternatives you've considered
systemd-sysext https://man.archlinux.org/man/systemd-sysext.8.en has appeared in the community and maybe there is a middle ground here to figure out how to integrate the OCI approach with systemd-sysext. Comments welcome!
A caveat here is that systemd-sysext will work only on systemd distros and not on windows
Another alternative is bootc for linux distros - https://github.com/containers/bootc
Additional context
My partners in crime in brainstorming this have been @randomvariable and @clebs and we want to check the appetite of the community for this feature. Happy to contribute to this effort!
cc @AverageMarcus @mboersma
/kind feature
The text was updated successfully, but these errors were encountered: