Hi Stefan, Thanks to bring this to the ML. This is an interesting approach I have not play with Dracut a lot in the past but it definitely is a good thing look at. When we started osbuilder the idea was to show adopters that Kata was able to boot with any OS as base (as long follow some requirements) and probably they adapt as needed or create their own tooling get Kata working for them. After all this time I see that it is more value to have just one tool that anyone can use and is flexible for developers and linux distributions adoption. So I think would need more feedback from all the community and also from linux distributions in general so we can have a solution that works better for all. Here some question related with dracut usage: 1. Is it possible to build a disk image? I think the answer is not. This is a feature that is still difficult to be compatible with packaging but helps in memory usage if used with DAX. So probably a nice feature to keep 2. Is it possible to have a custom rootfs with packages I want? Today we require system + agent + iptables + chrony. But also we support not having system but the agent as init. Also, users may want to add additional binaries in the future (to be part of the official image or just for hacking). On Tue, May 07, 2019 at 11:41:12AM -0400, Stefan Hajnoczi wrote:
Hi, Paolo Bonzini, Xu Wang, and I discussed using dracut (https://dracut.wiki.kernel.org/) to build a distro-friendly initramfs at the OpenStack Denver PTG.
I'm sharing a proof-of-concept for Fedora. Other distros can probably follow a similar approach.
This process creates an initramfs from the host system using dracut. It's fast and produces a relatively small initramfs. On my Fedora 30 system the file size is 19 MB including kata-agent and it could probably be optimized further.
osbuilder is replaced with dracut, a tool that distro kernel packagers are familiar with. I hope that this approach will make it easy and acceptable to package Kata Containers.
This is the major pro I can find of using this. The adoption will be easier for linux distributions, we had a workaround Fedora to build the image at post install but still got errors as for fedora the way to go is to use the host kernel. For SUSE Marco used a custom feature of OBS that is called kiwi. For Ubuntu we dont have any effort to get packages but we have snaps that have a bit more of freedom that traditional packaging tools. So I would like to get more feedback from differed linux distributions.
The scripts below build a kata-containers-initrd.img with systemd and the kernel modules from the host system. The generic distro kernel is used in the sandbox VM, something that distro kernel packagers will be happy about since it keeps their test matrix unchanged.
The proof-of-concept code is available here:
https://github.com/stefanha/agent/tree/fedora-dracut
To build the Kata sandbox VM initramfs:
# make # mkdir initramfs-overlay # make DESTDIR=initramfs-overlay install # make initrd
Edit /etc/kata-containers/configuration.toml so that hypervisor.qemu.kernel points to the host's vmlinuz and initrd points to the generated kata-containers-initrd.img file. hypervisor.qemu.kernel_params must contain systemd.unit=kata-containers.target so that kata-agent is launched upon sandbox VM boot. Also set hypervisor.qemu.use_vsock to true.
Stefan