How to Configure K3s Audit Log

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a k3s audit log by passing a policy file to the server. Then you point the server to a log file path on the host disk. Most teams turn this on by editing the main server start script on each node. They write a basic rule file that records every cluster API call to disk. When cluster roles are too broad, this log fills up with huge amounts of text. Admin keys let users run any action, and the log only shows the shared role. How the native k3s audit log works K3s packs the core Kuber

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 a k3s audit log by passing a policy file to the server. Then you point the server to a log file path on the host disk. Most teams turn this on by editing the main server start script on each node. They write a basic rule file that records every cluster API call to disk. When cluster roles are too broad, this log fills up with huge amounts of text. Admin keys let users run any action, and the log only shows the shared role.

How the native k3s audit log works

K3s packs the core Kubernetes API server into a single small file for edge nodes. It does not turn on API event logging out of the box to save space. To start logging, the admin creates a policy rule file on the host machine. This rule file tells the API server which events to save and which to skip. You can pick from four detail levels for each type of cluster resource.

The lowest level skips the event and writes nothing to the disk at all. The next level saves basic headers like the user name, timestamp, and action type. Higher levels save the full request body and the full answer from the server. After you write the policy, you pass its file path to the K3s server process. You also set limits for file size, file age, and old file backups. When a user or app sends an API call, the server checks the rules first. It writes the matching event details to the local text file before finishing the request.

What native logging solves and where it falls short

The native log helps teams see which cluster objects changed and when the change happened. If a pod vanishes, you can read the log to find the delete call. It also captures failed login tries and blocked role checks across the whole cluster. This history is great for reviewing past bugs or proving that basic rules exist.

Still, the native setup leaves a major operational gap for growing teams. Cluster roles only check who logs in and which broad resource types they can touch. They do not inspect or control what individual commands do inside a running pod. If an engineer opens a shell into a pod, the API log just shows a session start. It does not record the shell commands they run or the data they read inside. Also, full request logging writes secret values and private data straight to the host disk. Teams often share one admin key, so the log cannot tell which real person acted. Native logging only records the past and cannot stop a risky command in flight.

Audit Log Integrity + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Best practices for filtering cluster events

Start by ignoring read requests from core system parts and local node agents. These parts poll the server every second and will fill your hard drive very fast. Set your rules to capture only header data for secret objects and config maps. If you log the full body for secrets, plain text keys end up in logs. Focus full request logging on write, update, and delete actions made by human users. Ship the local log files off the node to a central store right away. If an attacker takes over the node, they can wipe local files to hide tracks. Keep your rule file small so the server does not slow down during busy times.

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

Does the k3s audit log slow down small edge nodes?

Yes, logging every full request body uses extra memory and disk write speed. You can avoid slowdowns by logging only headers for most normal cluster read calls.

Where does K3s store the log files on the server?

K3s saves the files in the exact host folder path you set at startup. You must pick this path yourself and set up file rotation rules to save disk space.

Can the native log show commands typed inside a pod shell?

No, the API server only logs the initial request that opens the pod shell connection. It cannot see or record the actual terminal commands the user runs inside that session.

The query runs. The emails stay hidden.