How to Configure Amazon Q Kubernetes Prevent Delete

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up amazon q kubernetes prevent delete, you must restrict cluster roles. You remove delete verbs from the role that the AI agent uses. Most teams run coding assistants using a local shell and user login. When that user holds broad admin rights, the AI assistant inherits them. A bad prompt can then wipe out live pods or whole namespaces. How to set up amazon q kubernetes prevent delete with roles Amazon Q runs commands in your local shell on your behalf. It uses your active cluster login

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 amazon q kubernetes prevent delete, you must restrict cluster roles. You remove delete verbs from the role that the AI agent uses. Most teams run coding assistants using a local shell and user login. When that user holds broad admin rights, the AI assistant inherits them. A bad prompt can then wipe out live pods or whole namespaces.

How to set up amazon q kubernetes prevent delete with roles

Amazon Q runs commands in your local shell on your behalf. It uses your active cluster login to talk to the API server. Because of this, cluster role rules are your main native control.

In Kubernetes, role rules only add rights to a user or group. The system has no deny rules at all. Every permission comes from a Role or a ClusterRole object.

A Role sets rules inside one single namespace. A ClusterRole sets rules across the whole cluster and all namespaces. You link these rules to an identity with a RoleBinding or ClusterRoleBinding.

To stop deletions, you must build a new role from scratch. You list only safe verbs like get, list, and watch. You leave out the delete and deletecollection verbs from every rule.

Next, you bind this safe role to a dedicated user profile. You then make sure your shell uses that restricted profile during AI tasks. When the assistant tries to drop a resource, the API server blocks it.

What native roles solve and what they leave open

Native cluster roles are great for static, full-time limits. If an identity should never drop a pod, omitting that verb works well. The API server checks the role before it runs the request.

Still, this setup creates friction for daily work. Engineers often need to delete stuck pods or clean up old jobs. If you strip delete rights from their main login, their work stops.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Teams then have to switch between two separate cluster profiles all day. One profile is for the AI agent, and one is for human work. In practice, people forget to switch profiles and run the agent as admin.

Also, role rules only check who logs in and what verb they call. They do not inspect the payload or the context of a command in flight. For example, a role can allow exec access to pods as a subresource. Once inside a pod, the agent can run destructive shell commands that RBAC ignores.

Why command-level checks matter for AI assistants

AI tools move fast and generate commands in seconds. Static role files cannot tell a safe cleanup apart from an outage. They also cannot pause a risky delete command to ask for peer review.

Even read-only roles carry data risks when AI agents debug live apps. An agent reading pod logs or config maps might pull sensitive user text. Without in-flight data masking, emails, phone numbers, or card numbers go straight to the model.

To stay safe without maintaining dozens of brittle roles, teams need deeper controls. You need a way to inspect each command right before it runs. That lets you block destructive actions while keeping normal work moving.

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 write a deny rule in Kubernetes to block Amazon Q deletes?

No, Kubernetes role rules are purely additive and do not support deny rules. To block deletions, you must grant a role that omits the delete verb.

Why does Amazon Q have delete rights in my cluster by default?

The assistant runs commands in your local terminal using your current cluster login. If your personal login has cluster admin rights, the agent gets those same rights.

Does removing the delete verb stop all destructive actions in a cluster?

No, a user or agent with pod exec rights can still run shell commands inside containers. Those internal commands can delete files or crash apps without triggering role checks.

The query runs. The emails stay hidden.