Skip to content

Commit dd7d1ba

Browse files
committed
Adding an operator-upgrade Github workflow.
This test will ensure the bundle built in the PR can be used to upgrade from the last bundle available of KMM. Signed-off-by: Yoni Bettan <[email protected]>
1 parent 5fc673e commit dd7d1ba

File tree

3 files changed

+119
-0
lines changed

3 files changed

+119
-0
lines changed

Diff for: .github/workflows/e2e.yaml

+67
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,70 @@ jobs:
183183
if: ${{ always() }}
184184
with:
185185
output-file: ${{ matrix.name }}-support-bundle.tar.gz
186+
187+
188+
operator-upgrade:
189+
190+
runs-on: ubuntu-20.04
191+
name: operator-upgrade
192+
needs: [build-operator-image, build-signing-image, build-worker-image]
193+
194+
services:
195+
registry:
196+
image: registry:2
197+
ports: ['5000:5000/tcp']
198+
199+
steps:
200+
201+
- name: Checkout
202+
uses: actions/checkout@v4
203+
204+
- name: Create the minikube cluster
205+
uses: ./.github/actions/create-minikube-cluster
206+
with:
207+
start-args: --insecure-registry=host.minikube.internal:5000
208+
209+
- name: Download container images
210+
uses: actions/download-artifact@v4
211+
with:
212+
path: artifacts
213+
214+
- name: Copy kmm, signing and worker images to the registry
215+
run: |
216+
# KMM is pulled by operator-sdk in the cluster and not by minikube
217+
docker load -i artifacts/ci-image-kmm/kmm_local.tar
218+
docker load -i artifacts/ci-image-signer/kmm-signimage_local.tar
219+
docker load -i artifacts/ci-image-worker/kmm-worker_local.tar
220+
221+
docker tag kmm:local localhost:5000/kmm/kmm:local
222+
docker tag kmm-signimage:local localhost:5000/kmm/signimage:local
223+
docker tag kmm-worker:local localhost:5000/kmm/worker:local
224+
225+
docker push localhost:5000/kmm/kmm:local
226+
docker push localhost:5000/kmm/signimage:local
227+
docker push localhost:5000/kmm/worker:local
228+
229+
- name: Set some Ubuntu environment variables
230+
run: |
231+
grep 'ID=' /etc/os-release >> "$GITHUB_ENV"
232+
grep 'VERSION_ID=' /etc/os-release >> "$GITHUB_ENV"
233+
234+
- name: Cache binaries needed by Makefile
235+
id: cache-bin
236+
uses: actions/cache@v3
237+
with:
238+
path: ./bin
239+
key: ${{ runner.os }}-${{ env.ID }}-${{ env.VERSION_ID }}-bin-${{ env.GO_VERSION }}-${{ hashFiles('Makefile') }}
240+
241+
- uses: actions/setup-go@v5
242+
with:
243+
go-version: ${{ env.GO_VERSION }}
244+
if: steps.cache-bin.outputs.cache-hit != 'true'
245+
246+
- name: Run test
247+
run: ./ci/prow/operator-upgrade
248+
249+
- name: Collect troubleshooting data
250+
uses: ./.github/actions/collect-troubleshooting
251+
if: ${{ always() }}
252+
with:

Diff for: ci/prow/operator-upgrade

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
3+
set -euxo pipefail
4+
5+
# operator-sdk run bundle<-upgrade> doesn't support local images and the image
6+
# has to be pushed to a remote registry.
7+
# When the command is run, operator-sdk checks the image twice. At first, it
8+
# validates that the image exists and then it creates a pod in the cluster
9+
# deploying the image, therefore, the image has to be accessed from both, the
10+
# running host and the minikube cluster.
11+
sudo echo "127.0.0.1 host.minikube.internal" | sudo tee -a /etc/hosts
12+
13+
# Build the bundle from the 'main' branch
14+
git fetch origin
15+
git checkout -b main origin/main
16+
make bundle bundle-build bundle-push \
17+
VERSION="1.0.0" \
18+
BUNDLE_IMG=localhost:5000/kmm/kmm-bundle:current
19+
# go back to the last branch
20+
git checkout -
21+
22+
# Install OLM
23+
make operator-sdk
24+
./bin/operator-sdk olm install
25+
26+
# Deploy the current bundle
27+
./bin/operator-sdk run bundle host.minikube.internal:5000/kmm/kmm-bundle:current \
28+
--namespace operators \
29+
--use-http \
30+
--timeout 5m0s
31+
32+
# Build the new bundle
33+
make bundle bundle-build bundle-push \
34+
VERSION="2.0.0" \
35+
IMG=host.minikube.internal:5000/kmm/kmm:local \
36+
SIGNER_IMG=host.minikube.internal:5000/kmm/signimage:local \
37+
WORKER_IMG=host.minikube.internal:5000/kmm/worker:local \
38+
BUNDLE_IMG=localhost:5000/kmm/kmm-bundle:local
39+
40+
# Upgrade to the new bundle
41+
./bin/operator-sdk run bundle-upgrade host.minikube.internal:5000/kmm/kmm-bundle:local \
42+
--namespace operators \
43+
--use-http \
44+
--timeout 5m0s
45+

Diff for: support/kmm.spec.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,21 @@ spec:
66
collectors:
77
- clusterInfo: {}
88
- clusterResources:
9+
#FIXME: remove to collect resources from all namespaces?
910
namespaces:
1011
- default
1112
- cert-manager
1213
- kmm-operator-system
14+
- olm
15+
- operators
1316
- logs:
1417
namespace: kmm-operator-system
1518
selector:
1619
- app.kubernetes.io/part-of=kmm
20+
- logs:
21+
namespace: olm
22+
- logs:
23+
namespace: operators
1724
hostCollectors:
1825
- cpu: {}
1926
- hostOS: {}

0 commit comments

Comments
 (0)