Skip to content

Commit

Permalink
WIP: migrating OLM (operator lifecycle manager) pipeline from Concour…
Browse files Browse the repository at this point in the history
…se to github action
  • Loading branch information
DanielePalaia committed Feb 21, 2024
1 parent 5823b07 commit 6173685
Show file tree
Hide file tree
Showing 2 changed files with 236 additions and 0 deletions.
119 changes: 119 additions & 0 deletions .github/workflows/testing_OLM.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# action to test our operator lifecycle manager bundle
name: test-OLM

on:
push:
# Pattern matched against refs/tags
branches:
- "testing_olm"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
GO_VERSION: ~1.21

jobs:
build-image:
name: Build an image of this operator to be used by the OLM packaging
runs-on: ubuntu-latest
container: us.gcr.io/cf-rabbitmq-for-k8s-bunny/rabbitmq-for-kubernetes-ci-olm
permissions:
contents: 'read'
id-token: 'write'
steps:
- uses: actions/checkout@v4
# for tkgi we would store the binary in the repo to avoid downloading it from tanzunet
- name: Auth to Google Cloud
uses: 'google-github-actions/auth@v2'
with:
workload_identity_provider: ${{ secrets.GCP_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SA }}

- name: OCI Metadata for multi-arch image
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
us.gcr.io/cf-rabbitmq-for-k8s-bunny/rabbitmq-for-kubernetes-dev-olm
tags: |
us.gcr.io/cf-rabbitmq-for-k8s-bunny/rabbitmq-for-kubernetes-dev-olm:0.0.0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64, linux/arm64, linux/ppc64le, linux/s390x
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

create-olm-package:
name: Create the OLM Packaging
runs-on: ubuntu-latest
container: us.gcr.io/cf-rabbitmq-for-k8s-bunny/rabbitmq-for-kubernetes-ci-olm

steps:
- name: create-olm-package
run: |
git clone https://github.com/rabbitmq/OLM-Package-Repo
make generate-installation-manifest
cp ./config/crd/bases/rabbitmq.com_rabbitmqclusters.yaml ./OLM-Package-Repo/generate_OLM/generate_OLM_cluster_operator/manifests_crds/crds.yaml
cp ./releases/cluster-operator.yml ./OLM-Package-Repo/generate_OLM/generate_OLM_cluster_operator/manifests_crds/cluster-operator.yaml
cp OLM-Package-Repo/generate_OLM/generate_OLM_cluster_operator/generators/cluster-service-version-generator-test.yml OLM-Package-Repo/generate_OLM/generate_OLM_cluster_operator//generators/cluster-service-version-generator.yml
cd ./OLM-Package-Repo/generate_OLM/generate_OLM_cluster_operator/
python3 generate-olm-package.py ./manifests_crds/cluster-operator.yaml 0.0.0 ./../../OLM-Package-Repo/OLM/rabbitmq-cluster-operator
cd ../..
sed -i -e 's/rabbitmqoperator\/cluster-operator:.*/us.gcr.io\/cf-rabbitmq-for-k8s-bunny\/rabbitmq-for-kubernetes-dev-olm:0.0.0/g' ./0.0.0/manifests/rabbitmq.clusterserviceversion.yaml
opm alpha bundle build -c stable -d ./0.0.0/manifests -t $DOCKER_REGISTRY_SERVER/$OLM_IMAGE:0.0.0 -p rabbitmq-cluster-operator --image-builder podman
echo "y" | gcloud auth configure-docker
podman push $DOCKER_REGISTRY_SERVER/$OLM_IMAGE:0.0.0
opm index add -b $DOCKER_REGISTRY_SERVER/$OLM_IMAGE:0.0.0 -t $DOCKER_REGISTRY_SERVER/$OLM_INDEX_IMAGE:0.0.0 -c podman
podman push $DOCKER_REGISTRY_SERVER/$OLM_INDEX_IMAGE:0.0.0
test-olm-package:
name: Tests the OLM packaging
runs-on: ubuntu-latest
container: us.gcr.io/cf-rabbitmq-for-k8s-bunny/rabbitmq-for-kubernetes-ci-olm

steps:
- name: Get Openshift connection info kubeconf from infrastructure repo
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUBACCESSTOKEN }}
run: |
git clone https://oauth2:"$GITHUB_ACCESS_TOKEN"@github.com/rabbitmq/infrastructure
- name: Protect access to the cluster with a mutex
uses: ben-z/[email protected]
with:
repo-token: ${{ secrets.GITHUBACCESSTOKEN }}
repository: https://github.com/rabbitmq-pro/tanzu-carvel-package-repo
branch: lock-openshift

- name: Connect to the Openshift cluster and deploy the operators through OLM
run: |
git clone https://github.com/rabbitmq/OLM-Package-Repo
export KUBECONFIG=./infrastructure/k8s/okd/admin-kubeconfig.yaml
export ENVIRONMENT=openshift
kubectl config use-context admin
olm-repo/testfiles
kubectl create -f ./olm-repo/testfiles/catalogsource-openshift.yaml
kubectl create ns rabbitmq-system
kubectl create -f og.yaml
kubectl create -f ./olm-repo/testfiles/sub_devopstales-catalog-openshift.yaml
make system-tests
- name: Clean up
if: always()
run: |
kubectl delete csv rabbitmq-cluster-operator.v0.0.0 -n rabbitmq-system
kubectl delete -f sub_devopstales-catalog-openshift.yaml
kubectl delete -f og.yaml
kubectl delete ns rabbitmq-system
kubectl delete -f catalogsource-openshift.yaml
117 changes: 117 additions & 0 deletions .github/workflows/testing_OLM_bundle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# action to test our operator lifecycle manager bundle
name: test-OLM

