From 81e7506b3c86fb7b6a374a28649e27df6ba5a9fb Mon Sep 17 00:00:00 2001 From: Gennady Azarenkov Date: Fri, 19 Jan 2024 16:41:38 +0200 Subject: [PATCH] Clean opm output and fix developer.md (#154) * clean opm output, fix developer.md * fix pr.yaml * Update docs/developer.md Co-authored-by: Armel Soro * quickfix pr.yaml * Update Makefile Co-authored-by: Nick Boldt * Update docs/developer.md Co-authored-by: Nick Boldt * Update Makefile --------- Co-authored-by: Armel Soro Co-authored-by: Nick Boldt --- .github/workflows/pr.yaml | 4 ++-- .gitignore | 2 +- Makefile | 27 ++++++++++++++++----------- docs/developer.md | 9 +++++++-- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 05bb6762..1f812893 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -29,7 +29,7 @@ jobs: strategy: matrix: - # See ../Makefile for value of single arch PLATFORM used with target operator-build + # See ../Makefile for value of single arch PLATFORM used with target image-build # NOTE: to build multiple arches, see ../Makefile and use target docker-buildx with PLATFORMS # only run this with docker since we have podman builds in pr-container-build.yaml # TODO: do we really even need this check? @@ -42,4 +42,4 @@ jobs: go-version-file: 'go.mod' - name: ${{ matrix.engine }} build run: | - CONTAINER_ENGINE=${{ matrix.engine }} make operator-build + CONTAINER_ENGINE=${{ matrix.engine }} make image-build diff --git a/.gitignore b/.gitignore index 405c8064..5430c94e 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,4 @@ __debug_bin* .scripts/ .DS_Store database/ -index.Dockerfile +docker/index.Dockerfile diff --git a/Makefile b/Makefile index 35076ebd..b135fa01 100644 --- a/Makefile +++ b/Makefile @@ -142,12 +142,12 @@ PLATFORM ?= linux/amd64 # (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. # More info: https://docs.docker.com/develop/develop-images/build_enhancements/ -.PHONY: operator-build -operator-build: test ## Build docker image with the manager using docker. +.PHONY: image-build +image-build: test ## Build docker image with the manager using docker. $(CONTAINER_ENGINE) build --platform $(PLATFORM) -f docker/Dockerfile -t $(IMG) --label $(LABEL) . -.PHONY: operator-push -operator-push: ## Push IMG image to registry +.PHONY: image-push +image-push: ## Push IMG image to registry $(CONTAINER_ENGINE) push $(IMG) # PLATFORMS defines the target platforms for the manager image be build to provide support to multiple @@ -296,7 +296,7 @@ bundle-build: ## Build the bundle image. .PHONY: bundle-push bundle-push: ## Push bundle image to registry - $(MAKE) operator-push IMG=$(BUNDLE_IMG) + $(MAKE) image-push IMG=$(BUNDLE_IMG) # A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0). # These images MUST exist in a registry and be pull-able. @@ -315,18 +315,19 @@ endif # https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator .PHONY: catalog-build catalog-build: bundle-push opm ## Generate operator-catalog dockerfile using the operator-bundle image built and published above; then build catalog image - $(OPM) index add --container-tool $(CONTAINER_ENGINE) --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT) --generate - $(CONTAINER_ENGINE) build --platform $(PLATFORM) -f index.Dockerfile -t $(CATALOG_IMG) --label $(LABEL) . + ## [GA] added '-d docker/index.Dockerfile' to avoid generating in the root + $(OPM) index add --container-tool $(CONTAINER_ENGINE) --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT) --generate -d docker/index.Dockerfile + $(CONTAINER_ENGINE) build --platform $(PLATFORM) -f docker/index.Dockerfile -t $(CATALOG_IMG) --label $(LABEL) . .PHONY: catalog-push catalog-push: ## Push catalog image to registry - $(MAKE) operator-push IMG=$(CATALOG_IMG) + $(MAKE) image-push IMG=$(CATALOG_IMG) .PHONY: -release-build: bundle operator-build bundle-build catalog-build ## Build operator, bundle + catalog images +release-build: bundle image-build bundle-build catalog-build ## Build operator, bundle + catalog images .PHONY: -release-push: operator-push bundle-push catalog-push ## Push operator, bundle + catalog images +release-push: image-push bundle-push catalog-push ## Push operator, bundle + catalog images .PHONY: deploy-olm deploy-olm: ## Deploy the operator with OLM @@ -342,5 +343,9 @@ undeploy-olm: ## Un-deploy the operator with OLM DEFAULT_OLM_NAMESPACE ?= openshift-marketplace .PHONY: catalog-update catalog-update: ## Update catalog source in the default namespace for catalogsource - -kubectl delete catalogsource backstage-operator -n $(DEFAULT_OLM_NAMESPACE) + kubectl delete catalogsource backstage-operator -n $(DEFAULT_OLM_NAMESPACE) sed "s/{{CATALOG_IMG}}/$(subst /,\/,$(CATALOG_IMG))/g" config/samples/catalog-source-template.yaml | kubectl apply -n $(DEFAULT_OLM_NAMESPACE) -f - + +.PHONY: deploy-openshift +deploy-openshift: release-build release-push catalog-update ## Deploy the operator on openshift cluster + diff --git a/docs/developer.md b/docs/developer.md index c526f121..b1ec2db6 100644 --- a/docs/developer.md +++ b/docs/developer.md @@ -38,7 +38,7 @@ You can use [minikube](https://kubernetes.io/docs/tasks/tools/#minikube) or [kin - Build and push your image to the location specified by `IMG`: ```sh -make docker-build docker-push IMG=/backstage-operator:tag +make image-build image-push IMG=/backstage-operator:tag ``` - Install the CRDs into the local cluster (minikube is installed and running): @@ -84,11 +84,16 @@ make catalog-update ```sh make deploy-olm ``` -4. To undeloy the operator with OLM +5. To undeploy the operator with OLM ```sh make undeploy-olm ``` +6. To deploy the operator to Openshift with OLM +```sh +make deploy-openshift [IMAGE_TAG_BASE=/backstage-operator] +``` + ### Modifying the API definitions If you are editing the API definitions, generate the manifests such as CRs or CRDs using: ```sh