How to Configure n8n Kubernetes Prevent Delete
To set up an n8n kubernetes prevent delete workflow, you must restrict Kubernetes RBAC roles. You give the workflow service account read and update rights, while leaving out delete rights. Many teams start by giving automation tools broad cluster admin roles to move fast. When an automated workflow or AI agent holds broad rights, one bad call drops live workloads. A broken prompt or bad input can wipe out pods, services, or whole namespaces. How native rules work for n8n kubernetes prevent del
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 an n8n kubernetes prevent delete workflow, you must restrict Kubernetes RBAC roles. You give the workflow service account read and update rights, while leaving out delete rights. Many teams start by giving automation tools broad cluster admin roles to move fast. When an automated workflow or AI agent holds broad rights, one bad call drops live workloads. A broken prompt or bad input can wipe out pods, services, or whole namespaces.
How native rules work for n8n kubernetes prevent delete
In n8n, workflows and AI Agent nodes call outside APIs to finish their tasks. The n8n AI Agent node pairs a chat model with one or more tool sub-nodes. The agent then decides which tool to call based on user input. Teams often link an HTTP Request Tool or Custom Code Tool to reach the Kubernetes API. They also call child workflows using the Call n8n Workflow Tool to run cluster tasks.
On the Kubernetes side, Role-Based Access Control governs what that API token can do. Kubernetes RBAC rules are purely additive, which means there are no explicit deny rules. You cannot attach a block rule on top of an existing admin role. Instead, you must build a new Role or ClusterRole from scratch. You list only the safe actions you want the workflow to run, like get or list. You leave the delete verb off the rule list to stop resource removal.
A Role sets permissions inside one single namespace. A ClusterRole sets permissions across the whole cluster or for cluster-wide items like nodes. After you write the Role, you link it to the n8n account with a RoleBinding. If you use a ClusterRole for all namespaces, you link it with a ClusterRoleBinding. When n8n sends an API call, Kubernetes checks the bound role before running the task. If the delete verb is missing from the role, the API server blocks the delete call.
What native RBAC solves and where gaps remain
Setting up additive RBAC roles stops direct delete calls against the Kubernetes API. If an n8n workflow tries to remove a pod, the API server rejects the request. This setup protects top-level cluster objects from accidental removal by a workflow. It also limits the blast radius if a workflow token leaks to an attacker.
Still, static RBAC roles only check who logs in and which API endpoint they hit. They do not inspect what happens inside allowed subresources or active sessions. For example, Kubernetes treats pod log reading and pod command execution as subresources. If a workflow needs to run scripts inside a container, it needs pod exec permissions. Once RBAC grants pod exec rights, Kubernetes cannot filter the shell commands sent inside that session. An n8n agent could still run a file delete command inside the running container.
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 struggle when workflows need temporary write or cleanup rights during incidents. Teams either keep permanent high privileges active or spend time editing role bindings by hand. Native RBAC also does not mask sensitive fields in API output returned to the agent. If a pod log or config map holds emails, phone numbers, or card numbers, n8n reads them raw. National IDs in log lines also pass straight into the chat model context without masking.
Why shared workflow tokens create audit blind spots
Most teams store one static Kubernetes token inside the n8n credential store. Every user and every workflow that uses that credential shares the same cluster identity. When you check the Kubernetes logs, every action looks like it came from one machine account. You cannot tell which engineer triggered the workflow or which AI prompt caused a change.
Also, n8n workflows often mix safe read steps with risky state changes in one flow. Native Kubernetes RBAC cannot pause a single high-risk API call to ask a human for approval. The API server either allows the call right away or rejects it with an error. Teams need a way to inspect commands in flight and tie actions to real user identities.
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 in Kubernetes RBAC to block deletes?
No, Kubernetes RBAC rules are purely additive and do not support deny rules. To block deletes, you must create a new Role that omits the delete verb.
How do n8n AI agents talk to a Kubernetes cluster?
An n8n AI Agent node uses attached tool sub-nodes like the HTTP Request Tool. The agent decides when to call the tool to send requests to the Kubernetes API.
Why can an n8n workflow still delete files if RBAC blocks pod deletion?
Blocking pod delete only stops the API from removing the pod object itself. If the role allows the pod exec subresource, commands inside the container can still delete files.
Related guides
In this post