Audit policy file is not configured

Configure the audit policy and output to retain necessary API activity records.

Description

--audit-policy-file tells the API server which requests to audit and how much detail to record. Without a policy file, the API server emits no audit events.

Potential impact

Gaps in audit history can leave you unable to identify who changed a resource or when. Different policies across environments can leave different gaps.

Remediation

  • Define the resources, levels and exclusions in an audit policy. Use Metadata when you need a record of access to Secrets without the request body.
  • Mount the policy file, set --audit-policy-file to its path and configure file or webhook output. Send a request covered by the policy and confirm its event arrives.

Examples

These excerpts show the policy argument for v1.34.0. Match the image to your cluster and configure the output separately.

Before

yaml
apiVersion: v1
kind: Pod
metadata:
  name: command-demo
spec:
  containers:
    - name: command-demo-container
      image: registry.k8s.io/kube-apiserver:v1.34.0
      command: ["kube-apiserver"]
      args: []

After

yaml
apiVersion: v1
kind: Pod
metadata:
  name: command-demo
spec:
  containers:
    - name: command-demo-container
      image: registry.k8s.io/kube-apiserver:v1.34.0
      command: ["kube-apiserver"]
      args: ["--audit-policy-file=/etc/kubernetes/audit-policy.yaml"]

The revised manifest reads /etc/kubernetes/audit-policy.yaml. The file must exist at that path inside the API server container.

References