How to Configure Claude Code Kubernetes Permissions

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up claude code kubernetes permissions by binding a tight RBAC role to the local cluster user. Next, you point the agent to that scoped kubeconfig file. Many teams skip this step during a busy week. They let the agent use an admin profile on a developer laptop. When a role is too broad, one bad prompt can delete pods or read secrets. How claude code kubernetes permissions work in native RBAC Claude Code reaches outside tools and APIs in two main ways. It can use Model Context Protocol

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 claude code kubernetes permissions by binding a tight RBAC role to the local cluster user. Next, you point the agent to that scoped kubeconfig file. Many teams skip this step during a busy week. They let the agent use an admin profile on a developer laptop. When a role is too broad, one bad prompt can delete pods or read secrets.

How claude code kubernetes permissions work in native RBAC

Claude Code reaches outside tools and APIs in two main ways. It can use Model Context Protocol servers, or it can run shell commands with its Bash tool. In manual mode, the Bash tool asks for human approval before it runs most commands. Only a small built-in list of safe read commands runs without a prompt. When the agent runs a cluster CLI tool, Kubernetes checks the local user credentials.

Kubernetes uses Role-Based Access Control to check those requests on the API server. Every rule in this system is additive, which means there are no deny rules. You start with zero rights and add verbs like get, list, or watch. A Role sets these rules inside a single namespace. A ClusterRole sets rules across all namespaces or for cluster-wide items like nodes.

To grant these rights to the agent, you create a RoleBinding or a ClusterRoleBinding. A RoleBinding links a Role or ClusterRole to a user inside one namespace. A ClusterRoleBinding grants those rights across the whole cluster. For a coding agent, teams usually build a Role that only allows read verbs on pods. You must also watch out for subresources in the API. Items like pod logs or pod exec paths count as subresources and use a slash in their name. If you leave out the exec subresource, the agent cannot open a shell inside a running container.

Why native roles leave an operational gap

Native cluster roles do a great job of limiting which API paths a user can reach. They stop an agent from dropping a namespace or changing a deployment spec. They also let you keep the agent inside a single dev or staging namespace.

Claude Code Security + Kubernetes RBAC: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Still, static roles only check who logs in and which API resource they call. They do not inspect what individual commands or requests do in flight. If an engineer grants the pod exec subresource for debugging, the agent gets full shell access inside that container. Kubernetes RBAC cannot check the shell commands the agent runs inside the pod. A single approved exec call can still change app files or dump memory.

Pod logs create a similar risk for sensitive data. When the agent reads logs to fix a bug, the cluster sends back raw text lines. Those log lines often hold user emails, phone numbers, or card numbers from recent requests. Native RBAC only decides if the agent can read the log stream at all. It cannot rewrite matched fields in results to hide private data before the model reads it. Also, storing a static cluster key on a laptop means the agent can use it whenever a shell command gets approved.

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

How does Claude Code talk to a Kubernetes cluster?

It reaches clusters by running CLI tools through its Bash tool or by calling an MCP server. Both paths use the local cluster credentials stored on the host machine to talk to the API server.

Should I give an AI coding agent a Role or a ClusterRole?

Use a Role with a RoleBinding whenever you can. This keeps the agent inside one namespace. Only use a ClusterRoleBinding if the agent truly needs to read nodes or pods across every namespace.

Can Kubernetes RBAC block dangerous commands inside a pod exec session?

No, native RBAC only checks if the user has the right to call the pod exec subresource. Once the session starts, the API server does not filter or block the shell commands that run inside the container.

The query runs. The emails stay hidden.