on:
push:
# Pattern matched against refs/tags
branches:
- "adding_tkg_test_action"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
GO_VERSION: ~1.21

jobs:
build-image:
name: Build an image of this operator to be used by the OLM packaging
runs-on: ubuntu-latest
container: us.gcr.io/cf-rabbitmq-for-k8s-bunny/rabbitmq-for-kubernetes-ci-olm
permissions:
contents: 'read'
id-token: 'write'
steps:
- uses: actions/checkout@v4
# for tkgi we would store the binary in the repo to avoid downloading it from tanzunet
- name: Auth to Google Cloud
uses: 'google-github-actions/auth@v2'
with:
workload_identity_provider: ${{ secrets.GCP_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SA }}

- name: OCI Metadata for multi-arch image
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
us.gcr.io/cf-rabbitmq-for-k8s-bunny/rabbitmq-for-kubernetes-dev-olm
tags: |
us.gcr.io/cf-rabbitmq-for-k8s-bunny/rabbitmq-for-kubernetes-dev-olm:0.0.0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64, linux/arm64, linux/ppc64le, linux/s390x
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

create-olm-package:
name: Create the OLM Packaging
runs-on: ubuntu-latest
container: us.gcr.io/cf-rabbitmq-for-k8s-bunny/rabbitmq-for-kubernetes-ci-olm

steps:
- name: create-olm-package
run: |
git clone https://github.com/rabbitmq/OLM-Package-Repo
make generate-installation-manifest
cp ./config/crd/bases/rabbitmq.com_rabbitmqclusters.yaml ./OLM-Package-Repo/generate_OLM/generate_OLM_cluster_operator/manifests_crds/crds.yaml
cp ./releases/cluster-operator.yml ./OLM-Package-Repo/generate_OLM/generate_OLM_cluster_operator/manifests_crds/cluster-operator.yaml
cp OLM-Package-Repo/generate_OLM/generate_OLM_cluster_operator/generators/cluster-service-version-generator-test.yml OLM-Package-Repo/generate_OLM/generate_OLM_cluster_operator//generators/cluster-service-version-generator.yml
python3 ./OLM-Package-Repo/generate_OLM/generate_OLM_cluster_operator/generate-olm-package.py ./manifests_crds/cluster-operator.yaml 0.0.0 ./OLM-Package-Repo/OLM/rabbitmq-cluster-operator
sed -i -e 's/rabbitmqoperator\/cluster-operator:.*/us.gcr.io\/cf-rabbitmq-for-k8s-bunny\/rabbitmq-for-kubernetes-dev-olm:0.0.0/g' ./0.0.0/manifests/rabbitmq.clusterserviceversion.yaml
opm alpha bundle build -c stable -d ./0.0.0/manifests -t $DOCKER_REGISTRY_SERVER/$OLM_IMAGE:0.0.0 -p rabbitmq-cluster-operator --image-builder podman
echo "y" | gcloud auth configure-docker
podman push $DOCKER_REGISTRY_SERVER/$OLM_IMAGE:0.0.0
opm index add -b $DOCKER_REGISTRY_SERVER/$OLM_IMAGE:0.0.0 -t $DOCKER_REGISTRY_SERVER/$OLM_INDEX_IMAGE:0.0.0 -c podman
podman push $DOCKER_REGISTRY_SERVER/$OLM_INDEX_IMAGE:0.0.0
test-olm-package:
name: Tests the OLM packaging
runs-on: ubuntu-latest
container: us.gcr.io/cf-rabbitmq-for-k8s-bunny/rabbitmq-for-kubernetes-ci-olm

steps:
- name: Get Openshift connection info kubeconf from infrastructure repo
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUBACCESSTOKEN }}
run: |
git clone https://oauth2:"$GITHUB_ACCESS_TOKEN"@github.com/rabbitmq/infrastructure
- name: Protect access to the cluster with a mutex
uses: ben-z/[email protected]
with:
repo-token: ${{ secrets.GITHUBACCESSTOKEN }}
repository: https://github.com/rabbitmq-pro/tanzu-carvel-package-repo
branch: lock-openshift

- name: Connect to the Openshift cluster and deploy the operators through OLM
run: |
git clone https://github.com/rabbitmq/OLM-Package-Repo
export KUBECONFIG=./infrastructure/k8s/okd/admin-kubeconfig.yaml
export ENVIRONMENT=openshift
kubectl config use-context admin
olm-repo/testfiles
kubectl create -f ./olm-repo/testfiles/catalogsource-openshift.yaml
kubectl create ns rabbitmq-system
kubectl create -f og.yaml
kubectl create -f ./olm-repo/testfiles/sub_devopstales-catalog-openshift.yaml
make system-tests
- name: Clean up
if: always()
run: |
kubectl delete csv rabbitmq-cluster-operator.v0.0.0 -n rabbitmq-system
kubectl delete -f sub_devopstales-catalog-openshift.yaml
kubectl delete -f og.yaml
kubectl delete ns rabbitmq-system
kubectl delete -f catalogsource-openshift.yaml

0 comments on commit 6173685

Please sign in to comment.