Skip to content
All projects

Security · 2026

Sandboxed Workloads with gVisor

The operator launches whatever container image a QueueWorker names, which is exactly when sharing the host kernel stops feeling comfortable. gVisor puts a second kernel in the way, and the choice is a field on the CRD rather than a separate cluster.

A container feels like a box, but it is really just a process with some namespaces around it. It makes system calls directly to the host kernel, the same kernel every other pod on that node is using. The isolation is only as strong as the kernel’s syscall surface — which is large, and occasionally has holes.

gVisor changes the shape of that risk. It runs a second, much smaller kernel called the Sentry in user space, written in Go. The workload’s syscalls are answered by the Sentry, and the Sentry itself only makes a narrow, carefully chosen set of real calls to the host.

The problem it solves

In this system the operator is deliberately generic: a QueueWorker names a container image and the controller runs it, with no idea what the code inside does. That is the feature — it is what lets one operator serve any number of unrelated queues.

It is also the problem. The moment the image is something you did not write — a tenant’s plugin, a third-party processor — “it shares the host kernel with everything else on this node” is no longer a comfortable sentence.

How it works

① trusted pod no runtimeClassName ① worker Job runtimeClassName: gvisor ② containerd picks a handler ③ gVisor Sentry answers syscalls ④ host kernel runsc
Only the sandboxed path goes through the Sentry. Redis and the monitoring stack deliberately stay on the default runtime.

What happens at each hop:

  1. The pod asks for a runtime. A runtimeClassName on the pod spec is a request for a named RuntimeClass. Leave it off and you get the cluster default. In this project the field travels from the QueueWorker CR, through the chart, onto the Job’s pod template.
  2. containerd routes it. The gvisor RuntimeClass maps to the runsc handler, so containerd starts that pod with gVisor instead of runc.
  3. The Sentry intercepts. The container’s syscalls are serviced inside the Sentry rather than by Linux. Most of the kernel surface the workload could previously reach simply is not there any more.
  4. A narrow path reaches the host. The Sentry makes a restricted set of real syscalls — that remaining surface is the actual attack surface, and it is dramatically smaller than the full kernel ABI.

Crucially this is per-pod, not per-cluster. Untrusted workers run sandboxed while Redis, the operator and the monitoring stack keep full performance on the default runtime.

The detail that bites

The field is a *string, not a string, and that distinction is load-bearing:

func runtimeClassNameOrNil(name string) *string {
	if name == "" {
		return nil
	}
	return &name
}

Kubernetes validates runtimeClassName as a DNS name whenever the field is present, so an empty string is rejected at admission rather than read as “no preference”. Only nil means “use the cluster default”. Without this helper, every pod that simply did not opt in would fail to be created at all.

What I would tell you before adopting it

The Sentry implements a subset of Linux, and the things that break are rarely the application — they are the tools around it. In this project kubectl port-forward stopped working against sandboxed pods: it dials the pod’s network-namespace loopback, but a gVisor pod’s sockets live in runsc’s userspace netstack. Traffic to the pod IP works; loopback does not. The fix was a NodePort Service for local access.

There is a throughput cost too, concentrated in syscall- and I/O-heavy workloads. So this is not a cluster-wide default — it is a boundary you draw around the specific code whose behaviour is not yours.

The CRD field, the Job builder and the chart plumbing are in the repo.