Skip to content

Commit 4c74dd3

Browse files
committed
introduce operator update functionality
1 parent bd62cce commit 4c74dd3

8 files changed

Lines changed: 354 additions & 3 deletions

File tree

defaults/operators.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,62 +2,73 @@
22
operators:
33

44
- name: quay-operator
5+
version: 3.15.2
56
defaultChannel: stable-3.15
67
channels:
78
- name: stable-3.15
89
namespace: quay-enterprise
910
source: cs-redhat-operator-index-v4-20
1011

1112
- name: multicluster-engine
13+
version: 2.10.1
1214
defaultChannel: stable-2.10
1315
channels:
1416
- name: stable-2.10
1517
namespace: multicluster-engine
1618
source: cs-redhat-operator-index-v4-20
1719

1820
- name: advanced-cluster-management
21+
version: 2.15.1
1922
defaultChannel: release-2.15
2023
channels:
2124
- name: release-2.15
2225
namespace: open-cluster-management
2326
source: cs-redhat-operator-index-v4-20
2427

2528
- name: cincinnati-operator
29+
version: 5.0.3
2630
defaultChannel: v1
2731
channels:
2832
- name: v1
2933
namespace: openshift-update-service
3034
source: cs-redhat-operator-index-v4-20
35+
csvName: update-service-operator
3136

3237
- name: openshift-gitops-operator
38+
version: 1.19.1
3339
defaultChannel: gitops-1.19
3440
channels:
3541
- name: gitops-1.19
3642
namespace: openshift-operators
3743
source: cs-redhat-operator-index-v4-20
3844

3945
- name: openshift-pipelines-operator-rh
46+
version: 1.20.2
4047
defaultChannel: pipelines-1.20
4148
channels:
4249
- name: pipelines-1.20
4350
namespace: openshift-operators
4451
source: cs-redhat-operator-index-v4-20
4552

4653
- name: netobserv-operator
54+
version: 1.10.1
4755
defaultChannel: stable
4856
channels:
4957
- name: stable
5058
namespace: openshift-operators
5159
source: cs-redhat-operator-index-v4-20
60+
csvName: network-observability-operator
5261

5362
- name: cluster-logging
63+
version: 6.4.1
5464
defaultChannel: stable-6.4
5565
channels:
5666
- name: stable-6.4
5767
namespace: openshift-logging
5868
source: cs-redhat-operator-index-v4-20
5969

6070
- name: loki-operator
71+
version: 6.4.1
6172
defaultChannel: stable-6.4
6273
channels:
6374
- name: stable-6.4
@@ -66,43 +77,52 @@ operators:
6677
disableTargetNamespace: true
6778

6879
- name: redhat-oadp-operator
80+
version: 1.5.3
6981
defaultChannel: stable
7082
channels:
7183
- name: stable
7284
namespace: openshift-oadp
7385
source: cs-redhat-operator-index-v4-20
86+
csvName: oadp-operator
7487

7588
- name: openshift-cert-manager-operator
89+
version: 1.18.1
7690
defaultChannel: stable-v1
7791
channels:
7892
- name: stable-v1
7993
- name: stable-v1.18
8094
namespace: cert-manager-operator
8195
source: cs-redhat-operator-index-v4-20
96+
csvName: cert-manager-operator
8297

8398
- name: cluster-observability-operator
99+
version: 1.3.1
84100
defaultChannel: stable
85101
channels:
86102
- name: stable
87103
namespace: openshift-operators
88104
source: cs-redhat-operator-index-v4-20
89105

90106
- name: openshift-external-secrets-operator
107+
version: 1.0.0
91108
defaultChannel: stable-v1.0
92109
channels:
93110
- name: stable-v1.0
94111
namespace: external-secrets-operator
95112
source: cs-redhat-operator-index-v4-20
96113
disableTargetNamespace: true
114+
csvName: external-secrets-operator
97115

98116
- name: compliance-operator
117+
version: 1.8.2
99118
defaultChannel: stable
100119
channels:
101120
- name: stable
102121
namespace: openshift-compliance
103122
source: cs-redhat-operator-index-v4-20
104123

105124
- name: metallb-operator
125+
version: 4.20.0-202601271911
106126
defaultChannel: stable
107127
channels:
108128
- name: stable
@@ -112,9 +132,11 @@ operators:
112132

