How to Configure MicroK8s Audit Log
You set up the microk8s audit log by adding an audit rule file to your API server. Then you restart the cluster service so the server writes events to disk. Many teams turn on this log to track who makes changes inside their cluster. Still, broad cluster roles still let users run risky commands before the log records them. A log tells you what went wrong after the fact, but it cannot stop bad commands. How the microk8s audit log works Every action in a cluster goes through the central API ser
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 the microk8s audit log by adding an audit rule file to your API server. Then you restart the cluster service so the server writes events to disk. Many teams turn on this log to track who makes changes inside their cluster. Still, broad cluster roles still let users run risky commands before the log records them. A log tells you what went wrong after the fact, but it cannot stop bad commands.
How the microk8s audit log works
Every action in a cluster goes through the central API server first. When a user or app sends a request, the API server checks the audit rules. The microk8s audit log records each step of that request as a text entry. You must define a rule file that tells the server what to write down. This file sets the logging level for different resources like pods, secrets, and roles.
The server supports four basic logging levels for any incoming request. You can skip logging, log just the header, log the request body, or log the full response. After you write your rule file, you point the API server start arguments to that file path. You also set a file path where the server will save the log entries. You should also set limits on file size and age so logs do not fill your disk. Once you restart the node services, the API server writes matching events to your log file.
Defining rules for cluster events
A good audit rule file balances detail against disk space and speed. If you log the full body of every request, your disk fills up fast. High log volume can also slow down the API server during busy work hours. Most teams log full details only when someone reads or changes sensitive items like secrets. For routine read requests from system apps, teams log only headers or skip them.
You also need a plan to move those log files off the node. If an attacker gains root access on the host, they can delete local files. Teams run a log shipper on the node to send entries to an outside store. This keeps the history safe even if a node crashes or gets wiped.
Audit Log Integrity + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
What native logs solve and what they miss
Native cluster logs give your security team a record of past API calls. They help you pass security checks and find out who changed a resource. If a pod stops working, you can read the log to see recent edits. This setup works well for tracking changes to cluster objects over time.
Still, native logs leave two big gaps open during daily work. First, the API server logs that a user opened a shell session to a pod. It does not log the commands the user types inside that shell session. Second, native logs are passive records that cannot block dangerous actions in flight. If an engineer has a broad admin role, they can delete a live namespace. The log records the deletion, but the damage to your app is already done. Native logs also cannot rewrite sensitive data like emails or card numbers in flight.
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 sits inline beside the API server as a sidecar for your Kubernetes API. For every production API call an agent or human sends, hoop.dev decides whether to pass, mask, block, or escalate it for review alongside RBAC.
With hoop.dev Kubernetes controls, guardrails allow listing Secret names while refusing reads of Secret data before execution, and 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
Where does the cluster store audit files on the node?
The API server saves audit files to the exact folder path you set in its start settings. You pick this folder when you update the server arguments on your host machine.
Does turning on audit logging restart running pods?
Changing the API server settings restarts the control plane service for a few seconds. Your running app pods stay up, but new cluster requests pause until the server comes back.
Can native audit logs capture commands run inside a container shell?
No, the native log only shows that a user opened an exec connection to a pod. It does not capture the terminal commands or output that happen inside that shell.
Related guides
In this post