Generating Kubernetes audit logs
Kubernetes audit logs in IBM® Cloud Private.
Kubernetes audit logs are used for tracking and storing data that is related to your IBM Cloud Private usage. Audit policies are used to define the rules for the type of data to be saved in the audit logs. IBM Cloud Private uses the default Kubernetes
audit policy. For more information about the default Kubernetes audit policy, see https://kubernetes.io/docs/tasks/debug-application-cluster/audit/ .
Note: For information about audit data sizes, see Audit logging data statistics.
By default, Kubernetes audit logs are unavailable in IBM Cloud Private. To generate these logs, during installation, set the auditlog_enabled parameter to true in the /<installation_directory>/cluster/config.yaml file. For more information, see Kubernetes settings.
The log files are saved in /var/log/k8saudit/ folder.
Enabling Kubernetes auditing after installation
Complete the following steps enable Kubernetes auditing.
- SSH to the master node as
rootuser. -
Copy
master.jsonfile totmplocation.cp /etc/cfc/pods/master.json /tmp/ -
Edit the copied
master.jsonfile by using any editor. For example:vim /tmp/master.json -
Add the
audit-policy-filepath and theaudit log filepath. The file paths must be under theapiserverconfiguration section and after the last element in the command list."--audit-policy-file=/etc/cfc/conf/audit-policy.yaml", "--audit-log-path=/var/log/k8saudit/audit.log", "--audit-log-maxage=3", "--audit-log-maxbackup=10", "--audit-log-maxsize=10"Note: Add a comma (
,) after last element of command parameters if it is added in the middle. -
Replace the original
master.jsonwith an updated one.cp /tmp/master.json /etc/cfc/pods/master.json -
The master pod picks up the changes and the
kube-apiserverrestarts with auditing enabled.