Skip to main content
InfraGap.com Logo
Home
Getting Started
Core Concept What is a CDE? How It Works Benefits CDE Assessment Getting Started Guide Inner Loop vs Outer Loop Environment Drift Local vs Cloud CDEs for Startups
AI & Automation
AI Coding Assistants Agentic AI AI-Native IDEs Agentic Engineering AI Agent Orchestration AI Governance AI-Assisted Architecture Shift-Left AI LLMOps Autonomous Development AI/ML Workloads CDEs for Data Science GPU Computing
Agent Infrastructure
Agent Experience (AX) Agent Egress Control Computer Use Agents Agent Evals Agent Runbooks Agent Client Protocol AGENTS.md MCP Servers Git Worktrees Kubernetes Agent Sandbox Agent Fleets Agent Identity Prompt Injection Defense Agent Observability Context Engineering AI Code Review Bottleneck Headless Agents in CI Spec-Driven Development Agent Readiness Code Provenance
Implementation
Architecture Patterns DevContainers Advanced DevContainers Language Quickstarts IDE Integration CI/CD Integration Platform Engineering Developer Portals Container Registry Multi-CDE Strategies Remote Dev Protocols Nix Environments Hermetic Builds OpenTofu for CDEs Kubernetes Development
Operations
Performance Optimization High Availability & DR Disaster Recovery Monitoring Capacity Planning Multi-Cluster Development Troubleshooting Runbooks Ephemeral Environments Sandbox Environments Workspace Snapshots Database Branching
Security
Security Deep Dive Zero Trust Architecture Secrets Management Vulnerability Management Network Security IAM Guide Supply Chain Security Air-Gapped Environments AI Agent Security MicroVM Isolation Compliance Guide EU AI Act Cyber Resilience Act Data Residency Governance
Planning
Pilot Program Design Stakeholder Communication Risk Management Migration Guide Cost Analysis FinOps GreenOps Vendor Evaluation Training Resources Developer Onboarding Team Structure Platform Maturity Model Open Source CDEs AI Productivity Paradox Build vs Buy DevEx Metrics Productivity Engineering Industry Guides CDEs for Healthcare CDEs for Financial Services CDEs for Government Edge Development WebAssembly in CDEs
Resources
Tools Comparison State of CDEs 2026 Isolation Decision Tool Template Library
Learning Paths
All Paths Platform Engineer Security and Compliance Engineering Manager
Vendor Reviews
GitHub Codespaces Coder Ona Google Workstations Microsoft Dev Box Okteto Eclipse Che DevPod Daytona E2B
Head to Head
Coder vs Codespaces Coder vs Ona Ona vs Codespaces Coder vs Okteto Self-Hosted vs Managed E2B vs Daytona CDE Market Guide CDE vs Alternatives Case Studies Lessons Learned Glossary FAQ Sources & Citations

Kubernetes Agent Sandbox - The Sandbox CRD Explained

A Kubernetes-native primitive for agent workloads. Sandbox, SandboxTemplate, SandboxClaim and SandboxWarmPool, plus the runtimes that isolate them.

Why a Pod Was Not Enough

Kubernetes workload types were designed for long-lived services, and an agent sandbox is almost the opposite of one

Every existing Kubernetes workload type encodes an assumption about lifetime. A Deployment assumes a fungible replica set that should be kept running and replaced when it dies. A StatefulSet assumes ordered, stable identities that persist across restarts. A Job assumes a batch task that runs to completion and is then garbage collected. Each of those is a reasonable model for a service or a pipeline. None of them is a good model for an AI agent's execution environment.

An agent sandbox has an awkward combination of properties. It is short-lived, often measured in minutes. It is created on demand, at a rate driven by developer or agent activity rather than by a deployment rollout. It is stateful for its lifetime, because the agent has a working directory it expects to persist across the many tool calls of a session, and it wants a stable address so a controller can talk to it. It runs code that was generated rather than reviewed, so it must be strongly isolated. And because sessions start constantly, cold start time is a product-level concern rather than an operational detail.

Teams have been assembling this from parts for a while: a StatefulSet per session, a bespoke controller, a home-grown pool of idle pods, a RuntimeClass wired in by hand. The Kubernetes SIG project agent-sandbox is an attempt to standardize that assembly into a small set of custom resources. It sits on the isolation ladder above a plain container and below a dedicated microVM, and it is the newer, standardized expression of the patterns described on sandbox environments.

What a Service Workload Assumes

  • Long lifetime, measured in days or weeks
  • Created by a rollout, not by user demand
  • Replicas are interchangeable
  • Startup latency amortized over the lifetime
  • Runs code that passed review and CI

