Skip to content

Commit 753df2c

Browse files
committed
chore: migrating addon-operator from olm to pko
Signed-off-by: Ankit152 <[email protected]>
1 parent 035c14e commit 753df2c

25 files changed

Lines changed: 1757 additions & 0 deletions
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
apiVersion: tekton.dev/v1
2+
kind: PipelineRun
3+
metadata:
4+
annotations:
5+
build.appstudio.openshift.io/repo: https://github.com/openshift/addon-operator?rev={{revision}}
6+
build.appstudio.redhat.com/commit_sha: '{{revision}}'
7+
build.appstudio.redhat.com/target_branch: '{{target_branch}}'
8+
pipelinesascode.tekton.dev/cancel-in-progress: 'true'
9+
pipelinesascode.tekton.dev/max-keep-runs: '3'
10+
pipelinesascode.tekton.dev/on-cel-expression: event == "pull_request" && target_branch
11+
== "main"
12+
labels:
13+
appstudio.openshift.io/application: addon-operator
14+
appstudio.openshift.io/component: addon-operator-pko
15+
pipelines.appstudio.openshift.io/type: build
16+
name: addon-operator-pko-on-pull-request
17+
namespace: addon-operator-tenant
18+
spec:
19+
params:
20+
- name: git-url
21+
value: '{{source_url}}'
22+
- name: revision
23+
value: '{{revision}}'
24+
- name: output-image
25+
value: quay.io/redhat-user-workloads/addon-operator-tenant/openshift/addon-operator-pko:on-pr-{{revision}}
26+
- name: dockerfile
27+
value: build/Dockerfile.pko
28+
- name: path-context
29+
value: deploy_pko
30+
- name: skip-preflight-cert-check
31+
value: true
32+
- name: image-expires-after
33+
value: 3d
34+
taskRunTemplate:
35+
serviceAccountName: build-pipeline-addon-operator-pko
36+
workspaces:
37+
- name: git-auth
38+
secret:
39+
secretName: '{{ git_auth_secret }}'
40+
pipelineRef:
41+
resolver: git
42+
params:
43+
- name: url
44+
value: https://github.com/openshift/boilerplate
45+
- name: revision
46+
value: master
47+
- name: pathInRepo
48+
value: pipelines/docker-build-oci-ta/pipeline.yaml
49+
status: {}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
apiVersion: tekton.dev/v1
2+
kind: PipelineRun
3+
metadata:
4+
annotations:
5+
build.appstudio.openshift.io/repo: https://github.com/openshift/addon-operator?rev={{revision}}
6+
build.appstudio.redhat.com/commit_sha: '{{revision}}'
7+
build.appstudio.redhat.com/target_branch: '{{target_branch}}'
8+
pipelinesascode.tekton.dev/cancel-in-progress: 'false'
9+
pipelinesascode.tekton.dev/max-keep-runs: '3'
10+
pipelinesascode.tekton.dev/on-cel-expression: event == "push" && target_branch
11+
== "main"
12+
labels:
13+
appstudio.openshift.io/application: addon-operator
14+
appstudio.openshift.io/component: addon-operator-pko
15+
pipelines.appstudio.openshift.io/type: build
16+
name: addon-operator-pko-on-push
17+
namespace: addon-operator-tenant
18+
spec:
19+
params:
20+
- name: git-url
21+
value: '{{source_url}}'
22+
- name: revision
23+
value: '{{revision}}'
24+
- name: output-image
25+
value: quay.io/redhat-user-workloads/addon-operator-tenant/openshift/addon-operator-pko:{{revision}}
26+
- name: dockerfile
27+
value: build/Dockerfile.pko
28+
- name: path-context
29+
value: deploy_pko
30+
- name: skip-preflight-cert-check
31+
value: true
32+
taskRunTemplate:
33+
serviceAccountName: build-pipeline-addon-operator-pko
34+
workspaces:
35+
- name: git-auth
36+
secret:
37+
secretName: '{{ git_auth_secret }}'
38+
pipelineRef:
39+
resolver: git
40+
params:
41+
- name: url
42+
value: https://github.com/openshift/boilerplate
43+
- name: revision
44+
value: master
45+
- name: pathInRepo
46+
value: pipelines/docker-build-oci-ta/pipeline.yaml
47+
status: {}

build/Dockerfile.pko

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM scratch
2+
3+
LABEL com.redhat.component="openshift-addon-operator" \
4+
io.k8s.description="addon-operator Operator for OpenShift Dedicated" \
5+
description="addon-operator Operator for OpenShift Dedicated" \
6+
distribution-scope="public" \
7+
name="openshift/addon-operator" \
8+
url="https://github.com/openshift/addon-operator" \
9+
vendor="Red Hat, Inc." \
10+
release="v0.0.0" \
11+
version="v0.0.0"
12+
13+
COPY * /package/

