From 0f0fb43fcca9f6bee4d7d874aa94701077205666 Mon Sep 17 00:00:00 2001 From: Rehan Khan Date: Tue, 24 Sep 2024 11:38:06 +0530 Subject: [PATCH] Added support for s390x and ppc64le via catalog source Co-authored-by: Rehan Khan Co-authored-by: Deepali Kushwah Signed-off-by: Rehan Khan --- .github/workflows/build-images.yaml | 63 ++++++++++------------------- README.md | 11 ----- script/build_catalog.sh | 40 ++++++++++++++++++ 3 files changed, 62 insertions(+), 52 deletions(-) create mode 100644 script/build_catalog.sh diff --git a/.github/workflows/build-images.yaml b/.github/workflows/build-images.yaml index 6400acd3..5603cc31 100644 --- a/.github/workflows/build-images.yaml +++ b/.github/workflows/build-images.yaml @@ -192,48 +192,29 @@ jobs: else echo "VERSION=${{ github.sha }}" >> $GITHUB_ENV fi - - name: Install qemu dependency - run: | - sudo apt-get update - sudo apt-get install -y qemu-user-static - - name: Run make catalog (main) - if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }} - run: | - make catalog \ - REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} \ - VERSION=${{ env.VERSION }} \ - IMAGE_TAG=${{ github.sha }} \ - AUTHORINO_VERSION=${{ env.LATEST_AUTHORINO_GITREF }} \ - CHANNELS=${{ inputs.channels }} - - name: Run make catalog (release) - if: ${{ github.ref_name != env.MAIN_BRANCH_NAME }} - run: | - make catalog \ - REGISTRY=${{ env.IMG_REGISTRY_HOST }} ORG=${{ env.IMG_REGISTRY_ORG }} \ - VERSION=${{ env.VERSION }} \ - AUTHORINO_VERSION=${{ github.event.inputs.authorinoVersion }} \ - CHANNELS=${{ inputs.channels }} - - name: Git diff - run: git diff - - name: Build Image - id: build-image - uses: redhat-actions/buildah-build@v2 + - name: Install opm from OpenShift Mirror + uses: redhat-actions/openshift-tools-installer@v1 with: - image: ${{ env.OPERATOR_NAME }}-catalog - tags: ${{ env.IMG_TAGS }} - platforms: linux/amd64,linux/arm64 - context: ./catalog - dockerfiles: | - ./catalog/${{ env.OPERATOR_NAME }}-catalog.Dockerfile - - name: Push Image - if: ${{ !env.ACT }} - id: push-to-quay - uses: redhat-actions/push-to-registry@v2 + opm: "4.14.4" + - name: Set permissions for build script + run: chmod +x ./script/build_catalog.sh + - name: Login to Quay.io + uses: docker/login-action@v1 with: - image: ${{ steps.build-image.outputs.image }} - tags: ${{ steps.build-image.outputs.tags }} - registry: ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }} + registry: ${{ secrets.IMG_REGISTRY_HOST || 'quay.io' }} username: ${{ secrets.IMG_REGISTRY_USERNAME }} password: ${{ secrets.IMG_REGISTRY_TOKEN }} - - name: Print Image URL - run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}" + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: build and push catalog (main) + if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }} + shell: bash + env: + TAG: ${{ env.IMG_TAGS }} + run: ./script/build_catalog.sh + - name: build and push catalog (release) + if: ${{ github.ref_name != env.MAIN_BRANCH_NAME }} + shell: bash + env: + TAG: ${{ env.IMG_TAGS }} + run: ./script/build_catalog.sh \ No newline at end of file diff --git a/README.md b/README.md index 239b0e0d..93317778 100644 --- a/README.md +++ b/README.md @@ -77,17 +77,6 @@ spec: EOF ``` -## Deploy authorino operator using operator-sdk -1. Install operator-sdk bin - ```sh - make operator-sdk - ``` -2. Run operator-sdk bundle command - ``` - ./bin/operator-sdk run bundle quay.io/kuadrant/authorino-operator-bundle:latest - ``` -Note: For s390x & ppc64le , use operator-sdk to install authorino-operator - ## Requesting an Authorino instance Once the Operator is up and running, you can request instances of Authorino by creating `Authorino` CRs. E.g.: diff --git a/script/build_catalog.sh b/script/build_catalog.sh new file mode 100644 index 00000000..7a7df464 --- /dev/null +++ b/script/build_catalog.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# builds the OLM catalog index and pushes it to quay.io. +# +# To push to your own registry, override the IMG_REGISTRY_HOST , IMG_REGISTRY_ORG , OPERATOR_NAME and TAG env vars, +# i.e: +# IMG_REGISTRY_HOST=quay.io IMG_REGISTRY_ORG=yourusername OPERATOR_NAME=authorino-operator TAG=latest ./script/build_catalog.sh +# +# REQUIREMENTS: +# * a valid login session to a container registry. +# * `docker` +# * `opm` +# + +# Iterate over tag list i.e. latest 8a17c81d5e9f04545753e5501dddc4a0ac2c7e03 +IFS=' ' read -r -a tags <<< "$TAG" + +for tag in "${tags[@]}" +do + # Build & push catalog images for each architecture using the tag + opm index add --build-tool docker --tag "${IMG_REGISTRY_HOST}/${IMG_REGISTRY_ORG}/${OPERATOR_NAME}-catalog:${tag}-amd64" --bundles "${IMG_REGISTRY_HOST}/${IMG_REGISTRY_ORG}/${OPERATOR_NAME}-bundle:${tag}" --binary-image "quay.io/operator-framework/opm:v1.28.0-amd64" + docker push ${IMG_REGISTRY_HOST}/${IMG_REGISTRY_ORG}/${OPERATOR_NAME}-catalog:${tag}-amd64 + + opm index add --build-tool docker --tag "${IMG_REGISTRY_HOST}/${IMG_REGISTRY_ORG}/${OPERATOR_NAME}-catalog:${tag}-ppc64le" --bundles "${IMG_REGISTRY_HOST}/${IMG_REGISTRY_ORG}/${OPERATOR_NAME}-bundle:${tag}" --binary-image "quay.io/operator-framework/opm:v1.28.0-ppc64le" + docker push ${IMG_REGISTRY_HOST}/${IMG_REGISTRY_ORG}/${OPERATOR_NAME}-catalog:${tag}-ppc64le + + opm index add --build-tool docker --tag "${IMG_REGISTRY_HOST}/${IMG_REGISTRY_ORG}/${OPERATOR_NAME}-catalog:${tag}-arm64" --bundles "${IMG_REGISTRY_HOST}/${IMG_REGISTRY_ORG}/${OPERATOR_NAME}-bundle:${tag}" --binary-image "quay.io/operator-framework/opm:v1.28.0-arm64" + docker push ${IMG_REGISTRY_HOST}/${IMG_REGISTRY_ORG}/${OPERATOR_NAME}-catalog:${tag}-arm64 + + opm index add --build-tool docker --tag "${IMG_REGISTRY_HOST}/${IMG_REGISTRY_ORG}/${OPERATOR_NAME}-catalog:${tag}-s390x" --bundles "${IMG_REGISTRY_HOST}/${IMG_REGISTRY_ORG}/${OPERATOR_NAME}-bundle:${tag}" --binary-image "quay.io/operator-framework/opm:v1.28.0-s390x" + docker push ${IMG_REGISTRY_HOST}/${IMG_REGISTRY_ORG}/${OPERATOR_NAME}-catalog:${tag}-s390x + + # Create a multi-architecture manifest + docker manifest create --amend ${IMG_REGISTRY_HOST}/${IMG_REGISTRY_ORG}/${OPERATOR_NAME}-catalog:${tag} \ + ${IMG_REGISTRY_HOST}/${IMG_REGISTRY_ORG}/${OPERATOR_NAME}-catalog:${tag}-amd64 \ + ${IMG_REGISTRY_HOST}/${IMG_REGISTRY_ORG}/${OPERATOR_NAME}-catalog:${tag}-arm64 \ + ${IMG_REGISTRY_HOST}/${IMG_REGISTRY_ORG}/${OPERATOR_NAME}-catalog:${tag}-ppc64le \ + ${IMG_REGISTRY_HOST}/${IMG_REGISTRY_ORG}/${OPERATOR_NAME}-catalog:${tag}-s390x + + docker manifest push ${IMG_REGISTRY_HOST}/${IMG_REGISTRY_ORG}/${OPERATOR_NAME}-catalog:${tag} +done \ No newline at end of file