How to Configure Amazon Q Kubernetes Permissions
You set up amazon q kubernetes permissions by binding a Kubernetes role to the identity that runs your agent. This setup limits which cluster resources the AI coding agent can read or change. Many teams start by giving the agent the same broad cluster rights that an engineer holds. When roles are too broad, a bad prompt or agent mistake can delete live workloads. It can also read sensitive secrets or run commands inside running containers across every namespace. How amazon q kubernetes permiss
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 amazon q kubernetes permissions by binding a Kubernetes role to the identity that runs your agent. This setup limits which cluster resources the AI coding agent can read or change. Many teams start by giving the agent the same broad cluster rights that an engineer holds. When roles are too broad, a bad prompt or agent mistake can delete live workloads. It can also read sensitive secrets or run commands inside running containers across every namespace.
How amazon q kubernetes permissions work in native RBAC
Amazon Q Developer runs local terminal commands or reaches external tools through the user's local setup. When it runs cluster commands, the Kubernetes API server checks the identity attached to that request. Kubernetes role-based access control uses pure additive rules to grant rights to users and service accounts. There are no deny rules in Kubernetes RBAC. You start with zero access and add rules for specific verbs and resources.
A Role sets permissions inside a single namespace. A ClusterRole sets permissions across the whole cluster. It can cover cluster-wide objects like nodes or namespaced objects like pods across every namespace. To apply these rules, you create a RoleBinding for one namespace or a ClusterRoleBinding for the whole cluster. For an AI assistant, teams usually start with read verbs like get, list, and watch.
You also must account for subresources in the Kubernetes API. Subresources represent actions like reading pod logs or running a shell inside a container. In RBAC rules, you write the top resource and the subresource with a slash between them. If you grant pod log rights, the agent can read text output from your running apps. If you grant pod exec rights, the agent can open a shell inside the container itself.
Scoping namespaces and subresources for AI agents
Limiting an AI agent to one namespace is the safest first step in native RBAC. You can create a dedicated service account or user profile just for agent tasks. Then you bind a Role to that identity in a test or staging namespace. This stops the agent from touching production apps or cluster nodes by mistake.
A common mistake is granting wildcard access to all resources in a namespace. Wildcard rules include secrets and config maps along with standard pod objects. If the agent can read secrets, it can pull database keys into its prompt context. You should list each safe resource type by name in your Role definition. Leave out secrets and write verbs unless the task requires them.
Kubernetes RBAC + AI Agent Permissions: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
What native RBAC solves and what it leaves open
Native Kubernetes RBAC solves the problem of who can call a given API endpoint. It blocks an unauthorized identity from touching namespaces or resource types outside its bound role. This keeps an agent with a read-only Role from deleting deployments or changing cluster nodes.
Still, RBAC only checks the resource type and verb at the door. It cannot inspect the content of a request or the data returned in a response. If an agent has pod log access to fix bugs, those logs might hold user emails. They might also hold phone numbers, card numbers, or national IDs printed by an app. Native RBAC sends the full log stream back to the agent with no filtering.
The same gap appears when an agent holds exec rights to debug a running pod. RBAC checks whether the user can start an exec session on that pod. Once the session starts, Kubernetes does not check the individual shell commands run inside the container. Static role bindings also stay active all day long without per-command approval from a human lead.
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 HTTP proxy, a sidecar for your Kubernetes API. The kubectl client changes only the server address it talks to while RBAC stays in place.
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. On the way back, hoop.dev data masking walks JSON responses by key and masks matched values in Secrets, ConfigMaps, and pod logs. Every request and verdict is logged without storing bearer tokens. View the project on GitHub.
Frequently asked questions
Should an AI coding agent use a developer's personal kubeconfig?
No, an agent that uses a personal kubeconfig inherits every cluster right that the human engineer holds. A dedicated identity with a narrow Role limits the blast radius if the agent runs a bad command.
Can Kubernetes RBAC block specific shell commands inside a pod exec session?
No, Kubernetes RBAC only controls whether an identity can open the exec subresource on a pod. It does not inspect or block the shell commands that run after the session opens.
How do I stop an agent from reading secrets across all namespaces?
Avoid using ClusterRoleBindings and wildcard resource rules when you set up the agent's identity. Bind a standard Role to one namespace and list only safe resources like pods and deployments.
Related guides
In this post