Claude Code security for Kubernetes
Claude Code runs kubectl with whatever access your shell has. In Krust, a Claude Code tab on a GKE or EKS cluster never holds the cluster credential, and you decide per tab whether it may only read, must ask before each change, or may write.
The problem: your agent has your access
A coding agent in your terminal inherits your kubeconfig and your cloud CLI login. If you can delete a deployment in production, so can the agent, and so can anything that drives the agent. In the August 2025 Nx "s1ngularity" incident, a malicious npm postinstall script launched the developer's own Claude Code, Gemini CLI and Amazon Q with permission-bypass flags to search the disk for secrets.
Claude Code's own permission prompts help, but they live inside the agent: a flag or a settings file can turn them off. Krust puts the limit outside the agent, between Claude Code and the cluster.
How Krust limits Claude Code
- Claude Code's
kubectlandhelmtalk to a local proxy in Krust on127.0.0.1, with a proxy token that is worthless to the cluster. - The proxy checks each request against the tab's mode and forwards the allowed ones through Krust's own connection, which adds the real GKE or EKS credential.
- The cluster token never reaches the terminal, and nothing is written to
~/.kube,~/.config/gcloudor~/.aws.
Read-only, Ask and Write
Choose the mode in the bar above the Claude Code tab.
| Mode | Reads | Changes, exec, attach, cp, debug, port-forward | Secret values |
|---|---|---|---|
| Read-only | Yes | Refused | Hidden |
| Ask (default) | Yes | Each one waits for your answer in Krust | Hidden |
| Write | Yes | Allowed, until you switch back or for 15 minutes | Real |
- Hidden Secrets: values read as
<hidden by Krust>, while keys, sizes and metadata stay real, so Claude can still see which Secrets exist. Krust refuses a Secret write that carries the placeholder. - Always refused: impersonation (
--as) andkubectl proxy, in every mode. - RBAC still applies. The proxy can only narrow what your identity may do from that tab. It never grants more.
When Claude tries a change in Read-only, it gets an answer it can act on:
$ kubectl delete pod api-7f9c
Error from server (Forbidden): This Claude tab is in Read-only mode in Krust, so it cannot change the cluster.Set it up
- Add the cluster with File → Add Cluster… and sign in to Google Cloud or AWS. See Google Cloud & GKE.
- Open a Claude Code tab for that cluster from the terminal panel, or right-click a resource and choose Ask with External Agent → Claude Code.
- Pick Read-only or keep Ask. Switch to Write only for the change you mean to make.
- Optional: revoke the CLI logins (
gcloud auth revoke,aws sso logout) so no other shell keeps a working credential. The kubeconfig post has the full checklist.
Compared with other ways to limit an agent
| Approach | What it limits | What it leaves |
|---|---|---|
| Claude Code permission rules | Which commands the agent runs without asking | The agent still holds your full credential; rules can be bypassed by flags or settings |
| A read-only RBAC identity for the agent | What the cluster allows, enforced by the API server | A second identity to create and keep in sync; no "ask me first" for occasional writes |
| A read-only Kubernetes MCP server | The agent's tools to reads | kubectl in the same shell still has your full access |
| Krust proxy | Every kubectl and helm request from the tab, per mode | Covers GKE and EKS clusters added with cloud sign-in; RBAC still decides the ceiling |
What this does not cover
- The proxy covers Claude Code tabs on clusters added with Google Cloud or AWS sign-in. A kubeconfig you import keeps working as before.
- It does not stop malware running as you from reading your source code, SSH keys or browser data, or from asking you to approve a request.
- Krust does not change IAM or RBAC. An over-privileged identity is still over-privileged in Write mode.
FAQ
Does Claude Code ever see my GKE or EKS token?
No. Its kubeconfig names only the loopback proxy, a certificate made for that session, and a proxy token that the cluster does not accept.
Can I still let Claude fix things?
Yes. In Ask, each change waits for your answer in Krust and then runs. Write allows changes without asking, until you switch back or for 15 minutes.
Is this in Krust Free?
Google Cloud and AWS sign-in are part of Krust Pro. Imported kubeconfig contexts stay Free.