UNCLASSIFIED - NO CUI

Updated RBAC Defaults for Cleanup Controller

General MR

Summary

  • Updated CleanupController RBAC to allow it permissions to delete policy exceptions using the cleanup.kyverno.io/ttl label

This is in support of adding policy exceptions into bb-common

Relevant logs/screenshots

Used the following as a test policy exception to validate:

apiVersion: policies.kyverno.io/v1
kind: PolicyException
metadata:
  name: test-policyexception
  namespace: kyverno
  labels:
    cleanup.kyverno.io/ttl: 2m
spec:
  policyRefs:
    - name: require-prod-label
      kind: ValidatingPolicy
  matchConditions:
    - name: skip-by-name
      expression: "object.metadata.name == 'skipped-deployment'"

Before Update:

kubectl get policyexceptions.policies.kyverno.io test-policyexception -n kyverno

NAME                   AGE
test-policyexception   9m4s

kubectl get policyexceptions.policies.kyverno.io test-policyexception -n kyverno -o yaml

apiVersion: policies.kyverno.io/v1
kind: PolicyException
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"policies.kyverno.io/v1","kind":"PolicyException","metadata":{"annotations":{},"labels":{"cleanup.kyverno.io/ttl":"2m"},"name":"test-policyexception","namespace":"kyverno"},"spec":{"matchConditions":[{"expression":"object.metadata.name == 'skipped-deployment'","name":"skip-by-name"}],"policyRefs":[{"kind":"ValidatingPolicy","name":"require-prod-label"}]}}
  creationTimestamp: "2026-11-20T18:40:45Z"
  generation: 1
  labels:
    cleanup.kyverno.io/ttl: 2m <==== Kyverno TTL Label
  name: test-policyexception
  namespace: kyverno
  resourceVersion: "35950"
  uid: beef778d-0aa8-4a10-885e-0fe2ffd54e4b
spec:
  matchConditions:
  - expression: object.metadata.name == 'skipped-deployment'
    name: skip-by-name
  policyRefs:
  - kind: ValidatingPolicy
    name: require-prod-label
  reportResult: skip

After Update:

Verified after upgrade the test policy exception was no longer present within the cluster.

kubectl get policyexceptions.policies.kyverno.io test-policyexception -n kyverno

Error from server (NotFound): policyexceptions.policies.kyverno.io "test-policyexception" not found

Linked Issue

issue

Upgrade Notices

N/A

Closes #218 (closed)

Edited by Jimmy Bourque

Merge request reports

Loading
Loading