How to Configure Cline Kubernetes Least Privilege

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up cline kubernetes least privilege by creating a scoped role for the agent. Then you bind that role to a dedicated identity in one namespace. Most teams let the coding agent use a developer shell with full cluster admin rights. That broad setup lets a bad command change or delete workloads across every namespace. How to set up cline kubernetes least privilege Cline runs commands in your local shell to check pods, read logs, and apply changes. It uses whatever cluster credentials exis

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 cline kubernetes least privilege by creating a scoped role for the agent. Then you bind that role to a dedicated identity in one namespace. Most teams let the coding agent use a developer shell with full cluster admin rights. That broad setup lets a bad command change or delete workloads across every namespace.

How to set up cline kubernetes least privilege

Cline runs commands in your local shell to check pods, read logs, and apply changes. It uses whatever cluster credentials exist in your active terminal session. If your terminal uses an admin profile, the agent gets those exact same cluster rights. To limit the blast radius, you must create a separate identity for the agent.

Kubernetes role-based access control uses rules that are purely additive. There are no deny rules in this system. You start with zero rights and add only the actions the agent needs. A Role sets permissions inside one single namespace. A ClusterRole sets permissions across the whole cluster and covers cluster-wide objects like nodes.

For most coding tasks, you should define a Role in a single test or staging namespace. You list the specific objects the agent can read, such as pods, deployments, and services. Then you create a RoleBinding in that same namespace. The RoleBinding links your Role to the user or service account that Cline uses. If you want to reuse one common rule set across a few namespaces, you can define a ClusterRole first. Then you link it with a local RoleBinding so the rights stay inside that one namespace.

Controlling subresources and local credentials

Standard read rules on pods do not cover every action an agent might try. Kubernetes treats pod logs and command execution as separate subresources in the API. You must grant access to the log subresource if Cline needs to read app output. You should leave out the exec subresource unless the agent truly needs to run shell commands inside containers.

Keep secret permissions out of the agent role as well. If the agent can read secrets in a namespace, those values enter the model context. Once you finish the role binding, give Cline a kubeconfig file tied only to that scoped identity. Do not let the agent share your main admin profile.

Least Privilege Principle + Kubernetes RBAC: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native RBAC solves and what keeps the session active

Native role bindings decide which API groups and namespaces an identity can reach. They stop an agent in a dev namespace from touching production workloads or cluster nodes. They also block the agent from creating new roles or reading cluster secrets when you leave those rules out.

Still, static roles leave big operational gaps open during daily work. Kubernetes permissions are all-or-nothing for each verb and resource type you grant. If you let Cline update deployments or run pod exec commands to fix a bug, it holds that power at all times. RBAC checks who logs in and which API endpoint they call. It does not inspect the exact shell command inside an exec call or require human approval for risky flags. It also cannot rewrite sensitive fields like emails, phone numbers, card numbers, or national IDs that appear inside pod logs before they reach the agent.

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

Why should Cline use a RoleBinding instead of a ClusterRoleBinding?

A RoleBinding limits permissions to one specific namespace. A ClusterRoleBinding grants permissions across every namespace in the cluster, which gives the coding agent too much reach.

Can I add a deny rule to block Cline from deleting pods?

No, Kubernetes RBAC permissions are purely additive and have no deny rules. To block deletions, you must leave the delete verb out of every role bound to the agent.

Does pod read access let Cline run commands inside a container?

No, reading a pod object and running commands inside it use different permissions. Container command execution uses the exec subresource, which you must grant as a separate rule.

The query runs. The emails stay hidden.