Skip to main content

Run unikernels

The unikernel runtime class runs a unikernel container in its own QEMU/KVM VM using urunc⁠. The pod remains a Kubernetes pod and can be exposed through a Service like other workloads.

Important

unikernel is a tech preview. It currently supports only the configurations and workloads described on this page. Review the tech preview limits before using it.

Schedule unikernel pods on bare-metal nodes 

QEMU requires hardware virtualization (KVM). On Hetzner, the unikernel runtime class schedules pods only on bare-metal nodes where Syself detects hardware virtualization.

The runtime class selects nodes with the platform label autopilot.syself.com/virtualization: kvm. See .

If your cluster has no nodes with this label, unikernel pods remain Pending. See to add eligible nodes.

Use a unikernel OCI image 

The container image must package a unikernel as an OCI image. It is not a regular container image with a filesystem and entrypoint. urunc reads the boot configuration from the image's /urunc.json file or its image labels.

urunc supports Unikraft, MirageOS, and Linux guests running on QEMU. Images built for other monitors, such as Firecracker or Solo5, do not work. Images that require a shared filesystem through virtiofs are also unsupported.

Only the unikernel container runs inside the VM. Other containers in the pod, such as sidecars, run as regular containers on the node's shared kernel. They do not receive the pod's network traffic, which is directed to the unikernel VM.

Run a unikernel 

This example runs nginx as a Unikraft unikernel using an image published by the urunc project. A Service exposes it on port 80.

unikernel-nginx.yamlyaml
				apiVersion: v1
kind: Pod
metadata:
  name: nginx-unikernel
  labels:
    app: nginx-unikernel
spec:
  runtimeClassName: unikernel
  containers:
    - name: nginx
      image: harbor.nbfc.io/nubificus/urunc/nginx-qemu-unikraft-initrd@sha256:12d9be606ec578e080383649473c87431f8062b7d106b3cfff44ed2bf6e0e5eb
      ports:
        - containerPort: 80
      resources:
        requests:
          cpu: 100m
          memory: 256Mi
        limits:
          memory: 256Mi
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-unikernel
spec:
  selector:
    app: nginx-unikernel
  ports:
    - port: 80
      targetPort: 80
			

Apply the manifest and wait for the pod to become Ready:

				$ kubectl apply -f unikernel-nginx.yaml
$ kubectl wait --for=condition=Ready pod/nginx-unikernel --timeout=180s
			

Other pods in the namespace can reach nginx at http://nginx-unikernel. The first start takes longer than a regular container because the node must pull the image and boot the VM.

Size the VM with container resources 

The unikernel VM's memory is determined by the container's memory limit:

  • If the container has a memory limit, the VM gets that amount of RAM.
  • If it has no memory limit, the VM gets 256 MiB.

Set a memory limit to control the VM's RAM. Set the memory request to the same value so the Kubernetes scheduler reserves the corresponding memory.

QEMU runs inside the pod's cgroup, so the pod's memory limit applies to both QEMU and the guest. The unikernel runtime class adds 100m CPU and 64Mi memory of pod overhead to account for the runtime.

The VM is sized when the container starts. Changing the pod's resource settings does not resize a running VM.

Tech preview limits 

The unikernel runtime class currently has these limitations:

  • QEMU only: The VM monitor is always QEMU. Images that require Firecracker or Solo5 do not start.
  • One vCPU: Each VM gets one vCPU, regardless of the container's CPU requests or limits.
  • One unikernel per pod: Run at most one unikernel container in a pod. A second unikernel container starts in its own VM but does not receive network traffic.
  • No kubectl exec: Exec does not work in any container in a unikernel pod, including sidecars. Exec probes also fail. A container using an exec readiness probe never becomes Ready. Use an httpGet probe instead.
  • Image configuration only: Pod annotations are not passed to urunc. Configure boot options in the image's /urunc.json file or image labels.
  • Bare metal with KVM: Unikernel pods cannot run on cloud nodes or bare-metal nodes without detected hardware virtualization.