From 233de7ea5f895ef5be319386f437f46d3bdde048 Mon Sep 17 00:00:00 2001 From: Mark Campbell Date: Fri, 19 Jan 2024 12:34:36 +0000 Subject: [PATCH] Added Workflow job to update CFO image (#398) --- .github/workflows/tag-and-build.yml | 7 ++++++- Makefile | 4 ++-- config/manager/kustomization.yaml | 16 ++++++++++++++++ config/manager/manager.yaml | 2 +- config/manager/params.env | 1 + config/manager/params.yaml | 3 +++ config/manifests/kustomization.yaml | 3 ++- 7 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 config/manager/params.env create mode 100644 config/manager/params.yaml diff --git a/.github/workflows/tag-and-build.yml b/.github/workflows/tag-and-build.yml index 02c850f7..f04d43d6 100644 --- a/.github/workflows/tag-and-build.yml +++ b/.github/workflows/tag-and-build.yml @@ -102,6 +102,11 @@ jobs: sed -i -E "s/(.*INSTASCALE_VERSION \?= ).*/\1${{ github.event.inputs.instascale-version }}/" Makefile sed -i -E "s/(.*KUBERAY_VERSION \?= ).*/\1${{ github.event.inputs.kuberay-version }}/" Makefile + - name: Update image version in params.env + run: | + VERSION=${{ github.event.inputs.version }} perl -i -pe 's/:(.*)$/:$ENV{"VERSION"}/' config/manager/params.env + shell: bash + - name: Login to Quay.io uses: redhat-actions/podman-login@v1 with: @@ -138,7 +143,7 @@ jobs: uses: stefanzweifel/git-auto-commit-action@v4 with: commit_message: Update dependency versions for release ${{ github.event.inputs.version }} - file_pattern: 'README.md *.yaml Makefile go.mod go.sum' + file_pattern: 'README.md *.yaml Makefile go.mod go.sum *.env' create_branch: true branch: ${{ env.PR_BRANCH_NAME }} diff --git a/Makefile b/Makefile index 8f15e0b4..0e2b24c3 100644 --- a/Makefile +++ b/Makefile @@ -198,7 +198,7 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified .PHONY: deploy deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. - cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} + cd config/manager && IMAGE=$(IMG) perl -i -pe 's/codeflare-operator-controller-image=(.*)$$/codeflare-operator-controller-image=$$ENV{"IMAGE"}/' params.env $(KUSTOMIZE) build config/${ENV} | kubectl apply -f - git restore config/* @@ -283,8 +283,8 @@ validate-bundle: install-operator-sdk .PHONY: bundle bundle: manifests kustomize install-operator-sdk ## Generate bundle manifests and metadata, then validate generated files. + cd config/manager && IMAGE=$(IMG) perl -i -pe 's/codeflare-operator-controller-image=(.*)$$/codeflare-operator-controller-image=$$ENV{"IMAGE"}/' params.env $(OPERATOR_SDK) generate kustomize manifests -q - cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG) cd config/manifests && $(KUSTOMIZE) edit add patch --patch '[{"op":"add", "path":"/metadata/annotations/containerImage", "value": "$(IMG)" }]' --kind ClusterServiceVersion cd config/manifests && $(KUSTOMIZE) edit add patch --patch '[{"op":"add", "path":"/spec/replaces", "value": "codeflare-operator.$(PREVIOUS_VERSION)" }]' --kind ClusterServiceVersion $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS) diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 4fe5ccaa..847eca17 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -3,3 +3,19 @@ resources: generatorOptions: disableNameSuffixHash: true + +configMapGenerator: +- name: stack-config + envs: + - params.env +configurations: + - params.yaml + +vars: +- name: codeflare_operator_controller_image + objref: + kind: ConfigMap + name: stack-config + apiVersion: v1 + fieldref: + fieldpath: data.codeflare-operator-controller-image diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index 8a4f6451..20a34fe9 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -34,7 +34,7 @@ spec: containers: - command: - /manager - image: controller:latest + image: $(codeflare_operator_controller_image) imagePullPolicy: Always name: manager securityContext: diff --git a/config/manager/params.env b/config/manager/params.env new file mode 100644 index 00000000..8c9de784 --- /dev/null +++ b/config/manager/params.env @@ -0,0 +1 @@ +codeflare-operator-controller-image=quay.io/opendatahub/codeflare-operator:v1.0.1 diff --git a/config/manager/params.yaml b/config/manager/params.yaml new file mode 100644 index 00000000..43509ff2 --- /dev/null +++ b/config/manager/params.yaml @@ -0,0 +1,3 @@ +varReference: + - path: spec/template/spec/containers[]/image + kind: Deployment diff --git a/config/manifests/kustomization.yaml b/config/manifests/kustomization.yaml index 958a9e24..161a419d 100644 --- a/config/manifests/kustomization.yaml +++ b/config/manifests/kustomization.yaml @@ -1,8 +1,9 @@ # These resources constitute the fully configured set of manifests # used to generate the 'manifests/' directory in a bundle. resources: -- bases/codeflare-operator.clusterserviceversion.yaml - ../default - ../scorecard +- bases/codeflare-operator.clusterserviceversion.yaml + apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization