How to Configure Codex Kubernetes Approval

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up codex kubernetes approval by pairing local agent prompts with strict cluster roles. First, require user consent before the agent runs any local shell tool. Many teams start by giving their coding agent a local cluster file. That file often holds broad admin rights for fast testing. When an agent uses broad roles, a bad command can delete live pods. It can also read private data across every single namespace. How to set up codex kubernetes approval with native roles A coding agent r

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 codex kubernetes approval by pairing local agent prompts with strict cluster roles. First, require user consent before the agent runs any local shell tool. Many teams start by giving their coding agent a local cluster file. That file often holds broad admin rights for fast testing. When an agent uses broad roles, a bad command can delete live pods. It can also read private data across every single namespace.

How to set up codex kubernetes approval with native roles

A coding agent reaches your cluster by running command tools on the host machine. It uses the local user profile and cluster file to talk to the server. To limit what the agent can do, you must use native role rules. In Kubernetes, a Role sets permissions inside one single namespace. A ClusterRole sets rules across the whole cluster for nodes or all namespaces. Both rule types are purely additive, which means there are no deny rules.

You start with zero rights and add only the actions the agent needs. Next, you link those rules to the agent user with a binding. A RoleBinding grants rights inside one namespace. It can point to a Role in that namespace or a shared ClusterRole. A ClusterRoleBinding grants those rights across the entire cluster at once. For an AI agent, you should always pick a single namespace RoleBinding. You can also control subresources like pod logs or pod command sessions.

In the role rules, you name the subresource with a slash after the main resource. Giving an agent pod log rights lets it read app output to fix bugs. Giving it pod exec rights lets it run shell commands inside a running container. You should separate these two rights into distinct roles. The agent can read logs by default, while exec rules stay unassigned until needed.

What native cluster roles solve and what they miss

Native cluster roles decide which API paths a user or agent can call. They stop an agent from touching namespaces it does not own. They also block the agent from changing cluster nodes or reading secret objects. On the client side, local agent settings let you pause shell commands before they run. A human must click approve in the editor before the tool sends the request. Together, these two steps stop most simple mistakes during daily coding tasks.

Approval Chains & Escalation + Kubernetes RBAC: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Still, static roles and local prompts leave big operational gaps in live systems. First, local prompts depend on the developer reading every command with care. Developers get tired and start clicking approve without checking the full command text. Second, Kubernetes roles only check who logs in and which API endpoint they hit. Once a role allows pod exec or database port forwarding, the cluster stops checking. It cannot see what happens inside that open stream.

An agent with exec rights can run a destructive script inside the container. It can also query a backend store and pull customer emails or phone numbers. Card numbers and national IDs can flow straight into the model prompt window. Also, naming specific resources in a role rule does not work for create actions on subresources. You cannot use a static role alone to approve just one single pod session. Teams need a way to check individual commands in flight and mask sensitive fields in results.

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 sits inline as an open-source proxy, a sidecar for your Kubernetes API, without replacing RBAC. On every production call from an engineer or AI agent, hoop.dev decides to pass, mask, block, or hold it for human approval.

First, hoop.dev guardrails refuse banned methods, paths, or headers before they run or hold risky deletes for review. 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

Can I use a deny rule in Kubernetes to block dangerous agent commands?

No, Kubernetes role rules are purely additive and do not support deny rules. You must start with an empty role and grant only the safe actions you want.

How do I let an agent read pod logs without letting it run container commands?

Grant rights only to the pods log subresource in your namespace Role. Leave the pods exec subresource out of the rule list so shell sessions fail.

Why is a local editor prompt not enough for cluster approval?

Local prompts only ask the user sitting at the laptop to click yes. They do not ask a team lead, and they do not mask card numbers or emails in output.

The query runs. The emails stay hidden.