What an Agent Sandbox Assumes

  • Short lifetime, often minutes
  • Created on demand at high rate
  • Each one belongs to a specific session
  • Startup latency is felt on every task
  • Runs generated, unreviewed code

The Four Resources

Sandbox, SandboxTemplate, SandboxClaim and SandboxWarmPool, and how they compose

Sandbox

The core resource. The project documentation describes it as a "Declarative API for a single, stateful pod with a stable hostname and optional persistent storage." That sentence is the whole design: one pod, not a replica set; stable identity so a controller can address the session reliably; storage that survives the many tool calls within a session. This is the object an orchestrator creates when it wants one agent to have somewhere to run.

SandboxTemplate

A reusable runtime configuration. The platform team defines the image, the resource limits, the runtime class, the mounts, and the policies once; consumers reference the template by name. The documented purpose is to let teams provision sandboxes consistently without exposing the underlying complexity, which in practice means application teams stop hand-writing pod specs and the platform team keeps a single place to change the security posture.

SandboxClaim

The user-facing request. A claim asks for a sandbox from a template, and the controller satisfies it either by creating one or by handing over a pre-warmed instance from a pool. The pattern will be familiar to anyone who has used a PersistentVolumeClaim: the consumer expresses what it needs, the platform decides how that need is met, and the two are decoupled so pooling can be introduced without changing any caller.

SandboxWarmPool

The documentation describes it as "Pre-warmed pod pools for near-instant sandbox allocation." It exists because cold start dominates short tasks: pulling an image and initializing a workspace can easily exceed the runtime of the task itself. Warm capacity is billed continuously whether or not anything claims it, so pool depth is a direct budget decision, discussed further under agent fleets.

How They Compose

Platform team defines once
  SandboxTemplate  (image, limits, runtimeClass, policy)
       |
       +-- SandboxWarmPool  (keeps N ready instances of that template)
       |
Agent orchestrator asks per session
  SandboxClaim  (please give me one of those)
       |
       \-- Sandbox  (a single stateful pod, stable hostname, storage)

The important property is that the claim does not care whether it was satisfied from a warm pool or by a cold creation. You can add pooling, remove it, or change its depth without touching the orchestrator, which is exactly the seam you want when you are still learning what your arrival rate looks like.

A Minimal Sandbox

The smallest useful manifest is a pod template wrapped in the Sandbox kind. The project's README examples use the agents.x-k8s.io/v1beta1 API group and version, and the documentation includes a migration guide covering the move from v1alpha1 to v1beta1. Confirm the group version against the release you install rather than copying it from any article, including this one.

apiVersion: agents.x-k8s.io/v1beta1
kind: Sandbox
metadata:
  name: agent-session-4f21
  namespace: agent-sandboxes
spec:
  podTemplate:
    spec:
      runtimeClassName: gvisor
      containers:
        - name: workspace
          image: registry.internal/agent-workspace:2026-07
          resources:
            requests:
              cpu: "2"
              memory: 4Gi
            limits:
              cpu: "4"
              memory: 8Gi

The template and claim pair below shows the shape of the platform-team split. Treat the field names as illustrative of the pattern rather than as a copy-paste manifest: verify them against the CRDs shipped with the version you deploy, because the API is still moving.

# Defined once by the platform team
apiVersion: agents.x-k8s.io/v1beta1
kind: SandboxTemplate
metadata:
  name: coding-agent-standard
  namespace: agent-sandboxes
spec:
  podTemplate:
    spec:
      runtimeClassName: gvisor
      automountServiceAccountToken: false
      containers:
        - name: workspace
          image: registry.internal/agent-workspace:2026-07
          resources:
            limits:
              cpu: "4"
              memory: 8Gi
---
# Requested per session by the orchestrator
apiVersion: agents.x-k8s.io/v1beta1
kind: SandboxClaim
metadata:
  name: claim-4f21
  namespace: agent-sandboxes
  labels:
    team: team-payments
    costCenter: eng-platform
spec:
  sandboxTemplateName: coding-agent-standard

Two habits are worth building in from the start. Put sandboxes in their own namespace so quotas, network policy, and RBAC apply to the whole class of workload at once. And label every claim with the team and cost center that triggered it, because attribution applied at creation is the only kind that survives to the bill.

Runtimes and Isolation Strength

The CRD gives you a declarative object. The runtime class is what decides how strong the boundary actually is.

A Sandbox is still a pod, and a default pod shares the node's kernel. The project's design notes describe supporting different runtimes such as gVisor or Kata Containers to provide enhanced security, and the documentation lists standard OCI containers, gVisor for kernel-level sandboxing, and Kata Containers for VM-grade isolation. Which one you get is a function of the runtimeClassName on the pod template, not of the Sandbox kind itself. Creating a Sandbox with no runtime class buys you the ergonomics without the isolation.

