Interview Prep/DevSecOps/Kubernetes Security

How does Kubernetes audit logging work?

IntermediateConceptKubernetes Security
Answer

The API server records requests according to an audit policy. Levels: None, Metadata (who, what, when), Request (plus request body), RequestResponse (plus response body). Rules are matched top-down; the first match wins.

apiVersion: audit.k8s.io/v1
kind: Policy
omitStages: ["RequestReceived"]
rules:
- level: Metadata
  resources: [{ group: "", resources: ["secrets", "configmaps"] }]
- level: RequestResponse
  resources: [{ group: "rbac.authorization.k8s.io" }]
- level: Metadata

Log Secrets at Metadata only, or you write secret values into logs. On EKS, enable the audit control-plane log type to send it to CloudWatch.

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Kubernetes Security