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

  1. Claude Code's kubectl and helm talk to a local proxy in Krust on 127.0.0.1, with a proxy token that is worthless to the cluster.
  2. 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.
  3. The cluster token never reaches the terminal, and nothing is written to ~/.kube, ~/.config/gcloud or ~/.aws.

Read-only, Ask and Write

Choose the mode in the bar above the Claude Code tab.

ModeReadsChanges, exec, attach, cp, debug, port-forwardSecret values
Read-onlyYesRefusedHidden
Ask (default)YesEach one waits for your answer in KrustHidden
WriteYesAllowed, until you switch back or for 15 minutesReal

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

  1. Add the cluster with File → Add Cluster… and sign in to Google Cloud or AWS. See Google Cloud & GKE.
  2. 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.
  3. Pick Read-only or keep Ask. Switch to Write only for the change you mean to make.
  4. 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

ApproachWhat it limitsWhat it leaves
Claude Code permission rulesWhich commands the agent runs without askingThe agent still holds your full credential; rules can be bypassed by flags or settings
A read-only RBAC identity for the agentWhat the cluster allows, enforced by the API serverA second identity to create and keep in sync; no "ask me first" for occasional writes
A read-only Kubernetes MCP serverThe agent's tools to readskubectl in the same shell still has your full access
Krust proxyEvery kubectl and helm request from the tab, per modeCovers GKE and EKS clusters added with cloud sign-in; RBAC still decides the ceiling

What this does not cover

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.