From 88185359c731d41d8909c1ae45bf0a6ec14d0031 Mon Sep 17 00:00:00 2001 From: Michael Nairn Date: Thu, 14 Mar 2024 17:22:26 +0000 Subject: [PATCH] release: Document release process * Add release doc * Update the `make prepare-release` command to properly set BUNDLE and CATALOG images * Add olm installation and make targets `make local-setup install-olm deploy-catalog` --- Makefile | 27 +++++++- config/deploy/olm/catalogsource.yaml | 9 +++ config/deploy/olm/kustomization.yaml | 8 +++ config/deploy/olm/namespace.yaml | 6 ++ config/deploy/olm/operatorgroup.yaml | 4 ++ config/deploy/olm/subscription.yaml | 9 +++ docs/RELEASE.md | 96 ++++++++++++++++++++++++++++ 7 files changed, 156 insertions(+), 3 deletions(-) create mode 100644 config/deploy/olm/catalogsource.yaml create mode 100644 config/deploy/olm/kustomization.yaml create mode 100644 config/deploy/olm/namespace.yaml create mode 100644 config/deploy/olm/operatorgroup.yaml create mode 100644 config/deploy/olm/subscription.yaml create mode 100644 docs/RELEASE.md diff --git a/Makefile b/Makefile index 087fc16..c08e211 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ IMAGE_TAG_BASE ?= quay.io/kuadrant/dns-operator # BUNDLE_IMG defines the image:tag used for the bundle. # You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=/:) -BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION) +BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:latest # BUNDLE_GEN_FLAGS are the flags passed to the operator-sdk generate bundle command BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS) @@ -235,6 +235,20 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. $(KUSTOMIZE) build config/deploy/local | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f - +.PHONY: install-olm +install-olm: operator-sdk + $(OPERATOR_SDK) olm install + +.PHONY: uninstall-olm +uninstall-olm: operator-sdk + $(OPERATOR_SDK) olm uninstall + +deploy-catalog: kustomize yq ## Deploy operator to the K8s cluster specified in ~/.kube/config using OLM catalog image. + $(KUSTOMIZE) build config/deploy/olm | $(KUBECTL) apply -f - + +undeploy-catalog: kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config using OLM catalog image. + $(KUSTOMIZE) build config/deploy/olm | $(KUBECTL) delete -f - + ##@ Build Dependencies ## Location to install dependencies to @@ -347,6 +361,10 @@ bundle-ignore-createdAt: .PHONY: bundle-post-generate bundle-post-generate: $(YQ) -i '.annotations."com.redhat.openshift.versions" = "v4.12-v4.14"' bundle/metadata/annotations.yaml + V="$(CATALOG_IMG)" $(YQ) eval '.spec.image = strenv(V)' -i config/deploy/olm/catalogsource.yaml + @if [ "$(CHANNELS)" != "" ]; then\ + V="$(CHANNELS)" $(YQ) eval '.spec.channel = strenv(V)' -i config/deploy/olm/subscription.yaml; \ + fi .PHONY: bundle-build bundle-build: ## Build the bundle image. @@ -378,7 +396,7 @@ endif BUNDLE_IMGS ?= $(BUNDLE_IMG) # The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0). -CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:v$(VERSION) +CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:latest # Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image. ifneq ($(origin CATALOG_BASE_IMG), undefined) @@ -403,8 +421,11 @@ catalog-push: ## Push a catalog image. .PHONY: prepare-release RELEASE_FILE = $(shell pwd)/make/release.mk +prepare-release: IMG_TAG=v$(VERSION) prepare-release: ## Generates a makefile that will override environment variables for a specific release and runs bundle. - echo -e "#Release default values\\nIMG=$(IMG)\nCHANNELS=$(CHANNELS)\nVERSION=$(VERSION)\nREPLACES_VERSION=$(REPLACES_VERSION)" > $(RELEASE_FILE) + echo -e "#Release default values\\nIMG=$(IMAGE_TAG_BASE):$(IMG_TAG)\nBUNDLE_IMG=$(IMAGE_TAG_BASE)-bundle:$(IMG_TAG)\n\ + CATALOG_IMG=$(IMAGE_TAG_BASE)-catalog:$(IMG_TAG)\nCHANNELS=$(CHANNELS)\nBUNDLE_CHANNELS=--channels=$(CHANNELS)\n\ + VERSION=$(VERSION)\nREPLACES_VERSION=$(REPLACES_VERSION)" > $(RELEASE_FILE) $(MAKE) bundle # Include last to avoid changing MAKEFILE_LIST used above diff --git a/config/deploy/olm/catalogsource.yaml b/config/deploy/olm/catalogsource.yaml new file mode 100644 index 0000000..7f67ed8 --- /dev/null +++ b/config/deploy/olm/catalogsource.yaml @@ -0,0 +1,9 @@ +apiVersion: operators.coreos.com/v1alpha1 +kind: CatalogSource +metadata: + name: dns-operator-catalog +spec: + sourceType: grpc + image: quay.io/kuadrant/dns-operator-catalog:latest + displayName: DNS Operators + publisher: grpc diff --git a/config/deploy/olm/kustomization.yaml b/config/deploy/olm/kustomization.yaml new file mode 100644 index 0000000..d4df93b --- /dev/null +++ b/config/deploy/olm/kustomization.yaml @@ -0,0 +1,8 @@ +# Adds namespace to all resources. +namespace: dns-operator-system + +resources: +- namespace.yaml +- operatorgroup.yaml +- catalogsource.yaml +- subscription.yaml diff --git a/config/deploy/olm/namespace.yaml b/config/deploy/olm/namespace.yaml new file mode 100644 index 0000000..8b55c3c --- /dev/null +++ b/config/deploy/olm/namespace.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: Namespace +metadata: + labels: + control-plane: controller-manager + name: system diff --git a/config/deploy/olm/operatorgroup.yaml b/config/deploy/olm/operatorgroup.yaml new file mode 100644 index 0000000..c9e8b5b --- /dev/null +++ b/config/deploy/olm/operatorgroup.yaml @@ -0,0 +1,4 @@ +apiVersion: operators.coreos.com/v1 +kind: OperatorGroup +metadata: + name: dns-operator diff --git a/config/deploy/olm/subscription.yaml b/config/deploy/olm/subscription.yaml new file mode 100644 index 0000000..141ebab --- /dev/null +++ b/config/deploy/olm/subscription.yaml @@ -0,0 +1,9 @@ +apiVersion: operators.coreos.com/v1alpha1 +kind: Subscription +metadata: + name: dns-operator +spec: + source: dns-operator-catalog + sourceNamespace: dns-operator-system + name: dns-operator + channel: "alpha" diff --git a/docs/RELEASE.md b/docs/RELEASE.md new file mode 100644 index 0000000..362d1fa --- /dev/null +++ b/docs/RELEASE.md @@ -0,0 +1,96 @@ +## Release + +### New Major.Minor version + +1. Create a new minor release branch from the HEAD of main: +```sh +git checkout -b release-0.2 +``` +2. Run prepare release: +```sh +make prepare-release IMG_TAG=release-0.2 VERSION=0.2.0-dev CHANNELS=alpha REPLACES_VERSION=0.1.0 +``` +3. Verify local changes, commit and push: +```sh +git add . +git commit -m "prepare-release: release-0.2" +git push upstream release-0.2 +``` +4. Verify that the build [image workflow](https://github.com/Kuadrant/dns-operator/actions/workflows/build-images.yaml) is triggered and completes for the new branch + +5. Do any final testing and bug fixing against the release branch, see [Verify OLM Deployment](#verify-olm-deployment) + +6. Run prepare release for final version +```sh +make prepare-release VERSION=0.2.0 CHANNELS=stable REPLACES_VERSION=0.1.0 +``` +7. Verify local changes, commit, push and tag: +```sh +git add . +git commit -m "prepare-release: v0.2.0" +git tag v0.2.0 +git push upstream release-0.2 +git push upstream v0.2.0 +``` +8. Verify that the build [image workflow](https://github.com/Kuadrant/dns-operator/actions/workflows/build-images.yaml) is triggered and completes for the new tag + +9. Verify the new version can be installed from the catalog image, see [Verify OLM Deployment](#verify-olm-deployment) + +10. Release to the [community operator index catalogs](#community-operator-index-catalogs). + +### New Patch version + +1. Checkout minor release branch: +```sh +git checkout release-0.2 +``` +2. Run prepare release: +```sh +make prepare-release VERSION=0.2.1 CHANNELS=stable REPLACES_VERSION=0.2.0 +``` +3. Verify local changes, commit and push: +```sh +git add . +git commit -m "prepare-release: v0.2.1" +git tag v0.2.1 +git push upstream release-0.2 +git push upstream v0.2.1 +``` +4. Verify that the build [image workflow](https://github.com/Kuadrant/dns-operator/actions/workflows/build-images.yaml) is triggered and completes for the new tag + +5. Verify the new version can be installed from the catalog image, see [Verify OLM Deployment](#verify-olm-deployment) + +6. Release to the [community operator index catalogs](#community-operator-index-catalogs). + +### Verify OLM Deployment + +1. Deploy the OLM catalog image: +```sh +make local-setup install-olm deploy-catalog +``` + +2. Wait for deployment: +```sh +kubectl -n dns-operator-system wait --timeout=60s --for=condition=Available deployments --all +deployment.apps/dns-operator-controller-manager condition met +``` + +3. Check the logs: +```sh +kubectl -n dns-operator-system logs -f deployment/dns-operator-controller-manager +``` + +4. Check the version: +```sh +$ kubectl -n dns-operator-system get deployment dns-operator-controller-manager --show-labels +NAME READY UP-TO-DATE AVAILABLE AGE LABELS +dns-operator-controller-manager 1/1 1 1 5m42s app.kubernetes.io/component=manager,app.kubernetes.io/created-by=dns-operator, +app.kubernetes.io/instance=controller-manager,app.kubernetes.io/managed-by=kustomize,app.kubernetes.io/name=deployment,app.kubernetes.io/part-of=dns-operator, +control-plane=dns-operator-controller-manager,olm.deployment-spec-hash=1jPe8AuMpSKHh51nnDs4j25ZgoUrKhF45EP0Wa,olm.managed=true,olm.owner.kind=ClusterServiceVersion, +olm.owner.namespace=dns-operator-system,olm.owner=dns-operator.v0.2.0-dev,operators.coreos.com/dns-operator.dns-operator-system= +``` + +### Community Operator Index Catalogs + +- [Operatorhub Community Operators](https://github.com/k8s-operatorhub/community-operators/tree/main/operators/dns-operator) +- [Openshift Community Operators](https://github.com/redhat-openshift-ecosystem/community-operators-prod/tree/main/operators/dns-operator) \ No newline at end of file