Skip to content

A Kubernetes driver: one isolated sandbox per session in a company's cluster #617

Open

Description

@fctl-sh

Organizations that run their workloads on EKS, GKE or AKS want fctl's agents in the same clusters: there they keep their networking, their node pools, their cost reports and their autoscaling. Today the host needs a machine with Docker, Apple's container, Lima or KVM (Firecracker). Kubernetes nodes have none of these to offer a pod, and running Docker inside a privileged pod gives up the isolation sandboxes exist for. So a company with a cluster has to run a separate fleet of VMs for fctl.

How it works now

  • Drivers. A host runs every sandbox with one driver, chosen by Driver::select (crates/fctl-host/src/driver/mod.rs):
    • process;
    • apple and docker, both ContainerDriver in container.rs, which runs the docker or container CLI;
    • firecracker (driver/firecracker/);
    • lima.
  • What a driver does. It pulls and checks images, creates a sandbox of a size, installs and starts fctl-agent in it, attaches to it over an exec channel with piped stdio (fctl-agent attach), runs scripts in it, stops it and keeps it for a resume, removes it, and lists what it has.
  • What the host tells FleetDO. It sends its driver's limits in its hello (HostHello.sandbox: the default size and the largest a sandbox may be), its images (allowed_images, allowed_builds) and whether its driver is ready.
  • Capacity. One host is one runner, with a fixed capacity of sessions at once.
  • Stopped sandboxes. They stay on the host's disk for keep_stopped_hours, so that a resume there continues Claude's conversation.
  • Isolation table. docs/architecture.md#sandboxes-and-drivers lists each driver's isolation: a VM per session (apple, firecracker, lima), containers (docker), none (process).

What has changed outside fctl (checked 2026-11-23)

  • kubernetes-sigs/agent-sandbox reached v1.0 in August 2026 (CRDs at agents.x-k8s.io/v1beta1; v1.0.12 on 2026-11-20).
    • A Sandbox is a singleton, stateful pod with its volumes.
    • operatingMode: Suspended deletes the pod but keeps the Sandbox and its volumes, and resuming starts a new pod on them.
    • SandboxTemplate, SandboxClaim and SandboxWarmPool keep sandboxes ready to hand out.
    • Plain kubectl exec works on its pods.
    • Google offers it on GKE as Agent Sandbox (generally available since May 2026), with gVisor, or Kata microVMs where nodes allow nested virtualization.
  • AWS Nitro Sandboxes (November 2026). On EKS, runtimeClassName: isolated-sandbox runs each pod in its own Firecracker microVM, enforced by the Nitro hypervisor and without nested virtualization. Exec and stdin work, privileged containers work inside the sandbox, and EBS and EFS volumes attach. It needs Kubernetes 1.36 or later and EKS Auto Mode or a sandbox-enabled AMI, and runs at most 5 sandboxes per node vCPU.
  • Karpenter (v1.15) adds nodes for pods that can't be scheduled. karpenter.sh/do-not-disrupt: "true" keeps consolidation away from a pod that works.

