K8s agent-box backend: SSH-reachable per-tenant pod
Summary
Add a Kubernetes backend for the agent box so an agent can reach a
per-tenant pod over SSH and get the same agent-box stdio MCP surface served
today from an LXC box. The agent-facing contract is unchanged:
ssh <tenant>@<gateway> -- agent-box → ForceCommand agent-box → stdio MCP
This is a backend behind the existing box vocabulary (--runtime=k8s),
not a parallel surface — CLI-first, MCP wraps the same Go function.
Design doc
docs/K8S-AGENT-BOX-RUNTIME-DESIGN.md (this PR/branch).
Decisions locked for v1
- Long-lived per-tenant pods — StatefulSet
box-0per tenant namespace, stable DNS. - In-cluster
sshpiperDeployment — reuse the sentinel reverse-proxy pattern; per-user fan-out behind one LB IP. - Namespace-per-tenant + default-deny NetworkPolicy — soft multi-tenancy; the K8s expression of eBPF deny-by-default + egress allowlist.
Scope (v1)
- [ ] Box image:
sshd+agent-box,ForceCommand, no baked-in keys, hardenedsecurityContext. - [ ] Per-tenant StatefulSet + headless Service templating.
- [ ]
sshpiperDeployment + LB Service in the gateway namespace. - [ ] Upstream controller: program
PiperUpstreamCRD + reconcile per-tenant key Secret (replaces sentinel YAML key-sync). - [ ] Default-deny ingress/egress NetworkPolicy per tenant namespace.
- [ ]
containarium box create --runtime=k8sCLI verb behind a box-backend Go interface; LXC stays default. - [ ] Host-key pre-distribution so first-connect is not a TOFU prompt.
Deferred
Hard isolation (gVisor/Kata RuntimeClass), ephemeral/pooled lifecycles,
GPU passthrough in pods, cross-cluster fan-out.
Open questions
- sshpiper CRD
kubernetesplugin vs.yamlplugin (leaning CRD — kills the file-write race). - Box-backend Go interface shape (
Create/Delete/Resolve) shared by LXC + K8s.
Why a K8s operator would want this (positioning)
The pitch is not "another way to run pods" — K8s already does that. The wedge is agent safety:
The safest blast-radius for an autonomous agent in your cluster — SSH-native, RBAC-minimal, default-deny — with zero new control plane.
Concrete hooks, in order of what resonates with cluster operators:
- No kube-apiserver token in the agent's hands. The default
kubectl execroute needs RBAC that over-grants — a compromised agent becomes a cluster-API foothold. Here the agent gets SSH → aForceCommand-pinnedagent-boxstdio MCP,automountServiceAccountToken: false. Compromise radius = one hardened pod, not the API server. - Better-behaved tenant than most workloads. Passes
restrictedPodSecurity as-is (non-root, drop-ALL, seccomp, read-only rootfs). Installs cleanly on locked-down clusters. - Auditable, namespaced footprint. Reviewable Helm chart + namespaced ServiceAccount, no steady-state cluster-admin (one-time CRD install only).
- BYO everything, zero new control plane. Their cluster, nodes, GPUs, network boundary. Agent foothold lives next to the data it works on.
- One agent contract across substrates. Same
agent-boxsurface / scoped-JWT /containarium box createCLI whether the box lands on LXC or K8s.
Caveat to message around: SSH-as-transport is unusual in K8s-land — the messaging must lead with the credential-isolation why, or it reads as swimming against the platform.
Full version in docs/K8S-AGENT-BOX-RUNTIME-DESIGN.md (PR #701).