How to Configure AutoGen Kubernetes Prevent Delete

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up autogen kubernetes prevent delete controls by building custom RBAC roles without delete verbs. Then you bind those limited roles to the identity your agent uses to run commands. Many teams start by giving AI agents broad cluster roles to speed up testing. If an agent hallucinates a bad command, broad roles let it wipe out workloads. How autogen kubernetes prevent delete works in native RBAC AutoGen agents run code and shell commands on behalf of your engineering team. When an agent

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 autogen kubernetes prevent delete controls by building custom RBAC roles without delete verbs. Then you bind those limited roles to the identity your agent uses to run commands. Many teams start by giving AI agents broad cluster roles to speed up testing. If an agent hallucinates a bad command, broad roles let it wipe out workloads.

How autogen kubernetes prevent delete works in native RBAC

AutoGen agents run code and shell commands on behalf of your engineering team. When an agent manages a cluster, it sends API calls using a local credential. Kubernetes checks every API call against its native role-based access control system. In Kubernetes RBAC, rules are additive, and there are no deny rules at all.

Because there are no deny rules, you cannot simply block the delete verb on an admin role. You must build a fresh Role or ClusterRole from scratch. A Role sets permissions inside one namespace, while a ClusterRole covers the whole cluster. You list only safe verbs like get, list, watch, create, and patch in that role.

Next, you connect that role to the agent identity with a RoleBinding or ClusterRoleBinding. A RoleBinding grants access inside a single namespace, even if it points to a ClusterRole. A ClusterRoleBinding grants those permissions across every namespace in the cluster. If the agent tries to delete a pod or deployment, the API server rejects the call.

What native RBAC solves and what it leaves open

Native RBAC stops direct resource deletion at the API level. If an AutoGen agent runs a delete command, Kubernetes blocks it right away. This setup works well when an agent only needs to read logs or check pod status. You can grant access to the pods log subresource and leave out write verbs.

Still, real agent workflows often need more than read-only access to fix issues. Agents often need to update configs, scale deployments, or run commands inside containers. Native RBAC decides who can log in and which API endpoints they can call. It does not inspect what individual commands or payloads do in flight.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

For example, an agent with patch or update rights can still break a live workload. It can set replicas to zero or replace a valid container image with a broken tag. Worse, if you grant access to the pods exec subresource, the agent can open a shell. Inside that container shell, Kubernetes RBAC cannot see or stop destructive shell commands.

Why static credentials increase risk for AI agents

To use native RBAC, the machine running AutoGen needs a local kubeconfig file or token. Any process or script in that workspace can read that static key. If the agent writes and runs new code, that code inherits the exact same cluster rights. You cannot pause a single risky command for human approval using static RBAC roles alone.

Teams also struggle to audit which prompt or task caused a specific cluster change. The Kubernetes audit log only shows the shared service account or user name. It does not link the API call back to the specific agent session or user request. Also, if pod logs contain emails, phone numbers, or card numbers, RBAC sends them in plain text.

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 runs as an open-source proxy, a sidecar for your Kubernetes API, checking requests and responses without replacing RBAC.

First, hoop.dev guardrails refuse banned methods, paths, or headers before they run. 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

Can I add a deny rule in Kubernetes RBAC to stop agent deletes?

No, Kubernetes RBAC permissions are additive and do not support deny rules. To block deletes, you must create a new role that leaves out the delete verb.

Does blocking the delete verb stop an AutoGen agent from breaking pods?

Not always, because an agent with update or patch access can still scale replicas to zero. If the agent has exec rights, it can also run destructive commands inside the container.

Should I use a Role or a ClusterRole for an AutoGen agent?

Use a namespaced Role and RoleBinding whenever the agent only works in one namespace. This limits the blast radius so the agent cannot touch resources in other namespaces.

The query runs. The emails stay hidden.