Review Kubernetes audit log retention settings

Match actual audit record retention to investigation and operational needs.

Description

--audit-log-maxage sets the maximum age of rotated API server audit files, in days. With 0, age alone never triggers deletion. If you omit the flag, the API server uses its version’s default.

Potential impact

Short retention can erase evidence before an investigation starts. Long retention uses more disk space and leaves sensitive records accessible for longer.

Remediation

  • Set the age limit to the history you need. Check whether the file count, file size and log volume leave that much history after rotation.
  • Retrieve a record from the oldest day you need, locally or from your log collector. For managed control planes, check the provider’s retention settings.

Examples

These v1.30.0 excerpts show one flag. File logging also needs an audit policy, --audit-log-path and a writable log volume.

Before

yaml
apiVersion: v1
kind: Pod
metadata:
  name: kube-apiserver
spec:
  containers:
    - name: kube-apiserver
      image: registry.k8s.io/kube-apiserver:v1.30.0
      command:
        - kube-apiserver
      args:
        - --audit-log-maxage=26

Rotated files become eligible for age-based deletion after 26 days.

After

yaml
apiVersion: v1
kind: Pod
metadata:
  name: kube-apiserver
spec:
  containers:
    - name: kube-apiserver
      image: registry.k8s.io/kube-apiserver:v1.30.0
      command:
        - kube-apiserver
      args:
        - --audit-log-maxage=30

The age limit increases to 30 days. The file-count limit can still remove logs sooner.

References