Este conteúdo não está disponível no idioma selecionado.
Chapter 6. Checking audit logs
You can use audit logs to identify pod security violations.
6.1. Identifying pod security violations through audit logs
You can identify pod security admission violations on a workload by viewing the server audit logs. The following procedure shows you how to access the audit logs and parse them to find pod security admission violations in a workload.
Prerequisites
- 
						You have installed jq.
- You have root access to the node.
Procedure
- To retrieve the node name, run the following command: - <node_name>=$(oc get node -ojsonpath='{.items[0].metadata.name}')- $ <node_name>=$(oc get node -ojsonpath='{.items[0].metadata.name}')- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- To view the audit logs, run the following command: - oc adm node-logs <node_name> --path=kube-apiserver/ - $ oc adm node-logs <node_name> --path=kube-apiserver/- 1 - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- Replace <node_name> with the name of the node retrieved from the previous step.
 - Example output - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- To parse the affected audit logs, enter the following command: - oc adm node-logs <node_name> --path=kube-apiserver/audit.log \ | jq -r 'select((.annotations["pod-security.kubernetes.io/audit-violations"] != null) and (.objectRef.resource=="pods")) | .objectRef.namespace + " " + .objectRef.name + " " + .objectRef.resource' \ | sort | uniq -c - $ oc adm node-logs <node_name> --path=kube-apiserver/audit.log \ | jq -r 'select((.annotations["pod-security.kubernetes.io/audit-violations"] != null) and (.objectRef.resource=="pods")) | .objectRef.namespace + " " + .objectRef.name + " " + .objectRef.resource' \ | sort | uniq -c- 1 - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- Replace <node_name> with the name of the node retrieved from the previous step.