-
Notifications
You must be signed in to change notification settings - Fork 276
258 lines (222 loc) · 10.7 KB
/
testing_and_publishing_OLM_bundle.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# action to test our operator lifecycle manager bundle
# See https://github.com/rabbitmq/OLM-Package-Repo for more info.
name: Test & Publish OLM Package
on:
release:
types: [published]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
# registry information where we want to store the operator image and the operator index image
DOCKER_REGISTRY_SERVER: quay.io/rabbitmqoperator
OLM_IMAGE: rabbitmq-for-kubernetes-olm-cluster-operator
OLM_INDEX_IMAGE: rabbitmq-for-kubernetes-olm-cluster-operator-index
jobs:
create-olm-package:
name: Create the OLM Packaging
runs-on: ubuntu-latest
permissions:
contents: 'write'
id-token: 'write'
outputs:
olm_package_version: ${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Checkout OLM-Package-Repo
uses: actions/checkout@v4
with:
repository: rabbitmq/OLM-Package-Repo
path: ./OLM-Package-Repo
- name: Set image tag to tagged release
id: set_bundle_version
run: scripts/print-tag-version.bash >> "$GITHUB_OUTPUT"
shell: bash
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: false
- name: OpenShift Tools Installer
uses: redhat-actions/openshift-tools-installer@v1
with:
# Using GitHub source because the Openshift mirror source binary file does not match the expected name
# pattern. In the mirror, the filename is opm-rhel8, and the Action is expecting the name as opm-${OS}-${ARCH}
source: github
github_pat: ${{ github.token }}
opm: "latest"
- name: carvel-setup-action
uses: carvel-dev/[email protected]
with:
token: ${{ github.token }}
only: ytt, kbld
- name: Podman Login
uses: redhat-actions/podman-login@v1
with:
registry: ${{ env.DOCKER_REGISTRY_SERVER }}
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
# TODO: Set auto-expiry in DEV images: https://idbs-engineering.com/containers/2019/08/27/auto-expiry-quayio-tags.html
- name: Create OLM Package
env:
DOCKER_REGISTRY_SERVER: ${{ env.DOCKER_REGISTRY_SERVER }}
OLM_IMAGE: ${{ env.OLM_IMAGE }}
OLM_INDEX_IMAGE: ${{ env.OLM_INDEX_IMAGE }}
BUNDLE_VERSION: ${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
run: |
make generate-installation-manifest
cp ./config/crd/bases/rabbitmq.com_rabbitmqclusters.yaml ./OLM-Package-Repo/rabbitmq_olm_package_repo/manifests_crds/crds.yaml
cd ./OLM-Package-Repo
poetry run generate_bundle ./../releases/cluster-operator.yml $BUNDLE_VERSION ./
opm alpha bundle build -c stable -d ./$BUNDLE_VERSION/manifests -t $DOCKER_REGISTRY_SERVER/$OLM_IMAGE:$BUNDLE_VERSION -p rabbitmq-cluster-operator --image-builder podman
opm index add -b $DOCKER_REGISTRY_SERVER/$OLM_IMAGE:$BUNDLE_VERSION -t $DOCKER_REGISTRY_SERVER/$OLM_INDEX_IMAGE:$BUNDLE_VERSION -c podman
mkdir upload
mv "$BUNDLE_VERSION" ./upload
cp ./rabbitmq_olm_package_repo/generators/cluster_operator_generators/cluster-service-version-generator-openshift.yml ./rabbitmq_olm_package_repo/generators/cluster_operator_generators/cluster-service-version-generator.yml
poetry run generate_bundle ./rabbitmq_olm_package_repo/manifests_crds/cluster-operator.yaml $BUNDLE_VERSION ./
mv "$BUNDLE_VERSION" ./upload/$BUNDLE_VERSION-openshift
- name: Push OLM Package to Registry
uses: redhat-actions/push-to-registry@v2
with:
registry: ${{ env.DOCKER_REGISTRY_SERVER }}
image: ${{ env.OLM_IMAGE }}
tags: ${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
- name: Push OLM Package to Registry
uses: redhat-actions/push-to-registry@v2
with:
registry: ${{ env.DOCKER_REGISTRY_SERVER }}
image: ${{ env.OLM_INDEX_IMAGE }}
tags: ${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
- name: Upload OLM Package
uses: actions/upload-artifact@v4
with:
name: olm-artifact
path: OLM-Package-Repo/upload/
retention-days: 2
test-olm-package:
name: Tests the OLM packaging
runs-on: ubuntu-latest
needs: create-olm-package
outputs:
# Required to pass on the OLM bundle version to publish job
olm_package_version: ${{ needs.create-olm-package.outputs.olm_package_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout infrastructure repo
uses: actions/checkout@v4
with:
repository: rabbitmq/infrastructure
token: ${{ secrets.GIT_HUB_INFRA_REPO_ACCESS_TOKEN }}
path: ./infrastructure
- name: Checkout OLM-Package-Repo
uses: actions/checkout@v4
with:
repository: rabbitmq/OLM-Package-Repo
path: ./OLM-Package-Repo
- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
- name: Setup Ginkgo CLI
uses: ci-tasks/setup-ginkgo@main
- name: carvel-setup-action
uses: carvel-dev/[email protected]
with:
token: ${{ github.token }}
only: ytt, kbld
- name: Protect access to the cluster with a mutex
uses: ben-z/[email protected]
with:
branch: openshift-lock
- name: Connect to the Openshift cluster and deploy the operators through OLM
id: connect-and-deploy
run: |
mkdir $HOME/.kube
cp ./infrastructure/k8s/okd/admin-kubeconfig.yaml $HOME/.kube/config
export KUBECONFIG=$HOME/.kube/config
export ENVIRONMENT=openshift
kubectl config use-context admin
./OLM-Package-Repo/testfiles/install-rabbitmq-cluster-operator.sh ${{ needs.create-olm-package.outputs.olm_package_version }}
- name: Run Operator System Tests
env:
ENVIRONMENT: "openshift"
K8S_OPERATOR_NAMESPACE: rabbitmq-system-olm
SYSTEM_TEST_NAMESPACE: rabbitmq-system-olm
run: |
kubectl wait -n "$K8S_OPERATOR_NAMESPACE" sub --all --for=jsonpath='{.status.state}'=AtLatestKnown --timeout=2m
make system-tests
- name: Clean up Openshift environment
env:
OLM_INDEX_TAG: ${{ needs.create-olm-package.outputs.olm_package_version }}
if: ${{ !cancelled() && steps.connect-and-deploy.conclusion == 'success' }}
run: |
export KUBECONFIG=./infrastructure/k8s/okd/admin-kubeconfig.yaml
kubectl config use-context admin
./OLM-Package-Repo/testfiles/uninstall-rabbitmq-cluster-operator.sh $OLM_INDEX_TAG
publish-bundle-operatorhub:
name: Create branch for OperatorHub PR
runs-on: ubuntu-latest
needs: test-olm-package
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
steps:
- name: Checkout community-operators fork (OperatorHub)
uses: actions/checkout@v4
with:
repository: rabbitmq/community-operators
token: ${{ secrets.RABBITMQ_CI_TOKEN }}
- name: Download OLM artifact
uses: actions/download-artifact@v4
with:
name: olm-artifact
path: olm-package-ci
- name: Create branch for OperatorHub PR
env:
BUNDLE_VERSION: ${{ needs.test-olm-package.outputs.olm_package_version }}
# RABBITMQ_CI_EMAIL: secret_rabbitmq/kv/Shared-Shared-RabbitMQ%2Frabbitmq-ci/details
# RABBITMQ_CI_TOKEN: secret_rabbitmq/kv/Shared-Shared-RabbitMQ%2Frabbitmq-ci/details
run: |
mkdir -pv operators/rabbitmq-cluster-operator
git config user.name "rabbitmq-ci"
git config user.email ${{ secrets.RABBITMQ_CI_EMAIL }}
git branch rabbitmq-cluster-operator-$BUNDLE_VERSION
git checkout rabbitmq-cluster-operator-$BUNDLE_VERSION
cp -v -fR olm-package-ci/"$BUNDLE_VERSION" ./operators/rabbitmq-cluster-operator/
sed -i -e "s/latest/$BUNDLE_VERSION/g" ./operators/rabbitmq-cluster-operator/$BUNDLE_VERSION/manifests/rabbitmq.clusterserviceversion.yaml
git add operators/rabbitmq-cluster-operator
git commit -s -m "RabbitMQ Operator release $BUNDLE_VERSION"
git push --set-upstream origin "rabbitmq-cluster-operator-$BUNDLE_VERSION"
publish-bundle-redhat-marketplace:
name: Create branch for Openshift marketplace PR
runs-on: ubuntu-latest
needs: test-olm-package
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
steps:
- name: Checkout community-operators-prod fork (Openshift Ecosystem)
uses: actions/checkout@v4
with:
repository: rabbitmq/community-operators-prod
token: ${{ secrets.RABBITMQ_CI_TOKEN }}
- name: Download OLM artifact
uses: actions/download-artifact@v4
with:
name: olm-artifact
path: olm-package-ci
- name: Create branch for Openshift Ecosystem PR
env:
BUNDLE_VERSION: ${{ needs.test-olm-package.outputs.olm_package_version }}
# RABBITMQ_CI_EMAIL: secret_rabbitmq/kv/Shared-Shared-RabbitMQ%2Frabbitmq-ci/details
# RABBITMQ_CI_TOKEN: secret_rabbitmq/kv/Shared-Shared-RabbitMQ%2Frabbitmq-ci/details
run: |
mkdir -pv operators/rabbitmq-cluster-operator
git config user.name "rabbitmq-ci"
git config user.email ${{ secrets.RABBITMQ_CI_EMAIL }}
git branch rabbitmq-cluster-operator-$BUNDLE_VERSION
git checkout rabbitmq-cluster-operator-$BUNDLE_VERSION
cp -v -fR olm-package-ci/"$BUNDLE_VERSION-openshift" ./operators/rabbitmq-cluster-operator/"$BUNDLE_VERSION"
sed -i -e "s/latest/$BUNDLE_VERSION/g" ./operators/rabbitmq-cluster-operator/"$BUNDLE_VERSION"/manifests/rabbitmq.clusterserviceversion.yaml
git add operators/rabbitmq-cluster-operator
git commit -s -m "RabbitMQ Operator release $BUNDLE_VERSION"
git push --set-upstream origin "rabbitmq-cluster-operator-$BUNDLE_VERSION"