Skip to main content
Resources

Unikernel Runtime (Tech Preview): Containers with Their Own Kernel

Published

Unikernel Runtime (Tech Preview): Containers with Their Own Kernel
Note

This resource is part of the Syself Autopilot 1.37 release. For the whole picture, see what's new in 1.37.

Unlike regular containers, unikernels don't share the node's kernel. Each unikernel boots with its own kernel in a dedicated virtual machine (VM), running only the application and the operating system components it needs. There is no general-purpose Linux userspace, shell or package manager.

A kernel exploit in a regular container can affect other containers sharing the same node kernel. Giving each workload its own kernel boundary reduces this risk. The secure runtime class also provides a separate kernel by running regular containers inside lightweight VMs. The new unikernel runtime takes this further by running a purpose-built image with only the components its application needs. This reduces the amount of code exposed to potential attacks, and the pod overhead stays lower than with secure.

With Syself Autopilot 1.37, you can try this approach using the new unikernel RuntimeClass, available as a tech preview. It boots OCI-packaged unikernels in their own QEMU/KVM VMs on bare-metal nodes. Despite running in separate VMs, they remain Kubernetes pods, so Services, networking and network policies continue to work as usual.

Why use unikernels? 

Many container images include a full Linux userspace, including libraries, a shell and package tools. Most of this code is never used by the application, but it remains part of the environment that could be exploited. Every reachable library adds to the attack surface.

A unikernel leaves all of that out, so an attacker has much less code to work with.

There are trade-offs. You must build the image for urunc, the runtime behind this class. The image must contain a unikernel from a framework such as Unikraft or MirageOS, or a Linux guest. You also cannot use kubectl exec or exec probes in a unikernel pod.

How it works on Syself Autopilot 

The unikernel RuntimeClass uses urunc, which boots unikernel images in QEMU/KVM. When a pod uses runtimeClassName: unikernel, containerd passes the container to urunc instead of crun, the default runtime. urunc checks the image's /urunc.json file or OCI labels to determine how to boot it. It then starts a QEMU VM for the container.

The pod keeps its normal Kubernetes network. urunc passes traffic reaching the pod to the VM, so the unikernel uses that network. Cilium, Services and network policies work as they do for other pods.

Sidecars can still start if their images do not contain a /urunc.json file or urunc labels. However, they run as regular containers on the node's shared kernel and do not get network access. Traffic to the pod goes to the VM, not the sidecars. If you need a log shipper, proxy or another networked sidecar, run it in a separate pod.

The RuntimeClass uses the node selector autopilot.syself.com/virtualization: kvm, just like the secure runtime class. This means unikernel pods can run only on bare-metal nodes where the platform has detected hardware virtualization. If your cluster has no such node, the pod stays Pending.

Try it out 

The following example runs nginx as a Unikraft unikernel built for QEMU. The urunc project publishes this image with its files packed into an initrd, which the VM loads at boot.

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
			
				$ kubectl apply -f unikernel-nginx.yaml
$ kubectl wait --for=condition=Ready pod/nginx-unikernel --timeout=180s
			

The VM uses the container's memory limit as its RAM. If no memory limit is set, it gets 256 MiB. Set the memory request to the same value so the scheduler reserves the full amount. The RuntimeClass also adds 100m CPU and 64Mi memory of pod overhead for QEMU. This is in addition to the container's own resource requests and limits.

The first start includes pulling the image and booting the VM. Once the pod is running, other pods in the same namespace can reach nginx at http://nginx-unikernel.

Stay up to date

Subscribe to The Syselfer, our newsletter, or add the RSS feed to your reader.

RSS

What images can you use? 

A unikernel image must be packaged as an OCI image and contain either a /urunc.json file or OCI labels that tell urunc how to boot it. On Syself Autopilot, urunc boots Unikraft and MirageOS unikernels, as well as Linux guests, on QEMU. Images built for other VM monitors, such as Firecracker or Solo5, do not start.

A regular container image without a /urunc.json file or urunc labels still starts, but runs as a regular container without its own VM. The unikernel RuntimeClass alone does not turn an existing container image into a unikernel. The urunc project publishes pre-built images for workloads such as nginx. These are a good starting point for trying the runtime.

Tech preview limitations 

The runtime is ready to try and experiment with, but it is not yet intended for production workloads. Its behavior may change in later releases. Keep these limitations in mind:

  • QEMU only. Every unikernel boots on QEMU. Images that require Firecracker, Solo5 or a shared filesystem through virtiofs do not start.
  • One vCPU. Each VM gets one vCPU, regardless of the container's CPU requests or limits.
  • One unikernel per pod. Put at most one unikernel container in a pod. A second one boots in its own VM but gets no network.
  • No kubectl exec or exec probes. kubectl exec does not work in any container in a unikernel pod, including sidecars. Exec probes fail too. A pod with an exec readiness probe never becomes Ready. Use an httpGet probe instead.
  • Image configuration only. Pod annotations do not change how the image boots. urunc uses only the image's /urunc.json file or OCI labels.
  • Bare metal with hardware virtualization. unikernel pods cannot schedule on cloud nodes.

FAQ 

How is this different from the secure runtime? 

The secure runtime runs a regular container image inside a Kata Containers VM with its own guest kernel. The unikernel runtime boots an image that carries its own kernel. The unikernel runtime has lower pod overhead: 100m CPU and 64Mi memory, compared with 250m CPU and 768Mi for secure. However, its images must be built for urunc.

Can I run existing container images as unikernels? 

No. An image without a /urunc.json file or urunc labels runs as a regular container on the node's shared kernel. It does not get its own VM. Setting runtimeClassName: unikernel on an existing image therefore does not give it extra isolation.

You must package the application for urunc, either as a unikernel built with a framework such as Unikraft or as a Linux guest for QEMU. Start with one of the urunc project's pre-built images to see how this works.

What happens if my cluster has no bare-metal nodes with KVM? 

The pod stays Pending. The RuntimeClass requires the node label autopilot.syself.com/virtualization: kvm, which is available only on bare-metal nodes with hardware virtualization.

Ready to Build? Start a Trial

Start with a trial, and our step-by-step guides will walk you through your first cluster deployment in minutes.

Tags

Product UpdatesKubernetesInfrastructure