deploy_pko/Cleanup-OLM-Job.yaml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: addon-operator-prom-token-role
5+
annotations:
6+
package-operator.run/phase: rbac
7+
package-operator.run/collision-protection: IfNoController
8+
rules:
9+
- nonResourceURLs:
10+
- /metrics
11+
verbs:
12+
- get
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: addon-operator
5+
annotations:
6+
package-operator.run/phase: rbac
7+
package-operator.run/collision-protection: IfNoController
8+
rules:
9+
- apiGroups:
10+
- addons.managed.openshift.io
11+
resources:
12+
- addons
13+
- addons/status
14+
- addons/finalizers
15+
- addonoperators
16+
- addonoperators/status
17+
- addonoperators/finalizers
18+
- addoninstances
19+
- addoninstances/status
20+
- addoninstances/finalizers
21+
verbs:
22+
- get
23+
- list
24+
- watch
25+
- update
26+
- patch
27+
- apiGroups:
28+
- addons.managed.openshift.io
29+
resources:
30+
- addonoperators
31+
- addonoperators/status
32+
- addonoperators/finalizers
33+
- addoninstances
34+
- addoninstances/status
35+
- addoninstances/finalizers
36+
verbs:
37+
- create
38+
- apiGroups:
39+
- ''
40+
resources:
41+
- namespaces
42+
- secrets
43+
- pods
44+
verbs:
45+
- create
46+
- get
47+
- list
48+
- watch
49+
- update
50+
- patch
51+
- delete
52+
- apiGroups:
53+
- ''
54+
resources:
55+
- configmaps
56+
verbs:
57+
- get
58+
- create
59+
- update
60+
- apiGroups:
61+
- operators.coreos.com
62+
resources:
63+
- operatorgroups
64+
- catalogsources
65+
- subscriptions
66+
- installplans
67+
verbs:
68+
- create
69+
- delete
70+
- update
71+
- watch
72+
- get
73+
- list
74+
- patch
75+
- apiGroups:
76+
- operators.coreos.com
77+
resources:
78+
- clusterserviceversions
79+
- operators
80+
verbs:
81+
- watch
82+
- get
83+
- list
84+
- apiGroups:
85+
- config.openshift.io
86+
resources:
87+
- clusterversions
88+
verbs:
89+
- watch
90+
- get
91+
- list
92+
- apiGroups:
93+
- monitoring.coreos.com
94+
resources:
95+
- servicemonitors
96+
verbs:
97+
- create
98+
- delete
99+
- update
100+
- watch
101+
- get
102+
- list
103+
- patch
104+
- apiGroups:
105+
- networking.k8s.io
106+
resources:
107+
- networkpolicies
108+
verbs:
109+
- create
110+
- delete
111+
- update
112+
- watch
113+
- get
114+
- list
115+
- patch
116+
- apiGroups:
117+
- monitoring.rhobs
118+
resources:
119+
- monitoringstacks
120+
verbs:
121+
- create
122+
- delete
123+
- update
124+
- watch
125+
- get
126+
- list
127+
- patch
128+
- apiGroups:
129+
- package-operator.run
130+
resources:
131+
- clusterobjecttemplates
132+
verbs:
133+
- create
134+
- delete
135+
- update
136+
- watch
137+
- get
138+
- list
139+
- patch
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRoleBinding
3+
metadata:
4+
name: addon-operator-prom-token-role-binding
5+
annotations:
6+
package-operator.run/phase: rbac
7+
package-operator.run/collision-protection: IfNoController
8+
subjects:
9+
- kind: ServiceAccount
10+
name: addon-operator-prom-token
11+
namespace: openshift-addon-operator
12+
roleRef:
13+
kind: ClusterRole
14+
name: addon-operator-prom-token-role
15+
apiGroup: rbac.authorization.k8s.io
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRoleBinding
3+
metadata:
4+
name: addon-operator
5+
annotations:
6+
package-operator.run/phase: rbac
7+
package-operator.run/collision-protection: IfNoController
8+
roleRef:
9+
apiGroup: rbac.authorization.k8s.io
10+
kind: ClusterRole
11+
name: addon-operator
12+
subjects:
13+
- kind: ServiceAccount
14+
name: addon-operator
15+
namespace: openshift-addon-operator

0 commit comments

Comments
 (0)