Agents

The Runtime Layer of Sandboxing: gVisor, Kata Containers, microVMs and Docker Sandboxes (sbx)

November 15, 2026 Kubezilla Team 6 min read

This post is part of the Kubezilla sandboxing series: Part 1: The two layers · Part 2: The cluster layer · Part 3: The runtime layer and Docker Sandboxes.

In Part 2 we locked down what an agent is allowed to reach. That is the cluster layer. This post covers the second layer: the runtime layer. It answers a harder question: if the code inside the sandbox is hostile, can it reach the host?

Why containers alone are not a sandbox

A normal container (runc) is a Linux process with namespaces, cgroups, seccomp and capabilities applied. It is a good packaging and isolation tool. But every container on a node talks to the same host kernel. A kernel bug, a container runtime bug or a misconfiguration can let code walk out of the container and onto the node.

For code you wrote and reviewed, that risk is often fine. For code an LLM wrote a second ago, pulled from a random package, and ran without review, you want another wall.

Your runtime options

RuntimeHow it isolatesStartupGood for
runcNamespaces and cgroups on the shared host kernelFastestTrusted workloads
gVisor (runsc)A user space kernel handles system calls instead of the host kernelFastUntrusted code with low overhead
Kata ContainersEach pod runs in a lightweight VM with its own guest kernelSlower than containersStrong isolation with normal pod specs
Firecracker style microVMsMinimal VMs built for fast boot and high densityVery fast for a VMPer task or per session sandboxes at scale
Docker Sandboxes (sbx)One microVM per agent with its own kernel, plus a policy proxySecondsRunning coding agents safely, local or cloud

Choosing a runtime in Kubernetes with RuntimeClass

Kubernetes lets you pick a runtime per pod with a RuntimeClass. The node must have the runtime installed and configured in containerd or CRI-O. Then you define the class once:

apiVersion: node.k8s.io/v1
kind: RuntimeClass
metadata:
  name: gvisor
handler: runsc
scheduling:
  nodeSelector:
    workload: sandbox
---
apiVersion: node.k8s.io/v1
kind: RuntimeClass
metadata:
  name: kata
handler: kata
scheduling:
  nodeSelector:
    workload: sandbox

The scheduling.nodeSelector makes sure pods using that class only land on the sandbox node pool from Part 2. Using it in a pod is one line:

apiVersion: v1
kind: Pod
metadata:
  name: agent-task
  namespace: agent-sandbox-01
spec:
  runtimeClassName: gvisor
  containers:
  - name: agent
    image: your-registry/agent:1.0

On GKE, gVisor is available as GKE Sandbox. Kata is available on several distributions and can use QEMU, Cloud Hypervisor or Firecracker as its VMM. Check your provider before you build your own nodes.

gVisor or Kata?

  • Pick gVisor when you want low overhead and fast start, and your workloads use common system calls. Some apps that need unusual kernel features or heavy I/O may run slower or not at all.
  • Pick Kata when you want a real VM boundary with its own kernel and better compatibility, and you can accept a bit more memory and startup time per pod. Nodes need hardware virtualization support (bare metal or nested virtualization).
  • Pick a microVM platform when you need thousands of short lived sandboxes with VM level isolation.

The Agent Sandbox project

Writing pods by hand for every agent session gets old fast. The Agent Sandbox project from Kubernetes SIG Apps adds resources made for this:

  • Sandbox: a single stateful pod with a stable hostname and optional persistent storage.
  • SandboxTemplate: a reusable definition of the runtime and pod settings.
  • SandboxClaim: a simple way for users or agents to ask for a sandbox from a template.
  • SandboxWarmPool: pre started pods so a new sandbox is ready almost instantly.

Agent Sandbox is runtime agnostic. You set runtimeClassName in the pod template and choose gVisor or Kata underneath. A minimal Sandbox looks like this:

apiVersion: agents.x-k8s.io/v1alpha1
kind: Sandbox
metadata:
  name: coding-agent-01
  namespace: agent-sandbox-01
spec:
  podTemplate:
    spec:
      runtimeClassName: gvisor
      serviceAccountName: agent-runner
      automountServiceAccountToken: false
      containers:
      - name: agent
        image: your-registry/agent:1.0

Notice how the runtime layer (runtimeClassName) and the cluster layer (namespace, service account, no token) sit side by side in the same spec. That is the whole point of this series. The project is still alpha, so check the docs for the current API version before you use it in production.

Docker Sandboxes (sbx): both layers in one tool

Most agents start life on a developer machine, not a cluster. That is where Docker Sandboxes comes in. sbx is a standalone CLI that runs agents like Claude Code, Codex, Gemini CLI and others inside a microVM.

According to the Docker Sandboxes isolation docs, sbx stacks several protections:

  • Hypervisor isolation: each sandbox is its own microVM with a separate Linux kernel. Processes inside are not visible to the host or to other sandboxes. sbx rm deletes the VM and everything in it.
  • Network proxy and policy: each sandbox has its own network. All outbound TCP goes through a host side proxy, and a connection is allowed only when a policy rule matches. UDP is off by default and ICMP is blocked.
  • Workspace modes: mountless (no host files), direct mount (read write to your project), or clone mode, where the host repo is mounted read only and the agent works on a private clone you merge later.
  • Credentials outside the VM: the proxy adds API auth headers on the way out, so keys are not stored inside the sandbox.

Getting started is short:

# run Claude Code in a microVM with the current folder mounted
sbx run claude

# safer: let the agent work on a private clone of your repo
sbx run --clone claude .

# open egress only to what the agent needs
sbx policy allow network api.github.com

# see every allowed and blocked connection
sbx policy log

If you map this to the two layers, the microVM is the runtime layer, and the proxy, deny by default network policy, workspace mode and credential injection are a small local cluster layer. It is the same model you would build on Kubernetes, packed into one tool.

From laptop to cluster

A practical path many teams follow:

  • Develop agent workflows locally inside sbx, with a tight network allow list. The sbx policy log output tells you exactly which hosts the agent needs.
  • Turn that allow list into cluster policy: DNS aware NetworkPolicy or egress proxy rules in the agent namespace.
  • Pick a matching runtime in the cluster: gVisor or Kata through RuntimeClass, or Agent Sandbox with a SandboxTemplate.
  • Keep credentials outside: use short lived tokens, workload identity, or a gateway that injects keys, instead of putting raw API keys in pod env vars.

Runtime layer summary

The cluster layer limits what an agent can reach. The runtime layer limits the damage if the agent’s code turns hostile. Containers on a shared kernel are a weak runtime layer for LLM written code. gVisor, Kata, microVMs and Docker Sandboxes give you a real wall, and RuntimeClass and Agent Sandbox make that wall easy to use on Kubernetes.

Use both layers together. Start with Part 1 if you missed the overview, and Part 2 for the cluster layer YAML.

Further reading

Leave a comment