How to Configure n8n Kubernetes Audit Log

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up an n8n kubernetes audit log by defining API server audit rules for your n8n service accounts and namespaces. Then you route those recorded API events to a central log store for review. Teams often run n8n workflows inside a cluster or let workflows call the cluster API. When teams grant broad roles to speed up work, workflows gain too much power. A single bad prompt or broken workflow can then change pods or read secrets across the cluster. How the native n8n kubernetes audit log wo

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 an n8n kubernetes audit log by defining API server audit rules for your n8n service accounts and namespaces. Then you route those recorded API events to a central log store for review. Teams often run n8n workflows inside a cluster or let workflows call the cluster API. When teams grant broad roles to speed up work, workflows gain too much power. A single bad prompt or broken workflow can then change pods or read secrets across the cluster.

How the native n8n kubernetes audit log works

In n8n, workflows and AI Agent nodes run tasks by calling external tools. An n8n AI Agent node pairs a chat model with one or more tool sub-nodes. The agent decides which tool to call to finish a task. Teams often attach an HTTP Request Tool, a Custom Code Tool, or database tool sub-nodes. When n8n interacts with a cluster, it sends requests to the Kubernetes API server.

Kubernetes controls these requests through Role-Based Access Control, known as RBAC. A Role sets permissions within one namespace. A ClusterRole sets permissions across the whole cluster. You link these rules to an n8n service account with a RoleBinding or ClusterRoleBinding. Permissions in Kubernetes RBAC are purely additive, which means there are no deny rules.

As n8n sends API requests, the Kubernetes API server checks the bound roles. At the same time, the API server records each request in its audit log. You set up an audit policy on the API server to choose what to record. The policy can log just basic metadata or the full request and response bodies. You can filter these rules by user, service account, namespace, or resource type. For example, you can log every action taken by the n8n service account. You can also watch specific subresources, such as pod logs or pod exec calls.

What native logging solves and where gaps remain

Native cluster audit logs give security teams a clear history of API server calls. You can see when the n8n service account listed pods or read a secret. You can also see when a workflow ran a command inside a container. This record helps teams check who called the cluster API and when it happened.

Still, native RBAC and cluster audit logs leave two major operational gaps. First, cluster roles only decide who can log in and call an API endpoint. Because RBAC has no deny rules, you cannot block one risky command inside an allowed session. If an n8n agent can exec into a pod, it can run any command there. The native audit policy shows that an exec call started, not what ran inside the shell.

Audit Log Integrity + Kubernetes Audit Logs: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Second, the Kubernetes API server only sees requests that hit the cluster API. Many n8n workflows connect directly to Postgres or MySQL databases using tool sub-nodes. Those database queries travel over the network and bypass the Kubernetes API server completely. Your cluster audit log will not record the SQL statements that the n8n agent ran. It also will not rewrite sensitive fields like emails, phone numbers, or card numbers in query results.

Best practices for scoping n8n cluster roles

Before you rely on audit logs, shrink the permissions given to n8n workflows. Create a dedicated service account for n8n instead of using a default account. Use a Role and RoleBinding to keep n8n inside a single namespace. Avoid ClusterRoleBindings unless a workflow truly must read cluster-wide nodes or resources.

Separate your human admin credentials from the keys used by automated n8n nodes. When you review your audit log, distinct identities make it easy to spot workflow mistakes. Check your logs often to find unused permissions and remove them from the role.

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

Does the Kubernetes audit log capture SQL queries from n8n database nodes?

No. The cluster audit log only records requests sent to the Kubernetes API server. Direct Postgres or MySQL calls from n8n bypass the API server and need database-level logging.

Can I use Kubernetes RBAC to block specific shell commands from n8n?

No. Kubernetes RBAC permissions are purely additive and include no deny rules. Once a role grants access to the pod exec subresource, it cannot filter specific shell commands.

How do I track n8n actions separately from human engineers in cluster logs?

Assign a unique Kubernetes service account or user identity exclusively to your n8n deployment. Every API call in the audit log will then tag that specific service account name.

The query runs. The emails stay hidden.