How to Configure AKS Audit Log

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up an aks audit log by sending Kubernetes API server events to your cloud log sink. This setup records every request that hits the control plane. Teams use these records to track who changed cluster resources and when. Still, broad permissions often flood these logs with noisy or risky actions. When roles grant wide access, engineers can run commands across many namespaces at once. How an aks audit log works with cluster roles To read an aks audit log well, you must first understand K

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 aks audit log by sending Kubernetes API server events to your cloud log sink. This setup records every request that hits the control plane. Teams use these records to track who changed cluster resources and when. Still, broad permissions often flood these logs with noisy or risky actions. When roles grant wide access, engineers can run commands across many namespaces at once.

How an aks audit log works with cluster roles

To read an aks audit log well, you must first understand Kubernetes role rules. The API server checks permissions on every request before it writes the event log. Kubernetes uses a role-based system that is purely additive. There are no deny rules in this model. You start with zero access and add permissions through role objects.

A standard role sets permissions inside a single namespace. A cluster role is not tied to one namespace. It can cover cluster-wide resources like nodes, or resources across every namespace. You attach these rules to users with a role binding or a cluster role binding. A role binding grants access inside one namespace, even if it points to a cluster role. A cluster role binding opens access across the whole cluster.

Every time a user or app makes an API call, the control plane checks these bindings. The aks audit log then records the caller identity, the target resource, and the result. Some API calls target subresources, like pod logs or pod command execution. In role rules, Kubernetes writes these subresources with a slash after the main resource name. The audit record captures hits to both top-level resources and these specific subresources.

Why native cluster roles and audit logs fall short

Native role bindings and audit logs solve the basic problem of tracking API calls. They tell you which user account reached the API server and whether the check passed. If an engineer creates a deployment or reads a secret, the control plane logs that API request. This gives security teams a historical trail of control plane changes.

Yet this native setup leaves a major operational gap during live fixing. Role bindings decide who can start an interactive pod session, not what happens inside it. Once an engineer opens a shell into a running container, the API server only logs the start request. It does not inspect or control the individual shell commands run inside that pod.

Audit Log Integrity + AKS Managed Identity: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

The same problem applies when teams use port forwarding to reach internal databases. The aks audit log shows that a port forward session started on a specific pod. It cannot see the queries run over that tunnel or the sensitive data returned. If a database table holds customer emails, phone numbers, or card numbers, native logs miss that exposure. Also, because permissions are purely additive, teams often hand out wide cluster role bindings during outages. Those broad roles stay in place long after the fix and create standing risk.

Managing subresource access and log noise

Teams often try to tighten subresource rules to make their audit trails cleaner. You can separate permission to view a pod from permission to read its logs. You can also split out the permission to run commands inside a container. This keeps read-only users from running live shells in production namespaces.

Still, managing hundreds of bindings across many clusters takes constant manual review. Engineers need a way to run safe diagnostic commands without holding standing cluster-wide keys. They also need fine-grained controls that act on live requests in flight, rather than just recording API hits after the fact.

Check Kubernetes API requests and responses on the wire

Kubernetes RBAC decides who may call the API server. RBAC does not check response payloads or split listing Secret names from reading Secret values when a role grants get access. With hoop.dev, you run an open-source proxy, a sidecar for your Kubernetes API, inline on the API connection. On every kubectl or API call an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

On each call, hoop.dev guardrails read the method, normalized path, and headers to refuse bad deletes or full Secret reads with a 403 error, or hold risky calls for approval. On the way back, hoop.dev data masking walks JSON responses by key and masks matched values in Secrets, ConfigMaps, and pod logs in memory. View the project on GitHub.

Frequently asked questions

What does an aks audit log capture by default?

It captures requests sent to the Kubernetes API server, including the user, target resource, and status. It records control plane events, but it does not log commands typed inside a pod shell.

Can I use deny rules in Kubernetes RBAC to block risky API calls?

No, Kubernetes RBAC permissions are purely additive and do not support deny rules. To block an action, you must remove the role binding that grants that permission.

How do role bindings affect subresources like pod logs or exec sessions?

Kubernetes treats pod logs and exec sessions as subresources written with a slash after the resource name. You must grant explicit access to those subresources in a role or cluster role.

The query runs. The emails stay hidden.