
AI agents that can execute code create a distinct infrastructure problem: their work may include commands and dependencies no developer has inspected. On a laptop, that exposure may be contained to one machine. On shared Kubernetes infrastructure, a weak boundary can put the host node and other workloads in scope. The practical challenge is to choose an isolation level that fits the agent’s work, then control what the agent can reach inside that boundary.
Cluster policy can restrict system calls, but filtering alone doesn’t eliminate the risk that an allowed call reaches a kernel vulnerability. For teams running agents alongside other workloads, sandboxing therefore needs to be designed across the pod request, worker node, runtime, access policy and agent session. These layers can be assembled from community projects and familiar Kubernetes APIs rather than built as a proprietary stack. The same challenge has also surfaced among users of Oracle Cloud Infrastructure (OCI).
KubeCon + CloudNativeCon takes place in Salt Lake City, Utah, from November 9 to 12. Register now.

Runtime choice sets the isolation boundary

The first decision is how much separation the workload needs from the host kernel. The options described here range from a conventional container using runc, through the user-space kernel in gVisor, to the virtual-machine boundary provided by Kata Containers. Security, performance, compatibility and operational cost vary with that choice.
With runc, containers share the host kernel. Seccomp filters can limit which system calls a process may make, while Linux namespaces separate its views of processes, filesystems and networks, and cgroups manage resource use. This approach offers the strongest performance of the three, but the host kernel remains part of the workload’s security boundary.
gVisor takes a different route: its Sentry application kernel handles workload system calls in user space, and a Gofer process mediates access to host-backed files. That narrower interface can suit workloads that don’t require a full guest kernel. gVisor implements a subset of Linux, which supports quick startup and dense packing, but it can also constrain applications to the interfaces Sentry provides. For agents that dynamically select tools and packages, compatibility needs to be checked against the work they’ll actually perform.
Kata runs each pod inside a lightweight virtual machine with its own guest Linux kernel. Hardware-backed virtualization separates that kernel from the host, and the broader Linux environment can accommodate activities such as package installation, compilation, nested builds and headless browsers. The tradeoff is the cost of starting a VM and allocating memory to its guest kernel and supporting components. A separate guest kernel can avoid incompatibilities that arise when system-call emulation falls short, but it also creates another kernel to operate and patch.
Node support determines what can run

The runtime choice has consequences beyond the pod specification. Every eligible worker node must have the corresponding runtime installed and configured. A cluster that exposes a sandbox option without suitable nodes can’t schedule workloads to it reliably.
For runc, the node needs a container runtime such as containerd configured to use the standard runtime. It doesn’t need a guest kernel or hypervisor. gVisor requires its runtime to be installed and integrated with containerd on nodes that will run those pods. Its Sentry and Gofer processes then provide the workload’s system-call and file-access paths.
Kata adds a larger set of node requirements. In a KVM setup, the node needs a Kata runtime shim, a supported virtual machine monitor, KVM and hardware virtualization. It also needs a guest kernel and image that include kata-agent. Nodes may be bare metal or virtual machines that support nested virtualization. The guest image requires maintenance; a kernel vulnerability can mean patching both the host and guest kernels. That workload can be justified when flexibility and a stronger boundary are priorities, but it should be accounted for as part of the operating model.
Access policy limits what a sandbox can affect
A sandbox limits the agent’s relationship with the host; it doesn’t automatically protect everything exposed to the agent. Code inside the pod may still delete a writable repository, read a mounted secret or send data to an allowed network destination. The sandbox boundary and the permissions granted within it need to work together.
- Network: Start with default-deny egress through a
NetworkPolicy, then permit the specific destinations a task needs, such as a package mirror or model endpoint. - Credentials: Use short-lived credentials scoped to the task instead of mounting long-lived tokens. If a credential is exposed, its useful lifetime ends with the task.
- Storage: Mount repositories and data read-only where possible. Give tasks that need to write a separate workspace volume.
- Remote tools: Apply authorization to API endpoints and MCP servers independently. These services run outside the sandbox, so the pod’s isolation boundary doesn’t govern their access.
These controls address different paths out of the workload. A VM boundary won’t narrow an overly broad credential, and a restrictive network policy won’t stop an agent from damaging a writable directory. Treating access as its own layer makes the combined design more useful for real agent tasks.
RuntimeClass connects pod intent to node configuration
Kubernetes RuntimeClass lets a pod request a particular runtime while keeping the standard Pod API. Platform teams can expose runtimes such as Kata or gVisor for workloads that need them, while pods that omit runtimeClassName continue to use the default runtime. This lets teams apply additional isolation selectively instead of adding its resource cost to every workload.
Administrators configure a RuntimeClass to match a runtime handler on the nodes, set scheduling constraints and describe fixed pod overhead. That overhead matters: gVisor’s Sentry processes and Kata’s guest kernel, kata-agent and VMM consume resources beyond the application containers. Including measured overhead helps Kubernetes account for capacity when scheduling pods and enforcing quotas. The sample values below are examples, not defaults; teams should measure their workloads.
apiVersion: node.k8s.io/v1
kind: RuntimeClass
metadata:
name: kata
handler: kata # runtime name in the node's containerd config
overhead:
podFixed:
memory: "160Mi" # example value; measure your own
cpu: "250m"
scheduling:
nodeSelector:
sandbox.example.com/kata: "true"
A pod opts in through the runtimeClassName field of its spec:
apiVersion: v1
kind: Pod
metadata:
name: agent-task
spec:
runtimeClassName: kata # or gvisor; omit for the default runc
containers:
- name: workspace
image: python:3.12
RuntimeClass makes the workload’s choice explicit and gives the scheduler information about where it can run and what capacity it needs. A cluster can publish each configured runtime as a separate class, while other workloads retain their existing pod configuration.
Session management handles bursty agent work
Agent tasks often alternate between active execution and pauses while a model or person supplies the next instruction. Keeping a VM alive during a long pause makes resumption easier but holds capacity. Deleting it frees resources, but the environment must be created again when work resumes. Warm pools can reduce that wait, at the cost of keeping spare capacity available.
The Agent Sandbox project, owned by Kubernetes SIG Apps, addresses this session-level problem. Its Sandbox API provides stateful, single-pod environments with stable identities and persistent storage, alongside extensions for templates, claims and warm pools. It doesn’t prescribe the isolation runtime: that remains the responsibility of the selected RuntimeClass.
That division is useful for platform design. RuntimeClass selects how the pod is isolated and scheduled; Agent Sandbox provides a way to manage the agent’s working environment across its session. Frameworks that integrate with the Sandbox API can use a shared Kubernetes interface, while the underlying runtime remains a separate platform choice.
Build the boundary as a stack
There isn’t one setting that makes autonomous code safe to run on shared infrastructure. The runtime determines the kernel boundary, node configuration makes that runtime available, access policy limits what the agent can touch, RuntimeClass ties workload requests to cluster capacity, and session management handles pauses between bursts of work. Each layer closes a different operational gap.
Open-source Kubernetes components let platform teams assemble these controls using existing tools and portable pod specifications. For agent workloads, the useful design question is how much isolation the code needs, what compatibility it requires, and what node and session costs the team can sustain. Answering those questions workload by workload gives teams a practical path to running untrusted code without treating every pod as if it had the same risk or resource profile.
The post The 5 essential layers of AI agent sandboxing on Kubernetes appeared first on The New Stack.