NetBSD as a Kubernetes Pod
2025/01 Update https://github.com/NetBSDfr/smolBSD/tree/main/k8s
I had to do it.
So here’s how to run a NetBSD micro-vm as… a Kubernetes pod.
First thing is to modify the start script from the previous article in order to add Docker-style networking, i.e. port forwarding from the host to the micro-vm. This is done using the hostfwd flag in qemu’s -netdev parameter
#!/bin/sh
kernel=$1
img=${2:-"root.img"}
[ -n "$3" ] && drive2="-drive file=${3},if=virtio"
qemu-system-x86_64 -enable-kvm -m 256 \
-kernel $kernel -append "console=com root=ld0a" \
-serial mon:stdio -display none \
-drive file=${img},if=virtio $drive2 \
-netdev user,id=net0,hostfwd=tcp::8080-:80 -device virtio-net,netdev=net0
In the previous experience we mapped the kernel and the root image from the host using Docker’s -v parameter, and while it’s possible to map files from the host using a Kubernetes volume, we will bundle NetBSD these files into the Docker image to make things easier.
Please refer to mksmolnb documentation to learn how to produce a minimal nginx micro-vm.