Kubernetes Audit Logging and Forensics
What you'll learn: How to enable and analyze Kubernetes audit logs to track API requests, detect unauthorized access, and investigate security incidents.
What Are Kubernetes Audit Logs?
Every action in Kubernetes—creating pods, modifying RBAC roles, accessing secrets—flows through the API server. Audit logging records these API requests chronologically, creating a detailed paper trail of who did what, when, and whether it succeeded or failed.
Think of audit logs as a security camera system for your cluster: they don't prevent break-ins, but they tell you exactly what happened, who was involved, and where to look for evidence.
How Audit Logging Works
When enabled, the API server captures each request through configurable audit policies that determine:
- What to log: All requests, only metadata, or full request/response bodies
- What stages to capture: RequestReceived, ResponseStarted, ResponseComplete, Panic
- Which resources matter: You might log all Secret access verbosely but ignore routine health checks
Audit events include the requesting user (or service account), source IP, HTTP verb, resource type, namespace, and outcome. This data is written to log files, sent to a webhook, or streamed to external systems.
Forensic Investigation with Audit Logs
When investigating incidents, audit logs answer critical questions:
- Did someone access sensitive secrets outside normal hours?
- Which service account created that suspicious pod?
- Was there an unauthorized RBAC change before the breach?
- What API calls preceded the container escape?
By correlating audit events with runtime security alerts, network traffic, and pod logs, you reconstruct the attack timeline and identify compromised credentials or privilege escalation paths.
Key Takeaway: Kubernetes audit logging creates an immutable record of all API server activity, enabling detection of unauthorized access patterns and providing the forensic evidence needed to investigate security incidents and understand attacker behavior.