How to Configure Cursor Kubernetes Credentials

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up cursor kubernetes credentials by linking your local cluster file to the editor. You also limit what the coding agent can do with native Kubernetes role rules. Many teams start by giving the editor the same local admin key they use daily. That quick shortcut lets the agent run any command across your whole cluster. If a prompt goes wrong, an overly broad role can delete workloads or read secrets. How cursor kubernetes credentials work with native roles Cursor reaches your cluster th

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 cursor kubernetes credentials by linking your local cluster file to the editor. You also limit what the coding agent can do with native Kubernetes role rules. Many teams start by giving the editor the same local admin key they use daily. That quick shortcut lets the agent run any command across your whole cluster. If a prompt goes wrong, an overly broad role can delete workloads or read secrets.

How cursor kubernetes credentials work with native roles

Cursor reaches your cluster through local shell tools or Model Context Protocol servers. These tools read the local kubeconfig file on your machine to log in. When the agent runs a command, the Kubernetes API server checks the identity in that file. You control what that identity can do with Role-Based Access Control, known as RBAC.

In Kubernetes, a Role sets rules within one single namespace. A ClusterRole sets rules across the whole cluster, including nodes and all namespaces. Both types of roles are purely additive, which means there are no deny rules. You start with zero permissions and add only the exact actions the agent needs.

After you define a Role, you connect it to the agent identity with a RoleBinding. A RoleBinding grants those permissions inside one specific namespace. If you use a ClusterRoleBinding, you grant those permissions across the entire cluster. For an AI assistant, scoping a RoleBinding to a test or staging namespace is safer.

You also need to watch subresources in your role rules. Kubernetes treats actions like reading pod logs or running commands in a pod as subresources. If you grant access to pods logs, the agent can read output to debug an app. If you grant access to pod exec, the agent can open a shell inside a container.

What native setup solves and what it leaves open

Setting up a dedicated Role and RoleBinding solves the first layer of risk. It decides which user or service account can log in to the cluster. It also blocks the agent from touching namespaces or resource types outside its assigned role. For example, a read-only role stops the agent from deleting a deployment by mistake.

Still, native RBAC stops at the API resource boundary. It checks who logs in and which resource type they call, not what happens inside. Once a role allows pod exec, Kubernetes does not check the shell commands run inside. Once a role allows reading pod logs, it returns every line of text from that pod.

Ephemeral Credentials + Kubernetes RBAC: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Pod logs and command output often hold emails, phone numbers, card numbers, or national IDs. When the coding agent reads those logs, that sensitive text goes straight to the model context. Also, a static kubeconfig file sits on the laptop disk all day. Any local process or runaway prompt can use those keys whenever the editor is open.

Steps to reduce risk when agents query clusters

First, never let your coding agent use a cluster-admin binding. Create a separate user or service account just for editor sessions. Bind that identity to one namespace with a RoleBinding instead of a ClusterRoleBinding.

Second, split read rules from write and exec rules. Let the agent list pods and read events by default. Keep pod exec and secret reading out of the base role so prompts cannot abuse them. Third, think about how to scrub emails and card numbers from command output before models read it.

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

Where does Cursor find my cluster login keys?

The editor uses your local shell or an MCP server to run cluster commands. Both tools read the standard kubeconfig file stored in your home folder by default. Whatever context is active in that file becomes the cluster the agent talks to.

Can I add a deny rule to block my agent from reading secrets?

No, Kubernetes RBAC permissions are purely additive and do not support deny rules. To block access to secrets, you must leave secrets out of every Role bound to that user. Start with an empty role and add only safe resources like pods and deployments.

Why is pod exec risky to include in cursor kubernetes credentials?

The pod exec subresource lets the user run arbitrary commands inside a running container. Native RBAC only checks if the user can start the exec call, not which commands run next. Through an open shell, an agent could change app files or read local container memory.

The query runs. The emails stay hidden.