|
| 1 | +--- |
| 2 | +# This Job cleans up old OLM resources after migrating to PKO |
| 3 | +# IMPORTANT: Review and customize this template before deploying! |
| 4 | +# |
| 5 | +# Things to customize: |
| 6 | +# 1. Adjust the namespace if needed |
| 7 | +# 2. Modify resource filters (CSV names, labels, etc.) |
| 8 | +# 3. Review RBAC permissions |
| 9 | +# 4. Update the cleanup logic for your specific operator |
| 10 | +# |
| 11 | +apiVersion: v1 |
| 12 | +kind: ServiceAccount |
| 13 | +metadata: |
| 14 | + name: olm-cleanup |
| 15 | + namespace: openshift-addon-operator |
| 16 | + annotations: |
| 17 | + package-operator.run/phase: cleanup-rbac |
| 18 | + package-operator.run/collision-protection: IfNoController |
| 19 | +--- |
| 20 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 21 | +kind: Role |
| 22 | +metadata: |
| 23 | + name: olm-cleanup |
| 24 | + namespace: openshift-addon-operator |
| 25 | + annotations: |
| 26 | + package-operator.run/phase: cleanup-rbac |
| 27 | + package-operator.run/collision-protection: IfNoController |
| 28 | +rules: |
| 29 | + # CUSTOMIZE: Adjust permissions as needed for your cleanup tasks |
| 30 | + - apiGroups: |
| 31 | + - operators.coreos.com |
| 32 | + resources: |
| 33 | + - clusterserviceversions |
| 34 | + - subscriptions |
| 35 | + verbs: |
| 36 | + - list |
| 37 | + - get |
| 38 | + - watch |
| 39 | + - delete |
| 40 | +--- |
| 41 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 42 | +kind: RoleBinding |
| 43 | +metadata: |
| 44 | + name: olm-cleanup |
| 45 | + namespace: openshift-addon-operator |
| 46 | + annotations: |
| 47 | + package-operator.run/phase: cleanup-rbac |
| 48 | + package-operator.run/collision-protection: IfNoController |
| 49 | +roleRef: |
| 50 | + kind: Role |
| 51 | + name: olm-cleanup |
| 52 | + apiGroup: rbac.authorization.k8s.io |
| 53 | +subjects: |
| 54 | + - kind: ServiceAccount |
| 55 | + name: olm-cleanup |
| 56 | + namespace: openshift-addon-operator |
| 57 | +--- |
| 58 | +apiVersion: batch/v1 |
| 59 | +kind: Job |
| 60 | +metadata: |
| 61 | + name: olm-cleanup |
| 62 | + namespace: openshift-addon-operator |
| 63 | + annotations: |
| 64 | + package-operator.run/phase: cleanup-deploy |
| 65 | + package-operator.run/collision-protection: IfNoController |
| 66 | +spec: |
| 67 | + template: |
| 68 | + metadata: |
| 69 | + annotations: |
| 70 | + openshift.io/required-scc: restricted-v2 |
| 71 | + spec: |
| 72 | + serviceAccountName: olm-cleanup |
| 73 | + priorityClassName: openshift-user-critical |
| 74 | + restartPolicy: Never |
| 75 | + containers: |
| 76 | + - name: delete-csv |
| 77 | + image: image-registry.openshift-image-registry.svc:5000/openshift/cli:latest |
| 78 | + imagePullPolicy: Always |
| 79 | + command: |
| 80 | + - sh |
| 81 | + - -c |
| 82 | + - | |
| 83 | + #!/bin/sh |
| 84 | + set -euxo pipefail |
| 85 | + # CUSTOMIZE: Update the label selector for your operator |
| 86 | + # Example pattern: operators.coreos.com/OPERATOR_NAME.NAMESPACE |
| 87 | + oc -n openshift-addon-operator delete csv -l "operators.coreos.com/addon-operator.openshift-addon-operator" || true |
| 88 | + |
| 89 | + # CUSTOMIZE: Add any additional cleanup logic here |
| 90 | + # Examples: |
| 91 | + # - Delete subscriptions |
| 92 | + # - Delete operator groups |
| 93 | + # - Clean up custom resources |
| 94 | + resources: |
| 95 | + requests: |
| 96 | + cpu: 100m |
| 97 | + memory: 100Mi |
0 commit comments