I'm looking at running coding agents on Kubernetes and am unsure where the sandbox ends and the application environment begins. Should the agent and the app it changes run separately, and what does that mean for access and cleanup?
Should a coding agent sandbox be separate from the app environment?
Answers
Think of the sandbox as the agent's workspace: the agent process, a repository checkout, and the access it needs for its task. The application environment is the deployed frontend, backend, databases, queues, and anything else the app needs.
One setup is to keep the agent in a small pod and give it a separate namespace where it can deploy the app, run tests, and inspect logs and events through the Kubernetes API. The sandbox manages where the agent runs. It doesn't automatically provide the deployed app environment.
Reply to this answer
A namespace per agent is useful for organizing access, but don't treat it as a complete security boundary. Scope the agent's ServiceAccount permissions to the namespace it needs, and use NetworkPolicy to restrict traffic where your cluster supports it.
For sensitive credentials such as repository push tokens or model API keys, consider a proxy outside the agent pod that adds credentials to outbound requests. That can reduce the risk of an agent exposing a token after being manipulated by untrusted content.
Reply to this answer
Plan for the agent dying halfway through a task. Give each temporary app environment an expiry and let a separate controller clean it up. Store test logs outside that namespace so deleting the environment doesn't also erase the evidence you need to debug a failure.
Reply to this answer
Separation doesn't have to mean making local development awkward. A development setup can connect the agent workspace and app environment closely enough to support things like hot reload. That's a different choice from giving the agent the same access to production.
Reply to this answer
Production investigation deserves its own access profile. An agent deploying into its temporary namespace might need broad permissions there, while one inspecting production logs and events can use read-only access such as get, list, and watch, without exec or secret access. Even read-only permissions need careful scoping because logs and other resources may contain sensitive data.
Reply to this answer
Add your answer
Answers are reviewed before publication.
2N..fira:
That also leaves an image-building question. The workflow needs a way to build the changed app images before deploying them.