From c65f3740adcdba875c49718e190c75ea613a7756 Mon Sep 17 00:00:00 2001 From: Feruzjon Muyassarov Date: Fri, 29 Dec 2023 11:37:45 +0200 Subject: [PATCH] patch operator manifests before the release Ensure that operator manifests are pointing to the right tag/version before pushing a new tag. Signed-off-by: Feruzjon Muyassarov --- .github/ISSUE_TEMPLATE/new-release.md | 4 --- .github/workflows/package-helm.yaml | 2 ++ deployment/operator/Makefile | 33 ++++++++++------- ...ns-operator.clusterserviceversion.yaml.in} | 0 hack/release-helper.sh | 36 ------------------- 5 files changed, 23 insertions(+), 52 deletions(-) rename deployment/operator/config/manifests/bases/{nri-plugins-operator.clusterserviceversion.yaml => nri-plugins-operator.clusterserviceversion.yaml.in} (100%) delete mode 100755 hack/release-helper.sh diff --git a/.github/ISSUE_TEMPLATE/new-release.md b/.github/ISSUE_TEMPLATE/new-release.md index 53e649560..8ea7d7ae4 100644 --- a/.github/ISSUE_TEMPLATE/new-release.md +++ b/.github/ISSUE_TEMPLATE/new-release.md @@ -21,10 +21,6 @@ future releases. - [ ] Sync/tidy up dependencies. - [ ] Run `go mod tidy`. - [ ] Run `git commit -m 'go.mod,go.sum: update dependencies.' go.{mod,sum}`, if necessary. - - [ ] Update deployment files - - [ ] run `hack/release-helper.sh` - - [ ] commit changes, submit as a PR to GitHub - - [ ] wait for the PR to be merged - [ ] Run `git tag -a -m "NRI plugins $VERSION" $VERSION`. - Publishing - [ ] Push the tag with `git push $VERSION`. diff --git a/.github/workflows/package-helm.yaml b/.github/workflows/package-helm.yaml index 32c898890..ad2660a97 100644 --- a/.github/workflows/package-helm.yaml +++ b/.github/workflows/package-helm.yaml @@ -22,6 +22,8 @@ jobs: - name: Package Helm charts run: | + find "$CHARTS_DIR" -name values.yaml | xargs -I '{}' \ + sed -e s"/pullPolicy:.*/pullPolicy: IfNotPresent/" -i '{}' helm package --version "$GITHUB_REF_NAME" --app-version "$GITHUB_REF_NAME" "$CHARTS_DIR"/* find . -name '*.tgz' -print | while read SRC_FILE; do DEST_FILE=$(echo $SRC_FILE | sed 's/v/helm-chart-v/g') diff --git a/deployment/operator/Makefile b/deployment/operator/Makefile index 869ce76fe..e8b856f61 100644 --- a/deployment/operator/Makefile +++ b/deployment/operator/Makefile @@ -57,7 +57,7 @@ endif OPERATOR_SDK_VERSION ?= v1.32.0 # Image URL to use all building/pushing image targets -IMG ?= $(IMAGE_TAG_BASE):$(IMAGE_VERSION) +IMAGE ?= $(IMAGE_TAG_BASE):$(IMAGE_VERSION) # (Default) operator image dockerfile and bundle image dockerfile. DOCKERFILE ?= Dockerfile @@ -94,31 +94,37 @@ endif endif .PHONY: bundle -bundle: copy-crds kustomize operator-sdk ## Generate bundle manifests and metadata, then validate generated files. +bundle: copy-crds kustomize operator-sdk kustomizations ## Generate bundle manifests and metadata, then validate generated files. $(OPERATOR_SDK) generate kustomize manifests -q - cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG) + cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMAGE) + find config/manifests/bases -name nri-plugins-operator.clusterserviceversion.yaml | xargs -I '{}' \ + sed -e "s|containerImage:.*|containerImage: $(IMAGE)|" -i '{}'; $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS) + $(MAKE) bundle-validate + $(MAKE) cleanup-crds + +.PHONY: bundle-validate +bundle-validate: $(OPERATOR_SDK) bundle validate ./bundle \ --select-optional name=operatorhub \ --select-optional suite=operatorframework \ --select-optional name=good-practices \ - --select-optional suite=operatorframework; \ - $(MAKE) cleanup-crds; + --select-optional suite=operatorframework .PHONY: docker-build: - docker build -f $(DOCKERFILE) -t ${IMG} . + docker build -f $(DOCKERFILE) -t ${IMAGE} . .PHONY: docker-push docker-push: - docker push ${IMG} + docker push ${IMAGE} .PHONY: docker-save docker-save: docker-build - @img_name="${IMG}"; \ + @img_name="${IMAGE}"; \ img_name="$${img_name##*/}"; \ img_name="$${img_name%:*}"; \ - img_info=`docker images --filter=reference=${IMG} --format '{{.ID}} {{.Repository}}:{{.Tag}} (created {{.CreatedSince}}, {{.CreatedAt}})' | head -n 1`; \ + img_info=`docker images --filter=reference=${IMAGE} --format '{{.ID}} {{.Repository}}:{{.Tag}} (created {{.CreatedSince}}, {{.CreatedAt}})' | head -n 1`; \ img_id=`awk '{print $$1}' <<< "$${img_info}"`; \ img_tag=`awk '{print $$2}' <<< "$${img_info}"`; \ img_tar=`realpath "$(IMAGE_PATH)/$${img_name}-image-$${img_id}.tar"`; \ @@ -161,7 +167,7 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross - docker buildx create --name project-v3-builder docker buildx use project-v3-builder - - docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross . + - docker buildx build --push --platform=$(PLATFORMS) --tag ${IMAGE} -f Dockerfile.cross . - docker buildx rm project-v3-builder rm Dockerfile.cross @@ -177,7 +183,7 @@ uninstall: copy-crds kustomize ## Uninstall CRDs from the K8s cluster specified .PHONY: deploy deploy: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. - cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} + cd config/manager && $(KUSTOMIZE) edit set image controller=${IMAGE} $(KUSTOMIZE) build config/default | kubectl apply -f - .PHONY: undeploy @@ -237,7 +243,10 @@ cleanup-crds: ## Clean up temporarily copied CRDs and CRs. rm -f $(SAMPLE_DEST_DIR)/noderesourcetopology.yaml .PHONY: kustomizations -kustomizations: config/manager/kustomization.yaml +kustomizations: config/manager/kustomization.yaml config/manifests/bases/nri-plugins-operator.clusterserviceversion.yaml config/manager/kustomization.yaml: config/manager/kustomization.yaml.in @cp $< $@ + +config/manifests/bases/nri-plugins-operator.clusterserviceversion.yaml: config/manifests/bases/nri-plugins-operator.clusterserviceversion.yaml.in + @cp $< $@ diff --git a/deployment/operator/config/manifests/bases/nri-plugins-operator.clusterserviceversion.yaml b/deployment/operator/config/manifests/bases/nri-plugins-operator.clusterserviceversion.yaml.in similarity index 100% rename from deployment/operator/config/manifests/bases/nri-plugins-operator.clusterserviceversion.yaml rename to deployment/operator/config/manifests/bases/nri-plugins-operator.clusterserviceversion.yaml.in diff --git a/hack/release-helper.sh b/hack/release-helper.sh deleted file mode 100755 index 7e6f4636a..000000000 --- a/hack/release-helper.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -e -set -o pipefail - -this=`basename $0` - -usage () { -cat << EOF -Usage: $this VERSION - -Example: - - $this v0.2.0 -EOF -} - -# Check args -if [ $# -ne 1 ]; then - usage - exit 1 -fi - -version=$1 -shift 1 - -if ! [[ $version =~ ^v[0-9]+\.[0-9]+\..+$ ]]; then - echo -e "ERROR: invalid VERSION '$version'" - exit 1 -fi - -# Patch Helm charts -echo "Patching Helm charts" -find deployment/helm -name Chart.yaml | xargs -I '{}' \ - sed -e s"/appVersion:.*/appVersion: $version/" -i '{}' -find deployment/helm -name values.yaml | xargs -I '{}' \ - sed -e s"/pullPolicy:.*/pullPolicy: IfNotPresent/" -i '{}' -