How to Configure Cursor Kubernetes Sandbox

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a cursor kubernetes sandbox by creating an isolated namespace with strict RBAC roles. Then you point the AI coding agent to that single namespace with limited credentials. Many teams start by handing the editor their local cluster admin file to test code. When permissions are too broad, a bad prompt or agent mistake can delete active workloads. How a cursor kubernetes sandbox works with native RBAC A safe setup starts inside the cluster API server using role-based access control. I

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up a cursor kubernetes sandbox by creating an isolated namespace with strict RBAC roles. Then you point the AI coding agent to that single namespace with limited credentials. Many teams start by handing the editor their local cluster admin file to test code. When permissions are too broad, a bad prompt or agent mistake can delete active workloads.

How a cursor kubernetes sandbox works with native RBAC

A safe setup starts inside the cluster API server using role-based access control. In Kubernetes, permissions are purely additive, which means there are no deny rules at all. You begin from zero permissions and add only the specific actions the AI agent needs. A Role always sets rules inside one single namespace, keeping the rest of the cluster safe. In contrast, a ClusterRole covers the whole cluster and can reach nodes or every namespace.

For a sandbox, you should stick to a standard Role inside a dedicated test namespace. Next, you create a RoleBinding in that same namespace to link the Role to an identity. That identity is usually a dedicated service account made just for the AI editor session. When the editor runs commands, it uses the credentials tied to that single service account. The API server checks the RoleBinding and stops any call that reaches outside the sandbox namespace.

Controlling subresources and local agent execution

Giving an agent basic pod permissions is not enough to keep a sandbox safe. Kubernetes splits many sensitive actions into subresources, such as reading pod logs or running commands inside containers. The API server treats pod logs and pod exec calls as distinct targets in your rules. If you only grant permission to view pods, the agent still cannot read the logs. You must explicitly add the log subresource to the Role if the agent debugs apps.

Running shell commands inside a live container uses the exec subresource, which carries higher risk. If you allow the exec subresource in the Role, the agent can open a shell inside pods. From inside a pod, the agent might read mounted secrets or reach other network services. Most teams leave the exec subresource out of the sandbox Role unless a task requires it. You also need to watch how the coding agent runs tools on the developer workstation. Coding agents can run local shell commands or talk to external systems through local tool servers. Each local command uses whatever cluster credentials sit in the developer shell session at that moment.

Kubernetes RBAC + AI Sandbox Environments: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native roles solve and what they leave open

Native roles and bindings do a good job of isolating one namespace from another. They stop an agent in the test namespace from deleting apps in a production namespace. They also block the agent from reading cluster-wide secrets or changing node settings on the server. Still, native RBAC only checks who makes the call and which resource type they touch.

Once a Role grants access to a resource or subresource, the API server allows every matching call. Native RBAC cannot inspect the exact shell command sent through an allowed pod exec request. It also cannot rewrite sensitive values like emails, phone numbers, or card numbers inside pod logs. If a test pod prints real customer emails to its log stream, the agent receives them. Also, static service account files stored on a laptop can leak or stay active too long. Teams still need a way to inspect individual commands and mask sensitive fields in flight.

Check Kubernetes API requests and responses on the wire

Kubernetes RBAC decides who may call the API server. RBAC does not check response payloads or split listing Secret names from reading Secret values when a role grants get access. With hoop.dev, you run an open-source proxy, a sidecar for your Kubernetes API, inline on the API connection. On every kubectl or API call an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

On each call, hoop.dev guardrails read the method, normalized path, and headers to refuse bad deletes or full Secret reads with a 403 error, or hold risky calls for approval. On the way back, hoop.dev data masking walks JSON responses by key and masks matched values in Secrets, ConfigMaps, and pod logs in memory. View the project on GitHub.

Frequently asked questions

Can I use a ClusterRole for a single sandbox namespace?

Yes, you can reference a ClusterRole inside a standard RoleBinding to limit permissions to one namespace. Still, writing a dedicated Role inside the sandbox namespace is simpler and avoids accidental broad permissions.

Why can the agent list pods but not read pod logs?

Kubernetes treats pod logs as a separate subresource in the API path. You must add the pod log subresource to your Role rules so the agent can read output.

Should a sandbox Role allow the pod exec subresource?

Only grant the exec subresource if the agent must run commands inside a running container. Leaving it out prevents the agent from running shell scripts or reading files inside the pod.

The query runs. The emails stay hidden.