How to Configure Windsurf Kubernetes Least Privilege

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up windsurf kubernetes least privilege, bind a narrow Kubernetes Role to the agent's local identity. Then limit that role to specific namespaces, read verbs, and safe subresources. Teams often run this editor using their own local admin kubeconfig files. Because the built-in agent runs shell commands directly, broad cluster roles create serious risk. A single bad prompt can delete workloads or read secret values across every namespace. How windsurf kubernetes least privilege works in na

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.

To set up windsurf kubernetes least privilege, bind a narrow Kubernetes Role to the agent's local identity. Then limit that role to specific namespaces, read verbs, and safe subresources. Teams often run this editor using their own local admin kubeconfig files. Because the built-in agent runs shell commands directly, broad cluster roles create serious risk. A single bad prompt can delete workloads or read secret values across every namespace.

How windsurf kubernetes least privilege works in native RBAC

Cognition renamed Windsurf to Devin Desktop in June 2026, while keeping the same IDE features. Its Cascade agent can run terminal commands in a dedicated shell with user permission. That shell loads the user's normal shell profile, including aliases and local variables. When the agent runs cluster commands, it uses whatever cluster credentials exist in that shell. It can also reach external tools through configured Model Context Protocol servers.

To restrict what the agent can do, you must use native Kubernetes RBAC. In Kubernetes, a Role sets permissions inside one specific namespace. A ClusterRole sets permissions across the whole cluster or for cluster-scoped objects like nodes. You connect these rules to a user or service account with a RoleBinding or ClusterRoleBinding. For the tightest setup, create a dedicated user identity just for your coding agent. Then bind that identity to a namespace Role using a RoleBinding.

Kubernetes RBAC rules are purely additive, which means there are no deny rules. You start with zero permissions and list every allowed resource and action verb. Give the agent read verbs like get and list on pods and deployments. Watch out for subresources, which appear after a slash in the API path. Allowing pod reads does not by default allow reading pod logs or running exec commands. You must grant the log subresource by itself and leave the exec subresource out.

Why static cluster roles fall short for AI agents

Native RBAC controls who can call a cluster API endpoint and which verb they use. That works well for static apps that do one small job in one namespace. Still, developers and AI agents need to fix live bugs across many namespaces. If you strip away every write verb and exec permission, the agent cannot fix issues. So teams end up granting broader roles just to get daily work done.

Once a role allows reading pod logs or running exec sessions, RBAC steps back. Native role bindings cannot check what happens inside an active shell session. They cannot inspect the command string an AI agent sends into a running container. They also cannot rewrite sensitive fields like emails or phone numbers in pod log output. Static credentials also sit on the laptop disk where any local process can read them.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Separating developer profiles from agent identities

A strong local setup starts by splitting the human profile from the AI agent shell. When a developer opens a terminal, their default profile often points to a cluster admin role. Because the editor loads the user's shell startup files, the agent inherits those broad keys. You can prevent this by pointing the agent shell to a restricted kubeconfig file.

That separate file should hold credentials for a read-only service account in a test namespace. Keep secret objects out of that role's rule list so the agent cannot dump keys. If the agent needs to check app output, allow only the pod log subresource. Even with a separate file, static keys on a laptop remain hard to rotate and audit. Teams still need a way to approve risky actions and filter output in real time.

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

How does the Windsurf agent run commands against a Kubernetes cluster?

The editor, now called Devin Desktop, runs terminal commands in a local zsh or bash shell. Because it loads your shell config, it uses your local cluster CLI and credentials.

Should I use a Role or a ClusterRole for an AI coding agent?

Use a Role paired with a RoleBinding whenever possible. This limits the agent to a single namespace, whereas a ClusterRoleBinding grants permissions across the entire cluster.

How do I let the agent read pod logs without allowing container shell execution?

Kubernetes treats logs and exec as separate subresources under pods. Grant get permissions on the pod log subresource and leave the pod exec subresource off the role.

The query runs. The emails stay hidden.