Interview Prep/DevSecOps/Kubernetes Security Posture

How do you design the Kubernetes audit policy so it is useful without being enormous?

IntermediateProductionKubernetes Security Posture
Answer

Log metadata for most things, request bodies for sensitive writes, and nothing for noisy read-only traffic.

apiVersion: audit.k8s.io/v1
kind: Policy
omitStages: ["RequestReceived"]
rules:
- level: None
  users: ["system:kube-proxy"]
  verbs: ["watch"]
- level: Metadata
  resources: [{group: "", resources: ["secrets", "configmaps"]}]
- level: RequestResponse
  verbs: ["create", "update", "patch", "delete"]
  resources: [{group: "rbac.authorization.k8s.io"}]
- level: Request
  verbs: ["create"]
  resources: [{group: "", resources: ["pods/exec", "pods/attach", "pods/portforward"]}]
- level: Metadata

Never log Secrets at Request level, or the audit log becomes a secret store. On EKS the policy is fixed by AWS, so focus on shipping and alerting.

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Kubernetes Security Posture