What should happen

  • A kubernetes driver. fctl host install --driver kubernetes, or the Helm chart below.

    • The host runs inside the cluster, as a Deployment of one replica, with a ServiceAccount that may manage sandboxes, pods, volumes and exec in one namespace.
    • FleetDO sees one runner whose capacity is how many sandboxes the cluster may run at once, from host.toml.
  • One sandbox per session. Each sandbox is a Sandbox of agent-sandbox where its CRDs are installed, or a Pod and a PersistentVolumeClaim where they aren't. It has:

    • the project's image;
    • resources.requests and limits from the session's CPUs and memory;
    • the cluster's isolation (runtimeClassName: gvisor, kata, isolated-sandbox, or none for trusted code, which the host's hello reports so docs/security.md's table can say it);
    • node selectors and tolerations for a node pool of its own;
    • labels with the workspace, project and session ids, for network policies and cost reports.
  • Stopping and resuming are suspending.

    • A stopped session's sandbox is suspended: the pod goes, freeing its node, and the volume with the home directory and the checkout stays for keep_stopped_hours.
    • A resume starts a new pod on that volume, so Claude's conversation and uncommitted work survive without a snapshot (Sessions keep their conversation and uncommitted work when they resume on another runner #616).
    • Zonal volumes (EBS, Persistent Disk) pin the new pod to the volume's zone, which the scheduler handles.
  • The agent channel. The host attaches to fctl-agent through the Kubernetes exec API: binary-safe stdin and stdout over WebSocket, through a Rust client such as kube-rs. fctl-agent's protocol and fctl-agent attach stay as they are. fctl-agent starts as the pod's main process, or through exec as with Docker.

  • Warm sandboxes. A SandboxWarmPool (or the host's own few spare pods) of the default image keeps a session's start to seconds rather than an image pull.

  • Nodes come and go with the cluster.

    • Working sandboxes carry karpenter.sh/do-not-disrupt: "true", and suspended ones drop it.
    • A sandbox that waits for a node is reported as such ("Waiting for the cluster to add a node", with how long), not as a failure. FleetDO counts it against capacity.
  • What the driver leaves out at first:

    • image builds from repositories (allowed_builds empty): projects use images from the organization's registry, ECR or Artifact Registry;
    • package caches, until a ReadWriteMany volume (EFS, Filestore) per project is designed;
    • pausing on low disk, since volumes have quotas instead.

    Each one says why in fctl host doctor.

  • A Helm chart (deploy/helm/fctl-runner): the host's Deployment, ServiceAccount and RBAC, the enrollment token as a Secret, the namespace for sandboxes with a default NetworkPolicy, and optional agent-sandbox templates and warm pool.

  • Docs:

    • docs/sandbox-images.md and docs/architecture.md#sandboxes-and-drivers (the driver's row and isolation);
    • docs/security.md (what a pod's ServiceAccount can reach: no token is mounted in sandboxes);
    • docs/self-hosting.md;
    • docs/llms.txt.

Notes on the design

  • No API access from sandboxes. Sandboxes get no Kubernetes API access (automountServiceAccountToken: false). Their pods run as a non-root user with the host's agent_as_root choice applied, and a NetworkPolicy that by default reaches the internet but not the cluster's services, which the organization can open.
  • Sizing. The largest sandbox the host announces (max_cpus, max_memory_mb) is the largest node in its node pool, minus the runtime's overhead (Nitro Sandboxes run about half the vCPUs of SMT instances).
  • Docker inside sandboxes (for agents that run docker compose in tests) works only where the isolation allows privileged containers inside it, as Nitro Sandboxes do. Elsewhere fctl host doctor and the project's image docs say so.

Design and UX

Running agents in a cluster should feel as simple as helm install, then watching the first session's sandbox appear, and the setup should say plainly how isolated each session is.

  • On the Runners tab, a cluster runner shows as one runner with a cluster's facts:

    • "Kubernetes on acme-prod (eks, us-east-1) · isolated-sandbox microVMs · 12 of 100 sandboxes running · 3 suspended";
    • with its node pool and warm pool in words;
    • and a driver problem in amber with what to do ("The ServiceAccount can't create pods in fctl-sandboxes: apply the chart's RBAC").
  • The setup steps follow the Runners tab's pattern (docs/web-app/explaining.md):

    1. Choose the cluster's isolation, with what each gives: "a microVM per session", "a gVisor sandbox", "containers only: for trusted code".
    2. Copy a helm install with the enrollment token and choices filled in.
    3. Watch the runner come online.

    Before the copy step, a preview shows the session pods as they'll appear (kubectl get sandboxes -n fctl-sandboxes).

  • A session's page names where it runs ("Pod web-12-7f3c on node ip-10-0-3-17, microVM") in its details, for those who look.

  • fctl host status and fctl host doctor on the cluster host list its sandboxes by state, the warm pool, what the driver leaves out and why, and RBAC or CRD problems with the command that fixes each.

  • Follow hyperstructure/design's docs: docs/principles.md; docs/web-app/explaining.md for pages that set something up (a headline that names the outcome, a lead built from this place's facts, a preview of the result, one primary action, and who can act); docs/web-app/kit.md for controls.

  • Design every state before building it: the first visit, loading, errors and refusals, waiting, partial setups and long lists.

  • Say what happens, plainly, and never leave someone at a disabled control without saying who can act.

  • Prototype the main screens with realistic data (cargo xtask demo's world) and review them before building the rest.

  • Check both themes, a phone's width, the keyboard, screen readers and reduced motion, and show screenshots in each pull request.

  • Give the CLI the same care: readable output, --json, and errors that say what to do next.

  • Add or update the pages of hyperstructure/design's docs for each new component, with the reasons behind its choices.

Compatibility

  • Host only. It's a new driver, so the control plane needs nothing new beyond what the host already reports.
    • DriverInfo and HostHello may gain optional fields for the isolation in use and the cluster's facts.
    • Older control planes ignore them.
  • The sandbox image must run as a pod's main process or under exec as it does under Docker. hyperstructure/sandbox may need an entrypoint that waits, and a test in its Examples workflow.
  • CI needs a cluster to test against, for example kind with agent-sandbox installed, and a fake for unit tests, as driver::fake does for Docker.

Decisions for a person

  • What backs a sandbox: agent-sandbox only (fewer moving parts in fctl, one more component in the cluster), plain Pods and volumes only, or both as described.
  • Isolation: whether the driver refuses to start without an isolating RuntimeClass unless the host says otherwise (allow_runc = true), as a safety default.
  • Replicas: whether one host per cluster is enough, or several hosts (one per namespace or node pool) as separate runners.
  • The Helm chart's home: this repository or a new one.

Related: #615, #616

Session: https://app.fctl.sh/s/ses_01M8450BECFP8DN88R0ZP0N0MS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementhost

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions