此内容没有您所选择的语言版本。

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

  1. To retrieve the node name, run the following command:

    $ <node_name>=$(oc get node -ojsonpath='{.items[0].metadata.name}')
    Copy to Clipboard Toggle word wrap
  2. To view the audit logs, run the following command:

    $ oc adm node-logs <node_name> --path=kube-apiserver/ 
    1
    Copy to Clipboard Toggle word wrap
    1
    Replace <node_name> with the name of the node retrieved from the previous step.

    Example output

    rhel-94.lab.local audit-2024-10-18T18-25-41.663.log
    rhel-94.lab.local audit-2024-10-19T11-21-29.225.log
    rhel-94.lab.local audit-2024-10-20T04-16-09.622.log
    rhel-94.lab.local audit-2024-10-20T21-11-41.163.log
    rhel-94.lab.local audit-2024-10-21T14-06-10.402.log
    rhel-94.lab.local audit-2024-10-22T06-35-10.392.log
    rhel-94.lab.local audit-2024-10-22T23-26-27.667.log
    rhel-94.lab.local audit-2024-10-23T16-52-15.456.log
    rhel-94.lab.local audit-2024-10-24T07-31-55.238.log
    Copy to Clipboard Toggle word wrap

  3. 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 
    1
    Copy to Clipboard Toggle word wrap
    1
    Replace <node_name> with the name of the node retrieved from the previous step.
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat