How to Configure Make Kubernetes Prevent Delete
To make kubernetes prevent delete actions, you remove the delete verb from your RBAC roles. Because permissions are additive, leaving out delete blocks users from removing resources. Many teams start by giving engineers broad cluster roles to speed up work. When roles are too broad, a single wrong command can wipe out live apps. Teams must build tight role rules from the start to avoid accidental data loss. How to make kubernetes prevent delete with RBAC Kubernetes uses Role-Based Access Cont
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 make kubernetes prevent delete actions, you remove the delete verb from your RBAC roles. Because permissions are additive, leaving out delete blocks users from removing resources. Many teams start by giving engineers broad cluster roles to speed up work. When roles are too broad, a single wrong command can wipe out live apps. Teams must build tight role rules from the start to avoid accidental data loss.
How to make kubernetes prevent delete with RBAC
Kubernetes uses Role-Based Access Control to manage what users and apps can do. The API server checks these rules every time someone sends a request. In this system, permissions are purely additive. There are no deny rules in native RBAC. To stop someone from deleting a resource, you never grant them that permission.
You set up these rules using two main objects. A Role sets permissions inside a single namespace. A ClusterRole sets permissions across the whole cluster. It can cover cluster-wide items like nodes, or namespaced items across every namespace. Inside a Role or ClusterRole, you list the resources and the allowed verbs.
To allow safe work, you give users read and update verbs for their pods. You leave the delete verb off the list. Next, you connect the role to a user or team. A RoleBinding grants those permissions inside one specific namespace. A ClusterRoleBinding grants the permissions across the entire cluster. A RoleBinding can also point to a ClusterRole to reuse rules in one namespace.
You also need to watch out for subresources in the API. The API writes subresources with a slash, such as pod logs or pod exec. If you grant access to pod exec, a user can run commands inside a container. Even if they cannot delete the pod, they might delete files inside it. You must keep subresource rules tight as well.
What native RBAC solves and what it leaves open
Native RBAC is great for drawing clear lines between namespaces and teams. It stops unauthorized users from calling the delete API on protected resources. When a user without the delete verb tries to remove a pod, the API server blocks it. This setup protects your cluster from basic mistakes at the API level.
Still, static roles leave a big gap during live incidents. Because RBAC has no deny rules, you cannot add a quick block over an admin role. If a user holds any binding with the delete verb, they can still remove objects. Auditing all bindings across a big cluster takes a lot of time.
Kubernetes RBAC + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Also, RBAC only checks who logs in and which API endpoint they hit. It does not inspect what happens inside an active pod exec session. Once a user opens a shell in a pod, RBAC steps back. It cannot see or stop dangerous commands running inside that container.
Why static role management struggles during live fixes
During an outage, engineers often need extra rights to fix a broken app. With static RBAC, admins have to edit role bindings by hand to grant help. Often, they bind a broad ClusterRole to fix the issue fast. While that binding is active, nothing stops an accidental delete command.
After the fix, teams often forget to remove those extra role bindings. Over time, permissions grow too wide again, and the risk of a bad delete returns. Teams need a way to check commands in flight without relying only on static roles.
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
Does Kubernetes RBAC have an explicit deny rule for deletes?
No, Kubernetes RBAC rules are purely additive and have no deny rules. To block deletes, you must omit the delete verb from every role bound to that user.
What is the difference between a Role and a ClusterRole when restricting deletes?
A Role applies allowed verbs only within a single namespace. A ClusterRole applies rules to cluster-wide resources or across all namespaces at once.
Can a user without pod delete permissions still break an app via subresources?
Yes, if their role includes the pod exec subresource, they can run commands inside the container. RBAC authorizes the subresource call but does not filter the shell commands inside it.
Related guides
In this post