113133
# AAP is a dependency for osac-operator
114134
- name: ansible-automation-platform-operator
135+
version: 2.5.0-0.1768928092
115136
defaultChannel: stable-2.5-cluster-scoped
116137
channels:
117138
- name: stable-2.5-cluster-scoped
118139
namespace: ansible-aap
119140
source: cs-redhat-operator-index-v4-20
120141
disableTargetNamespace: true
142+
csvName: aap-operator

defaults/storage_operators.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ storage_operators: # Install operator depending blockStorageBackend variable
88
source: cs-redhat-operator-index-v4-20
99
lvms:
1010
name: lvms-operator
11+
version: 4.20.0
1112
defaultChannel: stable-4.20
1213
channels:
1314
- name: stable-4.20
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
---
2+
- name: Get OpenShift CLI image from OpenShift release
3+
ansible.builtin.command: >
4+
{{ rootDir }}/bin/oc adm release info --registry-config={{ rootDir }}/config/pull-secret.json --image-for cli
5+
quay.io/openshift-release-dev/ocp-release:{{ mgmt_openshift_version }}-x86_64
6+
register: r_oc_cli_image
7+
changed_when: false
8+
9+
- name: Set image facts
10+
ansible.builtin.set_fact:
11+
oc_cli_image: "{{ r_oc_cli_image.stdout }}"
12+
13+
- name: Create Operator Update ServiceAccount
14+
kubernetes.core.k8s:
15+
state: present
16+
definition:
17+
apiVersion: v1
18+
kind: ServiceAccount
19+
metadata:
20+
name: operator-update
21+
namespace: openshift-pipelines
22+
23+
- name: Create Operator Update ClusterRole
24+
kubernetes.core.k8s:
25+
state: present
26+
definition:
27+
apiVersion: rbac.authorization.k8s.io/v1
28+
kind: ClusterRole
29+
metadata:
30+
name: operator-update
31+
rules:
32+
- apiGroups: ["operators.coreos.com"]
33+
resources: ["clusterserviceversions", "installplans"]
34+
verbs: ["get", "list", "patch", "update", "watch"]
35+
36+
- name: Create Operator Update ClusterRoleBinding
37+
kubernetes.core.k8s:
38+
state: present
39+
definition:
40+
apiVersion: rbac.authorization.k8s.io/v1
41+
kind: ClusterRoleBinding
42+
metadata:
43+
name: operator-update
44+
subjects:
45+
- kind: ServiceAccount
46+
name: operator-update
47+
namespace: openshift-pipelines
48+
roleRef:
49+
kind: ClusterRole
50+
name: operator-update
51+
apiGroup: rbac.authorization.k8s.io
52+
53+
- name: Create Operator Update Task
54+
kubernetes.core.k8s:
55+
state: present
56+
definition:
57+
apiVersion: tekton.dev/v1
58+
kind: Task
59+
metadata:
60+
name: operator-update
61+
namespace: openshift-pipelines
62+
spec:
63+
params:
64+
- name: dry-run
65+
description: "If true, only identifies pending updates"
66+
type: string
67+
default: "false"
68+
results:
69+
- name: exit-code
70+
description: "Success of operator version update (exit code)"
71+
- name: status-report
72+
description: "Report of operator version updates"
73+
workspaces:
74+
- name: shared-data
75+
steps:
76+
- name: generate-script
77+
image: "{{ oc_cli_image }}"
78+
workingDir: $(workspaces.shared-data.path)
79+
script: |
80+
#!/bin/bash
81+
82+
cat <<EOF > operator_update.py
83+
{{ lookup('ansible.builtin.file', '../scripts/operator_update.py') }}
84+
EOF
85+
- name: operator-update
86+
image: "{{ oc_cli_image }}"
87+
workingDir: $(workspaces.shared-data.path)
88+
script: |
89+
#!/bin/bash
90+
91+
python ./operator_update.py "{{ [storage_operators[blockStorageBackend]] + operators }}" "$(params.dry-run)" > $(results.status-report.path)
92+
echo -n $? > $(results.exit-code.path)
93+
94+
- name: Create Operator Update Pipeline
95+
kubernetes.core.k8s:
96+
state: present
97+
definition:
98+
apiVersion: tekton.dev/v1
99+
kind: Pipeline
100+
metadata:
101+
name: operator-update
102+
namespace: openshift-pipelines
103+
spec:
104+
params:
105+
- name: dry-run
106+
type: string
107+
description: "If true, only identifies pending updates"
108+
default: "false"
109+
results:
110+
- name: exit-code
111+
description: "Success of operator version update (exit code)"
112+
value: $(tasks.operator-update.results.exit-code)
113+
- name: status-report
114+
description: "Report of operator version updates"
115+
value: $(tasks.operator-update.results.status-report)
116+
workspaces:
117+
- name: shared-data
118+
tasks:
119+
- name: operator-update
120+
workspaces:
121+
- name: shared-data
122+
workspace: shared-data
123+
taskRef:
124+
name: operator-update
125+
params:
126+
- name: dry-run
127+
value: $(params.dry-run)
128+
timeout: "2h"

