From 8cddcd1ce2671335cbc3c2c30369d35b5ad7a1fa Mon Sep 17 00:00:00 2001 From: Michael Burman Date: Wed, 3 Sep 2025 19:08:34 +0300 Subject: [PATCH 1/7] Generated OLM tests for Github actions to allow verifying if we can actually deploy with OLM.. --- .github/workflows/olm-e2e.yml | 241 ++++++++++++++++++ Makefile | 4 +- .../components/reaper/add-reaper-image.yaml | 0 config/components/reaper/kustomization.yaml | 0 config/scorecard/patches/basic.config.yaml | 2 +- config/scorecard/patches/olm.config.yaml | 10 +- 6 files changed, 249 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/olm-e2e.yml create mode 100644 config/components/reaper/add-reaper-image.yaml create mode 100644 config/components/reaper/kustomization.yaml diff --git a/.github/workflows/olm-e2e.yml b/.github/workflows/olm-e2e.yml new file mode 100644 index 000000000..894005252 --- /dev/null +++ b/.github/workflows/olm-e2e.yml @@ -0,0 +1,241 @@ +name: OLM E2E + +on: + pull_request: + workflow_dispatch: + +jobs: + olm-e2e: + name: OLM bundle, catalog, deploy, scorecard + runs-on: ubuntu-latest + env: + REGISTRY_HOST: localhost:5001 + NAMESPACE: cass-operator + CHANNELS: dev + DEFAULT_CHANNEL: dev + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + cache: false + + - name: Install yq + run: | + sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_amd64 + sudo chmod +x /usr/local/bin/yq + + - name: Set version vars + id: vars + run: | + echo "version=$(make version)" >> $GITHUB_OUTPUT + echo "sha_short=$(git rev-parse --short=8 ${{ github.sha }})" >> $GITHUB_OUTPUT + echo "bundle_img=${{ env.REGISTRY_HOST }}/k8ssandra/cass-operator-bundle:v$(make version)" >> $GITHUB_OUTPUT + echo "catalog_img=${{ env.REGISTRY_HOST }}/k8ssandra/cass-operator-catalog:v$(make version)" >> $GITHUB_OUTPUT + echo "manager_img=${{ env.REGISTRY_HOST }}/k8ssandra/cass-operator:v$(make version)" >> $GITHUB_OUTPUT + echo "logger_img=${{ env.REGISTRY_HOST }}/k8ssandra/system-logger:v$(make version)" >> $GITHUB_OUTPUT + + - name: Start local registry + run: | + docker rm -f kind-registry || true + docker run -d --restart=always -p 127.0.0.1:5001:5000 --name kind-registry registry:2 + + - name: Create kind cluster with local registry config + uses: helm/kind-action@v1 + with: + cluster_name: kind + wait: true + config: | + kind: Cluster + apiVersion: kind.x-k8s.io/v1alpha4 + containerdConfigPatches: + - |- + [plugins."io.containerd.grpc.v1.cri".registry.mirrors] + [plugins."io.containerd.grpc.v1.cri".registry.mirrors."${{ env.REGISTRY_HOST }}"] + endpoint = ["http://kind-registry:5000"] + + - name: Connect registry to kind network + run: | + docker network connect kind kind-registry || true + + - name: Install tools (operator-sdk, kustomize, opm) + run: | + # Force local install of kustomize even in GHA + GITHUB_ACTIONS= make kustomize + make operator-sdk opm + + - name: Build and push operator images to local registry + run: | + export VERSION=${{ steps.vars.outputs.version }} + export IMG=${{ steps.vars.outputs.manager_img }} + export LOG_IMG=${{ steps.vars.outputs.logger_img }} + make docker-build docker-logger-build + docker push $IMG + docker push $LOG_IMG + + - name: Generate OLM bundle + run: | + export VERSION=${{ steps.vars.outputs.version }} + export IMG=${{ steps.vars.outputs.manager_img }} + export CHANNELS=${{ env.CHANNELS }} + export DEFAULT_CHANNEL=${{ env.DEFAULT_CHANNEL }} + export REGISTRY=${{ env.REGISTRY_HOST }} + make bundle + bin/operator-sdk bundle validate ./bundle --select-optional suite=operatorframework + + - name: Build and push bundle image to local registry + run: | + export VERSION=${{ steps.vars.outputs.version }} + export BUNDLE_IMG=${{ steps.vars.outputs.bundle_img }} + make bundle-build + docker push $BUNDLE_IMG + + - name: Build and push catalog (index) image to local registry + run: | + export VERSION=${{ steps.vars.outputs.version }} + export BUNDLE_IMGS=${{ steps.vars.outputs.bundle_img }} + export CATALOG_IMG=${{ steps.vars.outputs.catalog_img }} + make catalog-build + docker push $CATALOG_IMG + + - name: Install OLM + run: | + bin/operator-sdk olm install --timeout 5m + kubectl get pods -n olm + + - name: Run OLM deployment from bundle image + run: | + kubectl create ns ${{ env.NAMESPACE }} || true + bin/operator-sdk run bundle ${{ steps.vars.outputs.bundle_img }} --namespace ${{ env.NAMESPACE }} --timeout 10m + # Wait for CSV to succeed + kubectl -n ${{ env.NAMESPACE }} wait --for=jsonpath='{.status.phase}'=Succeeded csv --all --timeout=300s + kubectl -n ${{ env.NAMESPACE }} get csv + kubectl -n ${{ env.NAMESPACE }} get deploy,po + + - name: Run scorecard (olm suite) + run: | + bin/operator-sdk scorecard ./bundle --selector=suite=olm --verbose + + - name: Red Hat static checks (bundle) + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install operator static tests + run: | + python -m pip install --upgrade pip + python -m pip install git+https://github.com/redhat-openshift-ecosystem/operator-pipelines.git + + - name: Prepare bundle for static checks + id: prep_static + run: | + OP_NAME=$(yq -r '."operators.operatorframework.io.bundle.package.v1"' bundle/metadata/annotations.yaml) + CSV_VERSION=$(yq -r '.spec.version' bundle/manifests/*.clusterserviceversion.yaml) + echo "op_name=${OP_NAME}" >> $GITHUB_OUTPUT + echo "csv_version=${CSV_VERSION}" >> $GITHUB_OUTPUT + mkdir -p /tmp/community-operators-prod/operators/${OP_NAME}/${CSV_VERSION} + cp -r bundle/manifests /tmp/community-operators-prod/operators/${OP_NAME}/${CSV_VERSION}/ + cp -r bundle/metadata /tmp/community-operators-prod/operators/${OP_NAME}/${CSV_VERSION}/ + echo "Prepared repo structure at /tmp/community-operators-prod" + + - name: Run static checks + run: | + static-tests \ + --repo-path /tmp/community-operators-prod \ + --suites operatorcert.static_tests.community \ + --output-file /tmp/operator-static.json \ + --verbose \ + ${{ steps.prep_static.outputs.op_name }} ${{ steps.prep_static.outputs.csv_version }} + echo "Static checks output:" + cat /tmp/operator-static.json || true + + - name: Cleanup bundle install (pre-catalog) + if: always() + run: | + set +e + # Remove the operator deployed via run bundle + bin/operator-sdk cleanup cass-operator --namespace ${{ env.NAMESPACE }} || true + # Ensure namespace is clean for catalog stage + kubectl delete csv --all -n ${{ env.NAMESPACE }} || true + kubectl delete deploy --all -n ${{ env.NAMESPACE }} || true + kubectl delete po --all -n ${{ env.NAMESPACE }} || true + + - name: Create CatalogSource for local catalog + run: | + cat < Date: Thu, 4 Sep 2025 14:38:21 +0300 Subject: [PATCH 2/7] Some removals --- .github/workflows/olm-e2e.yml | 66 +++++++++-------------------------- 1 file changed, 17 insertions(+), 49 deletions(-) diff --git a/.github/workflows/olm-e2e.yml b/.github/workflows/olm-e2e.yml index 894005252..b78b05129 100644 --- a/.github/workflows/olm-e2e.yml +++ b/.github/workflows/olm-e2e.yml @@ -9,14 +9,19 @@ jobs: name: OLM bundle, catalog, deploy, scorecard runs-on: ubuntu-latest env: - REGISTRY_HOST: localhost:5001 + REGISTRY: localhost:5001 NAMESPACE: cass-operator CHANNELS: dev DEFAULT_CHANNEL: dev steps: + - name: Free diskspace by removing unused packages + shell: bash + run: | + sudo rm -rf /usr/local/lib/android + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc - name: Checkout uses: actions/checkout@v4 - - name: Set up Go uses: actions/setup-go@v5 with: @@ -31,73 +36,36 @@ jobs: - name: Set version vars id: vars run: | - echo "version=$(make version)" >> $GITHUB_OUTPUT - echo "sha_short=$(git rev-parse --short=8 ${{ github.sha }})" >> $GITHUB_OUTPUT - echo "bundle_img=${{ env.REGISTRY_HOST }}/k8ssandra/cass-operator-bundle:v$(make version)" >> $GITHUB_OUTPUT - echo "catalog_img=${{ env.REGISTRY_HOST }}/k8ssandra/cass-operator-catalog:v$(make version)" >> $GITHUB_OUTPUT - echo "manager_img=${{ env.REGISTRY_HOST }}/k8ssandra/cass-operator:v$(make version)" >> $GITHUB_OUTPUT - echo "logger_img=${{ env.REGISTRY_HOST }}/k8ssandra/system-logger:v$(make version)" >> $GITHUB_OUTPUT - - - name: Start local registry + echo "bundle_img=${{ env.REGISTRY }}/k8ssandra/cass-operator-bundle:v$(make version)" >> $GITHUB_OUTPUT + # The runners already have the latest versions of tools, no need to reinstall them + - name: Link tools + shell: bash run: | - docker rm -f kind-registry || true - docker run -d --restart=always -p 127.0.0.1:5001:5000 --name kind-registry registry:2 - - - name: Create kind cluster with local registry config - uses: helm/kind-action@v1 - with: - cluster_name: kind - wait: true - config: | - kind: Cluster - apiVersion: kind.x-k8s.io/v1alpha4 - containerdConfigPatches: - - |- - [plugins."io.containerd.grpc.v1.cri".registry.mirrors] - [plugins."io.containerd.grpc.v1.cri".registry.mirrors."${{ env.REGISTRY_HOST }}"] - endpoint = ["http://kind-registry:5000"] - - - name: Connect registry to kind network - run: | - docker network connect kind kind-registry || true - - - name: Install tools (operator-sdk, kustomize, opm) + mkdir bin + ln -s /usr/local/bin/kustomize bin/kustomize + - name: Create kind cluster + shell: bash run: | - # Force local install of kustomize even in GHA - GITHUB_ACTIONS= make kustomize - make operator-sdk opm - + hack/cluster.sh - name: Build and push operator images to local registry run: | - export VERSION=${{ steps.vars.outputs.version }} - export IMG=${{ steps.vars.outputs.manager_img }} - export LOG_IMG=${{ steps.vars.outputs.logger_img }} make docker-build docker-logger-build docker push $IMG docker push $LOG_IMG - name: Generate OLM bundle run: | - export VERSION=${{ steps.vars.outputs.version }} - export IMG=${{ steps.vars.outputs.manager_img }} - export CHANNELS=${{ env.CHANNELS }} - export DEFAULT_CHANNEL=${{ env.DEFAULT_CHANNEL }} - export REGISTRY=${{ env.REGISTRY_HOST }} make bundle bin/operator-sdk bundle validate ./bundle --select-optional suite=operatorframework - name: Build and push bundle image to local registry run: | - export VERSION=${{ steps.vars.outputs.version }} - export BUNDLE_IMG=${{ steps.vars.outputs.bundle_img }} + BUNDLE_IMG=${{ steps.vars.outputs.bundle_img }} make bundle-build docker push $BUNDLE_IMG - name: Build and push catalog (index) image to local registry run: | - export VERSION=${{ steps.vars.outputs.version }} - export BUNDLE_IMGS=${{ steps.vars.outputs.bundle_img }} - export CATALOG_IMG=${{ steps.vars.outputs.catalog_img }} make catalog-build docker push $CATALOG_IMG From f387e2ba547a425b249e6b79d8ec074da9f0d700 Mon Sep 17 00:00:00 2001 From: Michael Burman Date: Thu, 4 Sep 2025 15:02:34 +0300 Subject: [PATCH 3/7] Registry is not passed correctly --- .github/workflows/olm-e2e.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/olm-e2e.yml b/.github/workflows/olm-e2e.yml index b78b05129..09ec657b7 100644 --- a/.github/workflows/olm-e2e.yml +++ b/.github/workflows/olm-e2e.yml @@ -49,24 +49,24 @@ jobs: hack/cluster.sh - name: Build and push operator images to local registry run: | - make docker-build docker-logger-build + make REGISTRY=${{ env.REGISTRY }} docker-build docker-logger-build docker push $IMG docker push $LOG_IMG - name: Generate OLM bundle run: | - make bundle + make REGISTRY=${{ env.REGISTRY }} bundle bin/operator-sdk bundle validate ./bundle --select-optional suite=operatorframework - name: Build and push bundle image to local registry run: | BUNDLE_IMG=${{ steps.vars.outputs.bundle_img }} - make bundle-build + make REGISTRY=${{ env.REGISTRY }} bundle-build docker push $BUNDLE_IMG - name: Build and push catalog (index) image to local registry run: | - make catalog-build + make REGISTRY=${{ env.REGISTRY }} catalog-build docker push $CATALOG_IMG - name: Install OLM From 86d9414b5e099effba59adedf882f45de89a8ae0 Mon Sep 17 00:00:00 2001 From: Michael Burman Date: Thu, 4 Sep 2025 17:48:05 +0300 Subject: [PATCH 4/7] More more more.. --- .github/workflows/olm-e2e.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/olm-e2e.yml b/.github/workflows/olm-e2e.yml index 09ec657b7..4596013ad 100644 --- a/.github/workflows/olm-e2e.yml +++ b/.github/workflows/olm-e2e.yml @@ -49,9 +49,7 @@ jobs: hack/cluster.sh - name: Build and push operator images to local registry run: | - make REGISTRY=${{ env.REGISTRY }} docker-build docker-logger-build - docker push $IMG - docker push $LOG_IMG + make REGISTRY=${{ env.REGISTRY }} ORG=localhost:5001/k8ssandra docker-build docker-logger-build docker-push docker-logger-push - name: Generate OLM bundle run: | @@ -61,13 +59,11 @@ jobs: - name: Build and push bundle image to local registry run: | BUNDLE_IMG=${{ steps.vars.outputs.bundle_img }} - make REGISTRY=${{ env.REGISTRY }} bundle-build - docker push $BUNDLE_IMG + make REGISTRY=${{ env.REGISTRY }} BUNDLE_IMG=$BUNDLE_IMG bundle-build bundle-push - name: Build and push catalog (index) image to local registry run: | - make REGISTRY=${{ env.REGISTRY }} catalog-build - docker push $CATALOG_IMG + make REGISTRY=${{ env.REGISTRY }} catalog-build catalog-push - name: Install OLM run: | From faa2ebf1743c12b4d27e56dc8e2417228deb29f5 Mon Sep 17 00:00:00 2001 From: Michael Burman Date: Thu, 4 Sep 2025 18:08:12 +0300 Subject: [PATCH 5/7] More *n --- .github/workflows/olm-e2e.yml | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/.github/workflows/olm-e2e.yml b/.github/workflows/olm-e2e.yml index 4596013ad..7a63465c8 100644 --- a/.github/workflows/olm-e2e.yml +++ b/.github/workflows/olm-e2e.yml @@ -27,17 +27,11 @@ jobs: with: go-version-file: 'go.mod' cache: false - - name: Install yq run: | sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_amd64 sudo chmod +x /usr/local/bin/yq - - - name: Set version vars - id: vars - run: | - echo "bundle_img=${{ env.REGISTRY }}/k8ssandra/cass-operator-bundle:v$(make version)" >> $GITHUB_OUTPUT - # The runners already have the latest versions of tools, no need to reinstall them + # The runners already have the latest versions of tools, no need to reinstall them - name: Link tools shell: bash run: | @@ -50,39 +44,32 @@ jobs: - name: Build and push operator images to local registry run: | make REGISTRY=${{ env.REGISTRY }} ORG=localhost:5001/k8ssandra docker-build docker-logger-build docker-push docker-logger-push - - name: Generate OLM bundle run: | - make REGISTRY=${{ env.REGISTRY }} bundle + make REGISTRY=${{ env.REGISTRY }} ORG=localhost:5001/k8ssandra bundle bin/operator-sdk bundle validate ./bundle --select-optional suite=operatorframework - - name: Build and push bundle image to local registry run: | - BUNDLE_IMG=${{ steps.vars.outputs.bundle_img }} - make REGISTRY=${{ env.REGISTRY }} BUNDLE_IMG=$BUNDLE_IMG bundle-build bundle-push - + make ORG=localhost:5001/k8ssandra bundle-build bundle-push - name: Build and push catalog (index) image to local registry run: | - make REGISTRY=${{ env.REGISTRY }} catalog-build catalog-push - + make ORG=localhost:5001/k8ssandra catalog-build catalog-push - name: Install OLM run: | bin/operator-sdk olm install --timeout 5m kubectl get pods -n olm - - name: Run OLM deployment from bundle image run: | + BUNDLE_IMG=${{ env.REGISTRY }}/k8ssandra/cass-operator-bundle:v$(make version) kubectl create ns ${{ env.NAMESPACE }} || true - bin/operator-sdk run bundle ${{ steps.vars.outputs.bundle_img }} --namespace ${{ env.NAMESPACE }} --timeout 10m + bin/operator-sdk run bundle $BUNDLE_IMG --namespace ${{ env.NAMESPACE }} --timeout 10m # Wait for CSV to succeed kubectl -n ${{ env.NAMESPACE }} wait --for=jsonpath='{.status.phase}'=Succeeded csv --all --timeout=300s kubectl -n ${{ env.NAMESPACE }} get csv kubectl -n ${{ env.NAMESPACE }} get deploy,po - - name: Run scorecard (olm suite) run: | bin/operator-sdk scorecard ./bundle --selector=suite=olm --verbose - - name: Red Hat static checks (bundle) uses: actions/setup-python@v5 with: From b45585fca526ff460addab2c625ff27e63179053 Mon Sep 17 00:00:00 2001 From: Michael Burman Date: Thu, 4 Sep 2025 18:15:24 +0300 Subject: [PATCH 6/7] --use-http for the run bundle due to localhost registry --- .github/workflows/olm-e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/olm-e2e.yml b/.github/workflows/olm-e2e.yml index 7a63465c8..91fe99ae6 100644 --- a/.github/workflows/olm-e2e.yml +++ b/.github/workflows/olm-e2e.yml @@ -62,7 +62,7 @@ jobs: run: | BUNDLE_IMG=${{ env.REGISTRY }}/k8ssandra/cass-operator-bundle:v$(make version) kubectl create ns ${{ env.NAMESPACE }} || true - bin/operator-sdk run bundle $BUNDLE_IMG --namespace ${{ env.NAMESPACE }} --timeout 10m + bin/operator-sdk run bundle $BUNDLE_IMG --namespace ${{ env.NAMESPACE }} --timeout 10m --use-http # Wait for CSV to succeed kubectl -n ${{ env.NAMESPACE }} wait --for=jsonpath='{.status.phase}'=Succeeded csv --all --timeout=300s kubectl -n ${{ env.NAMESPACE }} get csv From bc0b9f2c46fbeddc38856f4dbed37ba26c23f534 Mon Sep 17 00:00:00 2001 From: Michael Burman Date: Wed, 10 Sep 2025 14:29:40 +0300 Subject: [PATCH 7/7] Add verbose logging --- .github/workflows/olm-e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/olm-e2e.yml b/.github/workflows/olm-e2e.yml index 91fe99ae6..776e712c3 100644 --- a/.github/workflows/olm-e2e.yml +++ b/.github/workflows/olm-e2e.yml @@ -62,7 +62,7 @@ jobs: run: | BUNDLE_IMG=${{ env.REGISTRY }}/k8ssandra/cass-operator-bundle:v$(make version) kubectl create ns ${{ env.NAMESPACE }} || true - bin/operator-sdk run bundle $BUNDLE_IMG --namespace ${{ env.NAMESPACE }} --timeout 10m --use-http + bin/operator-sdk run bundle $BUNDLE_IMG --namespace ${{ env.NAMESPACE }} --timeout 10m --use-http --verbose # Wait for CSV to succeed kubectl -n ${{ env.NAMESPACE }} wait --for=jsonpath='{.status.phase}'=Succeeded csv --all --timeout=300s kubectl -n ${{ env.NAMESPACE }} get csv