executing-plans
executing-plans
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available
kyverno-policy-report-overrideManages PolicyReport overrides using Kyverno's failureActionOverrides, report configuration, and CEL-based conditions to customize compliance reporting per resource.
Independent GitHub snapshot · Automated classification · Original documentation governs
name: kyverno-policy-report-override description: Manages PolicyReport overrides using Kyverno's failureActionOverrides, report configuration, and CEL-based conditions to customize compliance reporting per resource. license: MIT compatibility: opencode archetypes:
Manages PolicyReport overrides using Kyverno's failureActionOverrides, report configuration, and CEL-based conditions to customize compliance reporting per resource without disabling policies globally.
failureActionOverrides to escalate or de-escalate enforcement per resource or namespacePolicyReport comments or via annotation-based justificationresourceSelectors — never apply globallyvalidate rules to create dynamic report resultsPolicyReport after deploymentUse this skill when:
Audit to Enforce for critical namespaces (e.g., production) while keeping it as Audit for developmentEnforce to Audit for a specific resource that has a documented exception or temporary compliance waiverhigh severity for compliance-sensitive namespaces and medium for internal onesAvoid this skill for:
kyverno-exemptions-management instead for full exemptionsClusterPolicy validation with report-only rules — report overrides adjust enforcement behavior, they do not replace validationkyverno-cleanup-policies instead)Identify override needs — Determine which policies need per-resource enforcement adjustments. Categorize as escalation (Audit → Enforce) or de-escalation (Enforce → Audit). Document which resources and namespaces are affected. Checkpoint: Create a mapping of policy → namespace → action (Enforce/Audit) with justification.
Configure failureActionOverrides on the rule — Add a failureActionOverrides list to the desired rule. Each entry specifies an action (Enforce or Audit) and resourceSelectors that narrow the override to specific namespaces and resource kinds. Checkpoint: Verify the override targets only the intended resources using the selector.
Set match conditions — Ensure the rule's match block correctly identifies the resources that should be evaluated. The failureActionOverrides layer sits on top of the match, so resources outside the match scope are unaffected. Checkpoint: Test with a resource that should match and one that should not.
Add CEL-based report conditions — Where available, use CEL expressions in validate rules to create dynamic policy results. This allows conditions like has(request.object.metadata.labels['critical']) to trigger different behaviors. Checkpoint: Validate CEL syntax with kyverno apply --resource <file> before deployment.
Verify overridden results in PolicyReport — Apply the ClusterPolicy, create test resources that trigger overrides, and verify the PolicyReport reflects the escalated or de-escalated action. Checkpoint: Check result field shows the expected enforcement mode and severity is correct.
This pattern escalates a policy from Audit to Enforce for critical namespaces while keeping it as Audit for all others. The policy is defined globally but enforcement behavior varies by namespace.
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: resource-constraints-with-escalation
annotations:
policies.kyverno.io/title: Resource Constraints with Escalation
policies.kyverno.io/category: Pod Security
policies.kyverno.io/severity: high
policies.kyverno.io/description: >-
Validate that all containers and initContainers define CPU and memory
resource limits and requests. Escalated to Enforce in production
namespaces; Audit for all others.
policies.kyverno.io/minversion: 1.12.0
spec:
validationFailureAction: Audit
background: true
rules:
- name: validate-resource-constraints
match:
any:
- resources:
kinds:
- Pod
exclude:
any:
- namespaces:
- kube-system
- kyverno
- kube-public
failureActionOverrides:
- action: Enforce
resourceSelectors:
- namespace: production
kinds:
- Pod
- action: Enforce
resourceSelectors:
- namespace: staging
kinds:
- Pod
validate:
message: "Containers and initContainers must define both resource limits and requests."
pattern:
spec:
containers:
- resources:
limits:
cpu: "?*"
memory: "?*"
requests:
cpu: "?*"
memory: "?*"
initContainers:
- resources:
limits:
cpu: "?*"
memory: "?*"
requests:
cpu: "?*"
memory: "?*"
Pattern notes:
validationFailureAction: Audit means no pods are blocked by defaultfailureActionOverrides escalates specific namespaces to Enforce — pods violating the policy in production or staging are rejecteddevelopment, testing) remain in Audit mode — violations are reported but not blockedThis pattern de-escalates a policy from Enforce to Audit for specific resources that have a documented exception. Used for legacy workloads transitioning to compliance.
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: image-registry-enforcement
annotations:
policies.kyverno.io/title: Image Registry Enforcement
policies.kyverno.io/category: Pod Security
policies.kyverno.io/severity: high
policies.kyverno.io/description: >-
Require that all container images come from approved registries.
Legacy workloads with the 'legacy-exception' label are audited only.
policies.kyverno.io/minversion: 1.12.0
spec:
validationFailureAction: Enforce
background: true
rules:
- name: validate-image-registry
match:
any:
- resources:
kinds:
- Pod
exclude:
any:
- namespaces:
- kube-system
- kyverno
failureActionOverrides:
- action: Audit
resourceSelectors:
- namespace: legacy-migration
kinds:
- Pod
validate:
message: >-
Container images must be pulled from approved registries:
gcr.io/myproject, docker.io/myorg, quay.io/myorg.
pattern:
spec:
containers:
- image: "gcr.io/myproject/*"
| "docker.io/myorg/*"
| "quay.io/myorg/*"
Pattern notes:
Enforce — all pods must use approved registrieslegacy-migration namespace are de-escalated to Audit onlyCEL (Common Expression Language) conditions in Kyverno allow dynamic decision-making based on resource attributes. This pattern uses CEL to evaluate conditions and produce different report results.
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: dynamic-compliance-reporting
annotations:
policies.kyverno.io/title: Dynamic Compliance Reporting
policies.kyverno.io/category: Compliance
policies.kyverno.io/severity: high
policies.kyverno.io/description: >-
Apply dynamic compliance reporting based on resource labels and
namespace annotations. Critical namespaces escalate to Enforce with
high severity; internal namespaces use Audit with medium severity.
policies.kyverno.io/minversion: 1.12.0
spec:
validationFailureAction: Audit
background: true
rules:
- name: validate-compliance-level
match:
any:
- resources:
kinds:
- Pod
exclude:
any:
- namespaces:
- kube-system
- kyverno
failureActionOverrides:
- action: Enforce
resourceSelectors:
- namespace: production
kinds:
- Pod
- action: Audit
resourceSelectors:
- namespace: development
kinds:
- Pod
validate:
message: "Pod must have resource limits and requests defined."
pattern:
spec:
containers:
- resources:
limits:
cpu: "?*"
memory: "?*"
requests:
cpu: "?*"
memory: "?*"
- name: dynamic-result-with-cel
match:
any:
- resources:
kinds:
- Pod
validate:
message: "Critical pods must define resource constraints."
audit:
any:
- conditions:
all:
- key: "{{ request.object.metadata.labels['critical'] }}"
operator: InEquivalenceCheck
value: "true"
- key: "{{ request.object.spec.containers[0].resources.limits.cpu }}"
operator: NotEquals
value: ""
deny:
conditions:
all:
- key: "{{ request.object.metadata.labels['critical'] }}"
operator: InEquivalenceCheck
value: "true"
- key: "{{ request.object.spec.containers[0].resources.limits.memory }}"
operator: Equals
value: ""
Pattern notes:
audit block with CEL conditions produces a report entry when the condition matches (critical pod with limits present)deny block with CEL conditions produces a report entry when the condition fails (critical pod missing memory limits)request.object.metadata and request.object.spec fieldsThis shows what the PolicyReport looks like when failureActionOverrides produce different results per namespace.
apiVersion: wgpolicyk8s.io/v1alpha2
kind: PolicyReport
metadata:
name: resource-constraints-report
namespace: production
results:
- policy: resource-constraints-with-escalation
rule: validate-resource-constraints
result: fail
severity: high
message: "Containers and initContainers must define both resource limits and requests."
scored: true
source: kyverno
timestamp:
seconds: 1733501530
summary:
error: 0
fail: 1
pass: 0
skip: 0
warn: 0
---
apiVersion: wgpolicyk8s.io/v1alpha2
kind: PolicyReport
metadata:
name: resource-constraints-report
namespace: development
results:
- policy: resource-constraints-with-escalation
rule: validate-resource-constraints
result: pass
severity: medium
message: "Pod validation is in Audit mode — results reported but not enforced."
scored: true
source: kyverno
timestamp:
seconds: 1733501530
summary:
error: 0
fail: 0
pass: 1
skip: 0
warn: 0
Verification command:
# View PolicyReports across all namespaces
kubectl get policyreports -A
# View specific PolicyReport with detailed results
kubectl get policyreports -n production -o yaml
# Check generate rule status for network policies
kyverno generate-report --report-name generate-default-deny-network-policy --report-namespace production
failureActionOverrides for per-resource escalation or de-escalation — never apply overrides globally without resourceSelectorsannotations field (e.g., policies.kyverno.io/override-reason) so compliance teams understand the justificationresourceSelectors with namespace and kind filters — always target the narrowest scope possibleAudit as the base validationFailureAction when applying escalation, so non-escalated namespaces remain in audit modePolicyReport after deployment using kubectl get policyreports -AEnforce and Audit actions in overrides when implementing phased rollout (some namespaces enforce, others audit)PolicyReport or policy annotation must explain whykube-system namespace resources — the control plane should not be subject to custom enforcement overridesEnforce and Audit on the same rule without clear resourceSelectors — this makes it impossible to determine which enforcement mode applies to which resource| Skill | Purpose |
|---|---|
kyverno-exemptions-management | Full exemption management for resources that should not be subject to policy enforcement |
kyverno-cleanup-policies | Manage resource lifecycle and cleanup policies for stale or orphaned resources |
Authoritative documentation links for Kyverno PolicyReport override and compliance reporting.