operators/openshift-pipelines-operator-rh/tasks.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@
1414
until: r_tekton_config_info is success
1515
retries: 120
1616
delay: 30
17+
18+
- name: Create Operator Update Pipeline
19+
ansible.builtin.include_tasks:
20+
file: operator_update_pipeline.yaml

playbooks/tasks/configure_operator.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,21 @@
6767
name: "{{ operator.name }}"
6868
namespace: "{{ operator.namespace }}"
6969
spec:
70-
installPlanApproval: Automatic
70+
installPlanApproval: "{{ 'Automatic' if operator.namespace == 'openshift-operators' else 'Manual' }}"
7171
channel: "{{ operator.defaultChannel }}"
7272
name: "{{ operator.name }}"
7373
source: "{{ operator.source if (disconnected | default(true)) else 'redhat-operators' }}"
7474
sourceNamespace: openshift-marketplace
75+
startingCSV: "{{ operator.csvName | default(operator.name) }}.v{{ operator.version }}"
7576
register: r_sub_exists
7677
retries: 6
7778
delay: 5
7879
until: r_sub_exists is success
7980

8081
- name: "Get Installed CSV ({{ operator.name }})"
81-
when: r_sub_check.resources | length == 0
82+
when:
83+
- r_sub_check.resources | length == 0
84+
- operator.namespace == "openshift-operators"
8285
kubernetes.core.k8s_info:
8386
api_version: operators.coreos.com/v1alpha1
8487
kind: Subscription
@@ -92,7 +95,9 @@
9295
- r_subscription.resources[0].status.currentCSV | length > 0
9396

9497
- name: "Wait until CSV is installed"
95-
when: r_sub_check.resources | length == 0
98+
when:
99+
- r_sub_check.resources | length == 0
100+
- operator.namespace == "openshift-operators"
96101
kubernetes.core.k8s_info:
97102
api_version: operators.coreos.com/v1alpha1
98103
kind: ClusterServiceVersion

playbooks/tasks/configure_operators.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@
1313
loop_control:
1414
loop_var: operator
1515

16+
- name: Pause for 3 minutes for InstallPlans to be created
17+
ansible.builtin.pause:
18+
minutes: 3
19+
20+
- name: "Update operator versions"
21+
ansible.builtin.shell: |
22+
python ../scripts/operator_update.py "{{ [storage_operators[blockStorageBackend]] + operators }}" "False"
23+
24+
- name: Print the output
25+
ansible.builtin.debug:
26+
var: operator_update_result.stdout_lines
27+
1628
- name: Include specific tasks for the operators
1729
ansible.builtin.include_tasks: "../../operators/{{ operator.name }}/tasks.yaml"
1830
loop: "{{ [storage_operators[blockStorageBackend]] + operators }}"

schemas/operators.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ definitions:
1010
name:
1111
type: string
1212
description: Operator package name as it appears in the catalog.
13+
version:
14+
type: string
15+
description: Operator version.
1316
defaultChannel:
1417
type: string
1518
description: Default update channel for the operator.
@@ -31,6 +34,9 @@ definitions:
3134
source:
3235
type: string
3336
description: Catalog source name (from oc-mirror configuration).
37+
csvName:
38+
type: string
39+
description: ClusterServiceVersion name for the operator.
3440
disableTargetNamespace:
3541
type: boolean
3642
description: configure operator to watch a specific namespace or to watch the entire cluster

0 commit comments

Comments
 (0)