How to Configure Make Kubernetes Sandbox
You set up a make kubernetes sandbox by pairing build tasks with a scoped namespace. You then bind a narrow role to the account that runs those build tasks. Teams often start by giving their build tool broad cluster rights to move fast. That shortcut creates a major risk when a script or user runs a bad command. A wide role lets a single test task break shared workloads or read private keys. How a make kubernetes sandbox works in practice A safe setup starts with how the cluster checks permis
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 make kubernetes sandbox by pairing build tasks with a scoped namespace. You then bind a narrow role to the account that runs those build tasks. Teams often start by giving their build tool broad cluster rights to move fast. That shortcut creates a major risk when a script or user runs a bad command. A wide role lets a single test task break shared workloads or read private keys.
How a make kubernetes sandbox works in practice
A safe setup starts with how the cluster checks permissions on the API server. Kubernetes uses Role and ClusterRole objects to hold sets of permission rules. These rules are purely additive, which means there are no deny rules at all. A standard Role always sets permissions inside one single namespace. In contrast, a ClusterRole covers cluster-wide objects like nodes or spans across all namespaces. For a sandbox, you want to keep all build tasks inside one isolated namespace.
You link your build identity to that Role with a RoleBinding in that namespace. A RoleBinding grants permissions inside one namespace and can point to a Role or ClusterRole. Avoid using a ClusterRoleBinding here because it grants access across the entire cluster. When a developer triggers a target, the build tool calls the cluster API server. The API server checks the RoleBinding and allows only the actions listed in the Role.
Many build targets also need to read pod logs or run commands inside containers. Kubernetes treats these actions as subresources in the API URL. Your Role must name the top resource and the subresource with a slash between them. This lets you grant log reading without granting full control over the pod itself.
What native roles solve and where gaps remain
Native roles are great at deciding which account can enter a specific namespace. They stop a sandbox build task from deleting workloads in your main production namespaces. They also let you separate read rights on pod logs from exec rights on pods. This structure gives your team a clean boundary at the API entry point.
Still, native role checks stop once the API server approves the initial request. If a Role allows pod exec, the user or script can run any shell command. The role setup decides who logs in, not what individual commands do in flight. Also, Kubernetes does not let you restrict subresource creation to specific resource names. If a role allows exec inside a namespace, it applies to every pod there.
Kubernetes RBAC + AI Sandbox Environments: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
The same gap appears when a sandbox task reads logs or queries a pod. Native permissions cannot inspect the data stream that comes back from the container. If a test pod prints real emails, phone numbers, or card numbers, they show up. The native role system has no way to rewrite matched fields in results. Teams also struggle with static client keys stored on developer laptops for build scripts. If a laptop loses a key, anyone can run sandbox targets until you revoke it.
Tightening sandbox workflows for daily builds
To reduce risk, split your build targets into read tasks and write tasks. Map each task group to its own Role inside the sandbox namespace. Give the log checking task access only to the pod log subresource. Reserve the pod exec subresource for debug tasks that truly need a shell inside containers.
You should also clear out old sandbox namespaces on a regular schedule. Fresh namespaces prevent stale test data and old secrets from sitting around for weeks. Even with clean namespaces, you still need visibility into the commands that run inside pods. Pairing native namespace roles with command-level controls closes the gap left by basic permissions.
Govern kubectl and API calls in flight
Identity providers and Kubernetes RBAC decide who logs into a cluster. They cannot redact keys inside returned JSON objects or hold a risky delete call for review. By design, hoop.dev runs as an open-source proxy, a sidecar for your Kubernetes API, checking requests and responses without replacing RBAC.
First, hoop.dev guardrails refuse banned methods, paths, or headers before they run. Next, hoop.dev data masking rewrites sensitive keys in returned Secret, ConfigMap, and log responses in memory, and writes each decision to the audit trail. Explore the repo on GitHub.
Frequently asked questions
Should I use a Role or a ClusterRole for a sandbox?
Use a Role paired with a RoleBinding for almost every sandbox setup. This keeps all permissions locked inside one single namespace so tests cannot affect other teams. You can also reference a shared ClusterRole inside a namespaced RoleBinding to save time.
Can I add a deny rule to block dangerous build tasks?
No, Kubernetes permissions are purely additive and do not support deny rules. You must start with zero permissions and add only the exact verbs each task needs. If a permission is too broad, you must remove it from the Role.
How do I let build scripts read pod logs safely?
Add a rule to your Role that targets the pod log subresource specifically. In Kubernetes RBAC, you write the resource name and subresource name separated by a slash. This lets the script read log output without giving it permission to change pods.
Related guides
In this post