Syself Autopilot ships several runtime classes. A workload can select the runtime class that fits it. This page describes what each one is, when to use it, how to set it, and how a `secure` pod's virtual machine is sized. ## What is a runtime class? A [RuntimeClass](https://kubernetes.io/docs/concepts/containers/runtime-class/) is a Kubernetes object that selects the runtime a pod runs on. Syself Autopilot ships `standard`, `runc`, `secure`, and, as a tech preview, `unikernel`. A pod picks one with the `runtimeClassName` field, and a pod that sets nothing runs on `standard`. | Runtime class | Runtime | Isolation | Runs on | | ------------- | --------------- | -------------------------------- | --------------------------------------------- | | `standard` | crun (default) | shared node kernel | every node | | `runc` | runc | shared node kernel | every node | | `secure` | Kata Containers | one VM per pod, own guest kernel | bare-metal nodes with hardware virtualization | | `unikernel` | urunc (preview) | one VM per unikernel container | bare-metal nodes with hardware virtualization | ## Container runtimes ### `standard` `standard` is the default runtime class. Behind it is crun, an OCI runtime written in C. Syself uses crun because it starts containers faster and uses less memory per container than runc. It runs on every node type, cloud and bare metal. Most workloads use the `standard` runtime class by default. Unless a workload has a specific reason to change, such as an image that misbehaves on crun or code that needs VM isolation, leave it there. ### `runc` `runc` is the reference OCI runtime, the one most Kubernetes clusters run by default. On Syself Autopilot it is a fallback. A small number of container images behave differently on crun, and `runc` exists for those cases. Like `standard`, it shares the node's kernel and runs on every node type. Use `runc` when a specific image does not start or misbehaves under `standard`. A third-party image built and tested only against runc, for example, might fail on crun. Setting `runtimeClassName: runc` runs it on the runtime it expects, without changing anything else about the workload. ### `secure` `secure` runs each pod in its own virtual machine with its own kernel, using Kata Containers. If a process escapes the container it stays inside that VM and cannot reach the host or a neighbouring pod, even through a kernel-level bug. This is a stronger boundary than the shared-kernel runtimes, and it costs more, because each pod carries the VM's startup time and a fixed amount of CPU and memory overhead. Kata needs hardware virtualization (KVM), which on Hetzner exists only on [bare-metal nodes](/docs/hetzner/apalla/servers-and-nodes/bare-metal/add-bare-metal-servers), so `secure` pods do not schedule on cloud VMs. The runtime class carries its own node selector, so a `secure` pod with no capable node stays `Pending` instead of falling back to a shared kernel. A `secure` pod that also sets `hostNetwork: true` starts but has no network. Its VM gets only a loopback interface, so nothing can reach it. A `privileged` pod starts too, but its privileges stay inside the VM and it gets none of the host's devices. Use `secure` for code you do not trust, such as third-party code. Size its memory limits with care, since they also size the VM. See [Size a secure pod](#size-a-secure-pod). ### `unikernel` (tech preview) `unikernel` boots each unikernel container in its own QEMU/KVM VM, using urunc. The image holds a unikernel, a single application compiled together with only the operating system parts it needs, instead of a regular container filesystem. It has the same hardware requirement as `secure`: it schedules only on bare-metal nodes with hardware virtualization. Use `unikernel` to try out unikernel images, such as a web server built with Unikraft, while keeping the pod's normal network and Services. It is a tech preview with known limits. See [Run unikernels](/docs/hetzner/apalla/workloads/runtime-classes/run-unikernels) before you use it. ## Select a runtime class Select a runtime class per workload with the `runtimeClassName` field on the pod spec. A pod that sets nothing runs on `standard`, so you set this field only to switch to `runc`, `secure`, or `unikernel`. ```yaml title="deployment.yaml" apiVersion: apps/v1 kind: Deployment metadata: name: app spec: replicas: 2 selector: matchLabels: app: app template: metadata: labels: app: app spec: runtimeClassName: secure # standard (default), runc, secure, or unikernel containers: - name: app image: nginx:stable resources: requests: memory: 1Gi limits: memory: 1Gi # also sizes the secure VM: 256 MiB + 1Gi ``` ## Size a secure pod A `secure` pod's VM is sized once, when the pod starts, from the pod's own limits. The VM starts with 1 vCPU and 256 MiB for its guest kernel. It adds the pod's memory limits and its CPU limits, rounded up to whole vCPUs, so a pod without CPU limits gets 1 vCPU. All containers of the pod share that one VM. Processes in a `secure` pod see only the VM, never the node. `nproc` and `/proc/cpuinfo` count the VM's vCPUs, and `free` and `/proc/meminfo` show the VM's memory minus 100 to 170 MiB that the guest kernel reserves, more for a larger VM. Each container's own memory limit still applies inside the VM. Pods on the shared-kernel runtimes, `standard` and `runc`, see the node's CPUs and memory in `/proc`, whatever their limits. Measured on a bare-metal node with 20 CPUs and 62.6 GiB of RAM: | Runtime class | Limits | VM size | CPUs the pod sees | Memory the pod sees | | ---------------------- | --------------------- | ----------------- | --------------------- | ------------------- | | `standard` | 1 CPU, 1Gi | no VM | 20 in `/proc/cpuinfo` | 62.6 GiB | | `secure` | 1 CPU, 1Gi | 2 vCPUs, 1280 MiB | 2 | 1167 MiB | | `secure` | 2500m CPU, 4Gi | 4 vCPUs, 4352 MiB | 4 | 4182 MiB | | `secure` | none | 1 vCPU, 768 MiB | 1 | 665 MiB | | `secure`, 2 containers | 512Mi and 1Gi, no CPU | 1 vCPU, 1792 MiB | 1 in each | 1672 MiB in each | The VM runs inside the pod's cgroup. The pod's memory limit caps the VM, and the kubelet counts the VM's memory as the pod's usage, which eviction uses. `kubectl top` shows only the processes inside the VM, so it reports far less than the pod uses. When a container goes over its memory limit, the kernel inside the VM OOM-kills the process that uses the most memory, not the whole container. ### Default memory limit A container without a memory limit adds nothing to the VM, so a `secure` pod where no container sets one would get a VM with only the 256 MiB base. To prevent that, Syself Autopilot sets a default when the pod is created: every container and init container of a `secure` pod that has no memory limit gets a limit of `512Mi`, or its memory request if that is larger. A container that sets its own limit keeps it, and pods of every other runtime class are not changed. The default is fixed. If a container in a `secure` pod needs more than 512Mi, set its memory limit explicitly. ### Pod overhead The `secure` runtime class declares a pod overhead of 250m CPU and 768Mi memory. Kubernetes adds it to the pod's requests when it schedules the pod and to the pod's cgroup limit, so it covers the VM's own processes and kernel memory on top of your containers' limits. Account for it when you plan how many `secure` pods fit on a node. That fixed overhead covers pods with memory limits up to about 40Gi. The VM's kernel memory grows by about 16 MiB per GiB of guest memory, so a larger `secure` pod can need more than the overhead reserves and risks its VM being killed when the guest's memory fills up. Keep `secure` pods at or below about 40Gi of memory limits. ### Node memory for secure pods Each `secure` pod's VM memory comes from the node's shared memory, so the VMs of all `secure` pods on a node must fit in it together. On nodes that run `secure` pods, shared memory is sized to 90% of the node's RAM, so `secure` pods can use all the memory the scheduler gives them. It does not give any pod more memory than its limit. ### Resizing a running pod Resizing a running `secure` pod in place does not grow its VM. The VM keeps the vCPUs and memory it started with, even if the pod's limits change. Kubernetes still reports the resize as done, and a raised memory limit takes effect on the container inside the VM, so the container can use memory up to what the VM has, but no more. Nodes that run `secure` pods use the kubelet's static CPU manager policy, so they refuse to resize a Guaranteed pod in place at all. To give a `secure` workload more CPU or memory, change its limits in the workload spec and let the pods be recreated, for example with a Deployment rollout. ### File writes count against memory A `secure` pod writes files through the node's page cache, and that cache is charged to the pod's memory limit. Nodes that run `secure` pods hold back writers once about 512 MiB of written data on the node waits for the disk, so a fast writer slows to disk speed instead of filling its pod's limit with unwritten data. For a write-heavy workload, leave headroom in its memory limit above what the application itself uses. ## Related - [Run unikernels](/docs/hetzner/apalla/workloads/runtime-classes/run-unikernels) - [Run a workload in a user namespace](/docs/hetzner/apalla/workloads/secure/run-in-a-user-namespace) - [Set security contexts](/docs/hetzner/apalla/workloads/secure/set-security-contexts)