Kyverno policy fails when MinIO operator deployment doesn't exist during certificate renewal

While working on !4595 (merged), I noticed that mgmt-policy-report job failed with:

policyreport 288cd200-ea4c-4651-8bc4-eb5cb75dc177 in minio-operator namespace was in FAIL/WARN/ERROR
scope:
  apiVersion: v1
  kind: Secret
  name: sts-tls
  namespace: minio-operator
  uid: 288cd200-ea4c-4651-8bc4-eb5cb75dc177
results:
  - message: ': deployments.apps "minio-operator" not found'
    policy: minio-operator/restart-minio-operator-on-cert-renewal
    properties:
      process: background scan
    result: error
    rule: minio-operator-restart-on-sts-change
    scored: true
    source: kyverno
    timestamp:
      nanos: 0
      seconds: 1749631686

The policy attempts to mutate the minio-operator deployment when certificate secrets change, but the deployment may not exist yet.

The policy should gracefully handle cases where the MinIO operator deployment doesn't exist yet, either by adding existence checks before attempting mutations.

Assignee Loading
Time tracking Loading