Description
--audit-log-maxsize sets the size in MB at which the API server rotates its audit log. If you omit the flag, check the default for your API server version.
Potential impact
With a fixed backup count, smaller files cover less history during a spike in traffic. Larger files take more space to store and transfer.
Remediation
- Choose a size your storage and log collector can handle at peak volume. Check it alongside the backup count, age limit and external retention.
- Measure how often files rotate and how far back you can retrieve records.
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-maxsize=50
The log rotates at 50 MB.
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-maxsize=100
At 100 MB the log rotates less often for the same volume of events.