kubernetes: kube-apiserver audit log rotation throwing permission denied
What happened: I’m setting up integration with the Splunk logforwarder agent to stream our Kubernetes audit logs from our master nodes to Splunk Enterprise but I’m seeing an odd issue in our logs, where the kube-apiserver process says permission denied when trying to rotate the logs once they’ve reached maximum capacity.
kube-apiserver[1574]: E1105 18:43:54.090393 1574 metrics.go:86] Error in audit plugin 'log' affecting 1 audit events: can't open new logfile: open /var/lib/audit.log: permission denied
What you expected to happen: I expect the logs to be rotated without issue, though there seems to be a failure in our situation.
How to reproduce it (as minimally and precisely as possible): I’ve only observed the problem once enabling the Splunk logforwarder and pointing it to the audit log file. I’ve confirmed on the Splunk side, that the forwarder agent shouldn’t be locking the file in any way and should be doing a read only operation.
I’ve confirmed I can use root privileges to rename the file myself, but then I get a subsequent permission denied error with creating the new file (can't open new logfile: open /var/lib/audit.log: permission denied). From there, if I do touch audit.log then it begins to write to the file again as expected.
Anything else we need to know?:
Environment:
- Kubernetes version (use
kubectl version):Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.7", GitCommit:"dd5e1a2978fd0b97d9b78e1564398aeea7e7fe92", GitTreeState:"clean", BuildDate:"2018-04-19T00:05:56Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"} Server Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.7", GitCommit:"dd5e1a2978fd0b97d9b78e1564398aeea7e7fe92", GitTreeState:"clean", BuildDate:"2018-04-18T23:58:35Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"} - Cloud provider or hardware configuration: AWS/EC2
- OS (e.g. from /etc/os-release):
VERSION="16.04.5 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.5 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
- Kernel (e.g.
uname -a):Linux *** 4.4.0-1070-aws #80-Ubuntu SMP Thu Oct 4 13:56:07 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux - Install tools:
- Others:
/kind bug
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (3 by maintainers)
I am not sure if this is related, I had a similar issue recently with the rotation of kube-apiserver audit logs. The error I received, however was:
It turned out that I was mounting only the file to the kube-apiserver pod and therefore the container was unable to rename it. You can check if this is your case also.
This fixed my issue:
Ok guys @arun2arunraj @arpitaashu .I’ve sorted it out. Here’s my manifest.