Find policy violations in reports
Count failed PolicyReport results across the cluster, grouped by policy and rule.
kubectl get polr,cpolr -A -o json | jq -r '.items[].results[] | select(.result=="fail") | "\(.policy)/\(.rule)"' | sort | uniq -c
- tool
- kyverno5 commands
More kyverno commands
-
kubectl apply -f - <<'EOF' apiVersion: kyverno.io/v1 kind: ClusterPolicy metadata: name: add-team-label spec: rules: - name: add-label match: any: - resources: kinds: [Pod] mutate: patchStrategicMerge: metadata: labels: team: "{{request.userInfo.username}}" EOFAdd a team label with the requesting user's name to every new pod; mutate runs before validate.
-
kubectl get cpol,pol -A -o custom-columns='NAME:.metadata.name,ACTION:.spec.validationFailureAction,READY:.status.ready'Show every Kyverno policy with its enforce/audit mode and ready state in one table.
-
kyverno apply policy.yaml --resource resource.yaml --policy-reportRun a policy against a manifest without a cluster and get a PolicyReport you can use as a CI gate.
-
kyverno test ./tests --remove-color -dRun kyverno-test.yaml suites that check pass/fail/skip results; -d shows detailed results.