Skip to content

Instantly share code, notes, and snippets.

@developer-guy
Created December 30, 2020 19:17
Show Gist options
  • Save developer-guy/abeffa8b3b2735fe579d6600bacd8110 to your computer and use it in GitHub Desktop.
Save developer-guy/abeffa8b3b2735fe579d6600bacd8110 to your computer and use it in GitHub Desktop.
Kubernetes Audit Policy
apiVersion: audit.k8s.io/v1
kind: Policy
rules:
# do not log requests to the following
- level: None
nonResourceURLs:
- "/healthz*"
- "/logs"
- "/metrics"
- "/swagger*"
- "/version"
# limit level to Metadata so token is not included in the spec/status
- level: Metadata
omitStages:
- RequestReceived
resources:
- group: authentication.k8s.io
resources:
- tokenreviews
# extended audit of auth delegation
- level: RequestResponse
omitStages:
- RequestReceived
resources:
- group: authorization.k8s.io
resources:
- subjectaccessreviews
# log changes to pods at RequestResponse level
- level: RequestResponse
omitStages:
- RequestReceived
resources:
- group: "" # core API group; add third-party API services and your API services if needed
resources: ["pods"]
verbs: ["create", "patch", "update", "delete"]
# log everything else at Metadata level
- level: Metadata
omitStages:
- RequestReceived
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment