Published
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.
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.
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.
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.
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.
Subscribe to The Syselfer, our newsletter, or add the RSS feed to your reader.
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.
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:
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./urunc.json file or OCI labels.unikernel pods cannot schedule on cloud nodes.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.
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.
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.
Start with a trial, and our step-by-step guides will walk you through your first cluster deployment in minutes.
Tags
We set up the Spegel peer cache on a Syself Autopilot 1.37 cluster and tested where images come from during pulls, node drains, a registry outage and a new node joining.
1.36 rebuilds the node OS as Syself Linux, installs nodes with a new provisioner, and runs Syself's own failover proxy, tunnel, and KubeGate for the control-plane path. Read the highlights, the full notes by area, and the upgrade steps.
Syself Autopilot 1.36 runs an immutable Kubernetes node OS, built from source and then sealed and verified block by block, so you can prove what a node runs.