How to Configure Goose Kubernetes Prevent Delete

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up a goose kubernetes prevent delete rule, you restrict the agent role in RBAC. You must give the agent a role that leaves out delete verbs on cluster resources. Many teams start by linking their AI agent to a standard developer account. That account often holds broad cluster rights for daily work. When an AI tool runs with those broad rights, a bad prompt can wipe out live workloads. How native rules work for goose kubernetes prevent delete Kubernetes controls actions through Role-Bas

Kubernetes RBAC + End-to-End Encryption: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

To set up a goose kubernetes prevent delete rule, you restrict the agent role in RBAC. You must give the agent a role that leaves out delete verbs on cluster resources. Many teams start by linking their AI agent to a standard developer account. That account often holds broad cluster rights for daily work. When an AI tool runs with those broad rights, a bad prompt can wipe out live workloads.

How native rules work for goose kubernetes prevent delete

Kubernetes controls actions through Role-Based Access Control on the API server. In this system, all rules are purely additive, and there are no deny rules. You cannot attach a block rule on top of an admin role. Instead, you must build a new role from scratch for the agent.

A Role sets permissions inside a single namespace. A ClusterRole sets permissions across the whole cluster and covers cluster-scoped items like nodes. To link the agent to these rules, you create a RoleBinding or a ClusterRoleBinding. A RoleBinding grants rights inside one namespace, even if it points to a ClusterRole. A ClusterRoleBinding grants those rights across every namespace in the cluster.

To stop deletions, you list only read or update verbs in the role rules. You leave out the delete verb so the API server rejects drop requests. You also need to watch subresources in the API URL. Kubernetes RBAC treats subresources like pod logs or pod exec as separate targets. If you grant pod exec rights, the agent can still run shell commands inside a container.

Where static role setup falls short in live clusters

Native RBAC decides which account can call an API endpoint. It works well when an agent only needs to read pod status or fetch logs. Still, teams often want Goose to fix issues, scale apps, or update configs. Once you grant update or patch rights, static roles show their limits.

An agent with edit rights on deployments cannot delete the deployment object itself. Yet it can still change the replica count to zero or swap in a broken image. If the agent has exec rights on pods, it can delete files inside the running container. Native RBAC only checks the resource and verb at the start of the request. It does not inspect the payload of a patch or the command inside an exec call.

Kubernetes RBAC + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Static roles also stay active at all times on the local machine. If an engineer shares their local kubeconfig with the agent, both share the same standing rights. Teams end up maintaining dozens of custom roles across namespaces to balance safety and speed. They still lack a way to approve risky edits one by one as the agent runs.

Why command-level checks matter for AI agents

AI agents work fast and run many steps in a row. When an agent hits an error, it often tries another path to finish the task. If one command fails, it may try a broader change that causes an outage.

Teams need controls that look at each action while it happens. Checking the exact command lets a human approve a safe update and block a bad one. It also helps keep sensitive data safe when the agent reads cluster outputs. For example, masking rewrites matched fields like emails, phone numbers, card numbers, or national IDs in results.

Add request guardrails and response masking beside Kubernetes

Cluster roles and service accounts govern who reaches the Kubernetes API. Still, a broad role or agent can delete workloads or print sensitive values from ConfigMaps and logs. In practice, hoop.dev runs beside the API server as a sidecar for your Kubernetes API and checks every request and response alongside RBAC.

With hoop.dev Kubernetes controls, guardrails can allow listing Secret names while refusing reads of Secret data before execution. Data masking redacts matched keys in returned JSON responses and log streams in memory. Furthermore, hoop.dev holds SOC 2 Type II and is MIT licensed on GitHub.

Frequently asked questions

Can I add a deny rule to stop Goose from deleting pods?

No, Kubernetes RBAC permissions are purely additive and do not support deny rules. You must create a new Role or ClusterRole that omits the delete verb.

Should I use a RoleBinding or a ClusterRoleBinding for an AI agent?

Use a RoleBinding whenever possible to keep the agent inside a single namespace. A ClusterRoleBinding grants access across the entire cluster, which raises the risk of wide mistakes.

Does blocking the delete verb stop an agent from breaking a pod?

Not if the role includes pod exec or update permissions. An agent can still run destructive commands inside the container or scale a workload down to zero.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.