This topic describes audit logging in Tanzu Kubernetes Grid (TKG).
In Tanzu Kubernetes Grid, you can access the following audit logs:
auditd
. See System Audit Logs for Nodes below.Kubernetes audit logs record requests to the Kubernetes API server.
Audit logs are enabled by default for the Supervisor and the workload clusters that it deploys.
To enable Kubernetes auditing on a standalone management cluster or a workload cluster it deploys, set the ENABLE_AUDIT_LOGGING
variable to true
before you deploy the cluster.
ImportantEnabling Kubernetes auditing can result in very high log volumes. To handle this quantity, VMware recommends using a log forwarder such as Fluent Bit. For instructions, see Install Fluent Bit for Log Forwarding.
You can control what the audit logs include by passing audit policy files to kube-apiserver
as explained below.
By default, audit log entries for a cluster are written to the following location on its control plane nodes:
/var/log/kubernetes/audit.log
/var/log/vmware/audit/kube-apiserver.log
/var/log/kubernetes/kube-apiserver.log
You can customize these locations by setting --audit-log-path
in the audit log configuration.
If you deploy Fluent Bit on the cluster, it will forward the logs to your log destination.
To exert fine-grained control over what is being logged, you can create audit policy files and pass them in to the kube-apiserver with the --audit-policy-file
flag.
To see the audit log configuration for a cluster, including the audit log location, in the following locations:
Standalone management cluster and its workload clusters:
/etc/kubernetes/audit-policy.yaml
on control plane nodes~/.config/tanzu/tkg/providers/ytt/03_customizations/audit-logging/audit_logging.yaml
on your bootstrap machineSupervisor and its workload clusters: Kube API server settings in /etc/kubernetes/manifest/kube-apiserver.yaml
on control plane nodes. For example:
Supervisor:
- kube-apiserver
[...]
- --audit-log-maxage=30
- --audit-log-maxbackup=10
- --audit-log-maxsize=100
- --audit-log-path=/var/log/vmware/audit/kube-apiserver.log
- --audit-policy-file=/etc/vmware/wcp/audit-policy.yaml
Workload cluster:
- kube-apiserver
[...]
- --audit-log-maxage=30
- --audit-log-maxbackup=10
- --audit-log-maxsize=100
- --audit-log-path=/var/log/kubernetes/kube-apiserver.log
- --audit-policy-file=/etc/kubernetes/extra-config/audit-policy.yaml
When you deploy a standalone management or workload cluster, auditd
is enabled on the cluster by default. You can access your system audit logs on each node in the cluster by navigating to /var/log/audit/audit.log
.
If you deploy Fluent Bit on the cluster, it will forward these audit logs to your log destination. For instructions, see Install Fluent Bit for Log Forwarding.