This is the single most important thing to get right on the page. The declarative API and the isolation boundary are separate decisions that happen to be expressed in the same manifest, and it is entirely possible to adopt the CRD, feel more secure, and be running exactly the same shared-kernel containers you were running before.

Runtime Choices Under the Sandbox CRD

RuntimeMechanismIsolation strengthMain costBlast radius
Standard OCI (runc)Namespaces and cgroupsBaselineNone beyond the podThe node's shared kernel
gVisorUser-space kernel intercepting syscallsStrong syscall boundarySyscall compatibility gaps, I/O overheadThe gVisor sentry, not the host kernel directly
Kata ContainersLightweight VM per pod, own guest kernelVM-gradeRequires KVM-capable nodes, slower startOne virtual machine

Runtime characteristics are covered in depth on microVM isolation. Availability of a given runtime class depends on your node pools and your Kubernetes distribution, so confirm before designing around one.

The Runtime Is Necessary but Not Sufficient

A hardened runtime constrains what code inside the sandbox can do to the node. It does nothing about what that code can reach over the network, what secrets are mounted into it, or what a service account token lets it do to the cluster API. Network policy, egress allowlists, disabled service account token automounting, and dedicated node pools are all separate decisions you still have to make. Northflank's explainer puts the general limitation well: "Agent sandbox provides the isolation primitive and the declarative API, but not the surrounding production infrastructure your platform needs."

Snapshots and Warm Start

Attacking cold start from both ends: keep capacity ready, and restore initialized state instead of rebuilding it

Cold start is the defining performance problem for agent sandboxes, because the work being done is often short enough that setup dominates. Pulling an image, mounting storage, installing dependencies, and warming a language server can take longer than the change the agent was asked to make. Warm pools address part of this by keeping capacity provisioned in advance, but a pool member is only warm in the sense of being scheduled and running: it has not read your repository or installed your dependencies.

Snapshots attack the other half. Google Kubernetes Engine documents Pod snapshots for Agent Sandbox, which save and restore the state of a running sandbox, enabling pre-warmed snapshots, pause and resume for long-running agents, and reproducibility by capturing an initialized state. The restored sandbox comes back with dependencies installed and caches populated, which is a categorically different starting point from a freshly scheduled pod.

Pause and Resume

A long-running agent that is blocked, waiting on a human, or waiting on an external system does not need to hold compute. Snapshotting it and restoring later converts held capacity into stored state, which is generally the cheaper of the two.

Reproducible Starting Points

A snapshot taken after setup gives every session an identical, known-good baseline. That removes a whole class of "it failed because the install was flaky" outcomes, which matters because failed attempts are billed exactly like successful ones.

Constraints Apply

GKE documents that Pod snapshots require "GKE version 1.35.3-gke.1234000 or later" and states plainly that "Pod snapshots don't support E2 machine types," with further limitations on GPU machine types. Check the node pool before designing around snapshots.

Snapshot Support Is Still Landing

GKE's own guide describes its installation path as provisional: the tutorial "uses a manual installation method to deploy the Agent Sandbox components directly from the open-source GitHub repository," and calls that "a temporary workaround until the snapshot features are fully available in the GKE Agent Sandbox add-on." Read that as a feature in motion. It is worth prototyping against and worth being careful about committing a platform roadmap to.

Maturity: Read This Before You Depend On It

What the project claims about itself, and what it does not

The agent-sandbox repository does not carry an explicit maturity label such as alpha, beta, or stable, and it makes no statement about production readiness or stability guarantees. It describes itself as a community-driven effort. The strongest available signal about API stability is the API version itself: the README examples use agents.x-k8s.io/v1beta1, and the documentation includes a migration guide for moving from v1alpha1 to v1beta1. Third-party explainers written earlier still show v1alpha1 manifests, which is a useful reminder of how recently that changed.

The honest summary is that this is a young standardization effort with a documented breaking API change already behind it, backed by a Kubernetes SIG and with at least one managed platform building on it. That is a genuinely promising position, and it is not the same thing as a stable API you should hard-code into a platform. Anyone stating otherwise is filling in a claim the project has not made.

Reasonable Today

  • Prototyping an agent execution platform
  • Replacing a home-grown pod controller
  • Adopting the resource model as a design vocabulary
  • Internal, single-tenant workloads

Approach With Care

  • Externally facing multi-tenant platforms
  • Anything with a compliance attestation attached
  • Manifests generated by tools you cannot re-run
  • Roadmaps that assume snapshot GA dates

Practical Hedges

  • Pin the controller version explicitly
  • Generate manifests, do not hand-maintain them
  • Keep a fallback path to plain pods
  • Re-read the CRDs on every upgrade