Containarium icon indicating copy to clipboard operation
Containarium copied to clipboard

K8s agent-box backend: SSH-reachable per-tenant pod

Open hsinatfootprintai opened this issue 5 months ago • 1 comments

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-0 per tenant namespace, stable DNS.
  • In-cluster sshpiper Deployment — 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, hardened securityContext.
  • [ ] Per-tenant StatefulSet + headless Service templating.
  • [ ] sshpiper Deployment + LB Service in the gateway namespace.
  • [ ] Upstream controller: program PiperUpstream CRD + reconcile per-tenant key Secret (replaces sentinel YAML key-sync).
  • [ ] Default-deny ingress/egress NetworkPolicy per tenant namespace.
  • [ ] containarium box create --runtime=k8s CLI 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

  1. sshpiper CRD kubernetes plugin vs. yaml plugin (leaning CRD — kills the file-write race).
  2. Box-backend Go interface shape (Create/Delete/Resolve) shared by LXC + K8s.

hsinatfootprintai avatar Jun 16 '26 03:06 hsinatfootprintai

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:

  1. No kube-apiserver token in the agent's hands. The default kubectl exec route needs RBAC that over-grants — a compromised agent becomes a cluster-API foothold. Here the agent gets SSH → a ForceCommand-pinned agent-box stdio MCP, automountServiceAccountToken: false. Compromise radius = one hardened pod, not the API server.
  2. Better-behaved tenant than most workloads. Passes restricted PodSecurity as-is (non-root, drop-ALL, seccomp, read-only rootfs). Installs cleanly on locked-down clusters.
  3. Auditable, namespaced footprint. Reviewable Helm chart + namespaced ServiceAccount, no steady-state cluster-admin (one-time CRD install only).
  4. BYO everything, zero new control plane. Their cluster, nodes, GPUs, network boundary. Agent foothold lives next to the data it works on.
  5. One agent contract across substrates. Same agent-box surface / scoped-JWT / containarium box create CLI 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).

hsinatfootprintai avatar Jun 16 '26 05:06 hsinatfootprintai