Skip to content

[Request]: container cluster create: nested virtualization and a custom kernel for nodes #2518

Description

@johnstonmatt

Feature or enhancement request details

container cluster create can't make nodes that run VMs, because every node is created with virtualization: false and kernel: nil (Sources/ContainerCluster/Provisioners/LinuxNodeProvisioner.swift), and nothing on create changes either. container run --virtualization --kernel and container machine create --virtualization --kernel already expose /dev/kvm, so this asks for the same two knobs on cluster nodes.

The concrete case: I work on a platform that runs tenants in micro-VMs on Kubernetes (Substrate, Cloud Hypervisor under each pod), and its node agent needs /dev/kvm on the nodes it schedules onto. Locally that's kind inside a Lima VM with nested virtualization today, which works, but it's a VM to babysit and a Docker daemon to point everything at. container cluster would replace both, since each node is already its own VM.

What would help:

# 2 workers that can run VMs
container cluster create --name cell \
  --workers count=1,cpus=4,memory=8g,virtualization=true,kernel=/path/to/vmlinux-kvm \
  --workers count=1,cpus=4,memory=8g,virtualization=true,kernel=/path/to/vmlinux-kvm

# or for the single node / control plane, matching `container run`
container cluster create --name lab --virtualization --kernel /path/to/vmlinux-kvm

Per worker group rather than cluster-wide, because only the nodes that run VMs need them, and a KVM kernel is a bigger ask than the default one.

Plan, if this direction is ok:

  1. WorkerGroup parses virtualization=true|false and kernel=<path> beside count, cpus and memory, and ClusterCreate gets --virtualization and --kernel for the control plane (or single node).
  2. LinuxNodeProvisioner takes both and passes them into Flags.Management, so the node is created exactly as container run --virtualization --kernel would create it, including its "nested virtualization is not supported on the platform" error on an M1/M2.
  3. NodeConfiguration records both, so anything that recreates a node (eg. the start/stop in Add container cluster start and stop #2485) recreates it the same way.
  4. Tests for the new --workers keys, and a line in docs/cluster.md pointing at the kernel config in docs/runtime-configuration.md.

What I've checked so far (M4, macOS 26.7.2, container 1.7.1): the containerization kernel (kernel/ at main, Linux 6.18.5, built with its own make, run from that checkout) gives a container /dev/kvm with --virtualization:

$ container run --rm --virtualization --kernel ./bin/vmlinux-arm64 busybox sh -c 'ls -l /dev/kvm; dmesg | grep -i kvm'
crw-------    1 root     root       10, 232 Jan  1  1970 /dev/kvm
[    0.017756] kvm [1]: nv: 568 coarse grained trap handlers
[    0.017786] kvm [1]: IPA Size Limit: 40 bits
[    0.018134] kvm [1]: Hyp nVHE mode initialized successfully

And container cluster runs on that kernel today, with it set as the system default (container system kernel set --binary), since nodes take the default when kernel is nil:

$ container cluster create --name kvm-test --workers 1
$ kubectl --context kvm-test get nodes -o wide
NAME                STATUS   ROLES           VERSION   KERNEL-VERSION           CONTAINER-RUNTIME
kvm-test            Ready    control-plane   v1.35.5   6.18.5-cz-7723232d1832   containerd://2.3.1
kvm-test-worker-1   Ready    <none>          v1.35.5   6.18.5-cz-7723232d1832   containerd://2.3.1

kube-system came up Running (CoreDNS, kindnet, kube-proxy, the control plane). So the kernel side is ready, and the gap is only that nodes can't ask for --virtualization, or for a kernel other than the system default, which every other container would then share.

A VM also boots inside a --virtualization container on that kernel. Cloud Hypervisor v45 boots a busybox guest on the container's /dev/kvm, using the same kernel as the guest's, and the guest prints from its own init:

$ container run --rm --virtualization --kernel ./bin/vmlinux-arm64 -v "$PWD/bin:/kernel" alpine:3.20 sh -c '
  apk add -q busybox-static cpio
  wget -qO /usr/local/bin/cloud-hypervisor https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/v45.0/cloud-hypervisor-static-aarch64
  chmod +x /usr/local/bin/cloud-hypervisor
  mkdir -p /r/bin /r/dev /r/proc && cp /bin/busybox.static /r/bin/busybox
  printf "#!/bin/busybox sh\n/bin/busybox mount -t devtmpfs dev /dev\nexec >/dev/console 2>&1\n/bin/busybox echo guest booted: \$(/bin/busybox uname -r)\n/bin/busybox poweroff -f\n" > /r/init
  chmod +x /r/init && (cd /r && find . | cpio -o -H newc --quiet) > /initramfs
  cloud-hypervisor --kernel /kernel/vmlinux-arm64 --initramfs /initramfs --cmdline console=hvc0 \
    --cpus boot=1 --memory size=256M --console tty --serial off'
...
[    0.093229] Run /init as init process
guest booted: 6.18.5-cz-7723232d1832

What I don't know yet: whether one boots inside a cluster node, since nodes can't get --virtualization until this change lands. I'll check it on the PR's build before asking for review.

Related: #2498 (kubeadm config patches, extra mounts and node labels on cluster create), which is the other half of what this setup needs.

Happy to take this on if that's cool with you!

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. changed the title [-][Request]:[/-] [+][Request]: container cluster create: nested virtualization and a custom kernel for nodes[/+] on Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions