diff --git a/.github/workflows/push_image.yml b/.github/workflows/push_image.yml index 853379737..117eb9efe 100644 --- a/.github/workflows/push_image.yml +++ b/.github/workflows/push_image.yml @@ -27,34 +27,20 @@ jobs: go-version: ${{ matrix.go }} - name: checkout uses: actions/checkout@v3 - - name: build images - run: IMG=${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ env.TAGS }} make ci-images-build - - name: podman login to quay.io - uses: redhat-actions/podman-login@v1 + - name: docker login to quay.io + uses: docker/login-action@v2 with: username: ${{ env.REGISTRY_USER }} password: ${{ env.REGISTRY_PASSWORD }} registry: quay.io - name: get short sha run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - - name: push to quay.io - id: push-to-quay - uses: redhat-actions/push-to-registry@v2 - with: - image: ${{ env.IMAGE }} - tags: ${{ env.TAGS }} ${{ env.short_sha }} - registry: ${{ env.REGISTRY }} + - name: build and push images + run: IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ env.TAGS }} make ci-images - name: print image url run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}" - - name: build bundle - run: VERSION=${{ env.TAGS }} PLG_VERSION=${{ env.TAGS }} FLP_VERSION=${{ env.TAGS }} BPF_VERSION=${{ env.TAGS }} BUNDLE_VERSION=${{ env.BUNDLE_VERSION }} make bundle bundle-build - - name: push bundle to quay.io - id: push-bundle - uses: redhat-actions/push-to-registry@v2 - with: - image: ${{ env.IMAGE }}-bundle - tags: v${{ env.BUNDLE_VERSION }} - registry: ${{ env.REGISTRY }} + - name: build and push bundle + run: VERSION=${{ env.TAGS }} PLG_VERSION=${{ env.TAGS }} FLP_VERSION=${{ env.TAGS }} BPF_VERSION=${{ env.TAGS }} BUNDLE_VERSION=${{ env.BUNDLE_VERSION }} make bundle-all - name: build catalog run: BUNDLE_VERSION=${{ env.BUNDLE_VERSION }} make catalog-build - name: push catalog to quay.io diff --git a/.github/workflows/push_image_pr.yml b/.github/workflows/push_image_pr.yml index 27ad8d828..e2f115d9e 100644 --- a/.github/workflows/push_image_pr.yml +++ b/.github/workflows/push_image_pr.yml @@ -27,23 +27,16 @@ jobs: uses: actions/checkout@v3 with: ref: "refs/pull/${{ github.event.number }}/merge" - - name: build images - run: IMG=${{ env.REGISTRY }}/${{ env.IMAGE }}:temp make ci-images-build - - name: podman login to quay.io - uses: redhat-actions/podman-login@v1 + - name: docker login to quay.io + uses: docker/login-action@v2 with: username: ${{ env.REGISTRY_USER }} password: ${{ secrets.QUAY_SECRET }} registry: quay.io - name: get short sha run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - - name: push to quay.io - id: push-to-quay - uses: redhat-actions/push-to-registry@v2 - with: - image: ${{ env.IMAGE }} - tags: ${{ env.short_sha }} - registry: ${{ env.REGISTRY }} + - name: build and push images + run: IMG=${{ env.REGISTRY }}/${{ env.IMAGE }}:temp make ci-images - name: build bundle run: VERSION=${{ env.short_sha }} PLG_VERSION=main FLP_VERSION=main BPF_VERSION=main BUNDLE_VERSION=0.0.0-${{ env.short_sha }} make bundle shortlived-bundle-build - name: push bundle to quay.io diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d46f208f4..171ff2bed 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,6 +19,12 @@ jobs: steps: - name: checkout uses: actions/checkout@v3 + - name: docker login to quay.io + uses: docker/login-action@v2 + with: + username: ${{ env.REGISTRY_USER }} + password: ${{ env.REGISTRY_PASSWORD }} + registry: quay.io - name: validate tag run: | tag=`git describe --exact-match --tags 2> /dev/null` @@ -36,39 +42,12 @@ jobs: uses: actions/setup-go@v3 with: go-version: ${{ matrix.go }} - - name: build operator - run: IMG=${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ env.tag }} make image-build - - name: podman login to quay.io - uses: redhat-actions/podman-login@v1 - with: - username: ${{ env.REGISTRY_USER }} - password: ${{ env.REGISTRY_PASSWORD }} - registry: quay.io - - name: push operator to quay.io - id: push-operator - uses: redhat-actions/push-to-registry@v2 - with: - image: ${{ env.IMAGE }} - tags: ${{ env.tag }} - registry: ${{ env.REGISTRY }} - - name: build bundle - run: BUNDLE_VERSION=${{ env.tag }} IMAGE_TAG_BASE=${{ env.REGISTRY }}/${{ env.IMAGE }} make bundle-build - - name: push bundle to quay.io - id: push-bundle - uses: redhat-actions/push-to-registry@v2 - with: - image: ${{ env.IMAGE }}-bundle - tags: v${{ env.tag }} - registry: ${{ env.REGISTRY }} - - name: build catalog - run: BUNDLE_VERSION=${{ env.tag }} IMAGE_TAG_BASE=${{ env.REGISTRY }}/${{ env.IMAGE }} make catalog-build - - name: push catalog to quay.io - id: push-catalog - uses: redhat-actions/push-to-registry@v2 - with: - image: ${{ env.IMAGE }}-catalog - tags: v${{ env.tag }} - registry: ${{ env.REGISTRY }} + - name: build and push operator + run: IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ env.tag }} make images + - name: build and push bundle + run: BUNDLE_VERSION=${{ env.tag }} IMAGE_TAG_BASE=${{ env.REGISTRY }}/${{ env.IMAGE }} make bundle bundle-all + - name: build and push catalog + run: BUNDLE_VERSION=${{ env.tag }} IMAGE_TAG_BASE=${{ env.REGISTRY }}/${{ env.IMAGE }} make catalog - name: print images reference run: | echo "Images: ${{ steps.push-operator.outputs.registry-paths }}, ${{ steps.push-bundle.outputs.registry-paths }}, ${{ steps.push-catalog.outputs.registry-paths }}" diff --git a/.mk/local.mk b/.mk/local.mk index 38d64e2f4..479f1278d 100644 --- a/.mk/local.mk +++ b/.mk/local.mk @@ -54,7 +54,7 @@ local-deploy-operator: .PHONY: deploy-kind deploy-kind: generate 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} $(SED) -i -r 's~ebpf-agent:.+~ebpf-agent:main~' ./config/manager/manager.yaml $(SED) -i -r 's~flowlogs-pipeline:.+~flowlogs-pipeline:main~' ./config/manager/manager.yaml $(SED) -i -r 's~console-plugin:.+~console-plugin:main~' ./config/manager/manager.yaml diff --git a/.mk/shortcuts.mk b/.mk/shortcuts.mk new file mode 100644 index 000000000..d7898ed62 --- /dev/null +++ b/.mk/shortcuts.mk @@ -0,0 +1,42 @@ +##@ shortcuts helpers +.PHONY: build-image +build-image: image-build ## Build MULTIARCH_TARGETS images + +.PHONY: push-image +push-image: image-push ## Push MULTIARCH_TARGETS images + +.PHONY: build-manifest +build-manifest: manifest-build ## Build MULTIARCH_TARGETS manifest + +.PHONY: push-manifest +push-manifest: manifest-push ## Push MULTIARCH_TARGETS manifest + +.PHONY: images +images: image-build image-push manifest-build manifest-push ## Build and push MULTIARCH_TARGETS images and related manifest + +.PHONY: build-ci-images +build-ci-images: ci-images-build ## Build CI images + +.PHONY: push-ci-images +push-ci-images: ci-images-push ## Push CI images + +.PHONY: ci-images +ci-images: ci-images-build ci-images-push ## Build and push CI images + +.PHONY: build-catalog +build-catalog: catalog-build ## Build a catalog image + +.PHONY: push-catalog +push-catalog: catalog-push ## Push a catalog image + +.PHONY: catalog +catalog: catalog-build catalog-push ## Build and push a catalog image + +.PHONY: build-bundle +build-bundle: bundle-build ## Build the bundle image + +.PHONY: push-bundle +push-bundle: bundle-push ## Push the bundle image + +.PHONY: bundle-all +bundle-all: bundle bundle-build bundle-push ## Build and push the bundle image \ No newline at end of file diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index af445d776..5fc42747b 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -10,10 +10,10 @@ make build test ## Build and deploy a Docker image -A way to test code changes is to build a Docker image from local sources, push it to your own Docker repository, and deploy it to an existing cluster. Do the following, but replace IMG value with your own registry and account: +A way to test code changes is to build a Docker image from local sources, push it to your own Docker repository, and deploy it to an existing cluster. Do the following, but replace IMAGE value with your own registry and account: ```bash -IMG="quay.io/youraccount/network-observability-operator:test" make image-build image-push deploy +IMAGE="quay.io/youraccount/network-observability-operator:test" make image-build image-push deploy ``` After the operator is deployed, set up Loki, which is used to store flows, install a `FlowCollector` custom resource to collect network flows, and optionally install Grafana to provide a user interface and dashboards. @@ -55,7 +55,7 @@ It is recommended to switch to the corresponding release Git tag before deployin When `VERSION` is not provided, it defaults to the latest build on `main` branch. -You can also provide any custom `IMG` to `make deploy`. +You can also provide any custom `IMAGE` to `make deploy`. ## Before commiting, make sure bundle is correct @@ -106,18 +106,18 @@ bundle for local testing, you should execute the following commands: ```bash export USER= -export IMG=quay.io/$USER/network-observability-operator:v0.0.1 -export BUNDLE_IMG=quay.io/$USER/network-observability-operator-bundle:v0.0.1 +export IMAGE=quay.io/$USER/network-observability-operator:v0.0.1 +export BUNDLE_IMAGE=quay.io/$USER/network-observability-operator-bundle:v0.0.1 make image-build image-push -make bundle bundle-build bundle-push +make bundle-push ``` Optionally, you might validate the bundle: ```bash -bin/operator-sdk bundle validate $BUNDLE_IMG +bin/operator-sdk bundle validate $BUNDLE_IMAGE # or for podman -bin/operator-sdk bundle validate -b podman $BUNDLE_IMG +bin/operator-sdk bundle validate -b podman $BUNDLE_IMAGE ``` > Note: the base64 logo can be generated with: `base64 -w 0 `, then manually pasted in the [CSV manifest file](./config/manifests/bases/netobserv-operator.clusterserviceversion.yaml) under `spec.icon`. @@ -127,7 +127,7 @@ bin/operator-sdk bundle validate -b podman $BUNDLE_IMG This mode is recommended to quickly test the operator during its development: ```bash -bin/operator-sdk run bundle $BUNDLE_IMG +bin/operator-sdk run bundle $BUNDLE_IMAGE ``` To cleanup: @@ -144,7 +144,7 @@ operators' catalog and installing/configuring it manually through the UI. First, create and push a catalog image: ```bash -export CATALOG_IMG=quay.io/$USER/network-observability-operator-catalog:v$VERSION +export CATALOG_IMAGE=quay.io/$USER/network-observability-operator-catalog:v$VERSION make catalog-build catalog-push catalog-deploy ``` diff --git a/Dockerfile b/Dockerfile index 810456506..49d2fc4fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,12 @@ +# We do not use --platform feature to auto fill this ARG because of incompatibility between podman and docker +ARG TARGETPLATFORM=linux/amd64 +ARG BUILDPLATFORM=linux/amd64 # Build the manager binary -FROM docker.io/library/golang:1.19 as builder +FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.19 as builder ARG BUILD_VERSION="unknown" +ARG TARGETPLATFORM +ARG TARGETARCH=amd64 WORKDIR /opt/app-root # Copy the go manifests and source @@ -14,10 +19,10 @@ COPY controllers/ controllers/ COPY pkg/ pkg/ # Build -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -ldflags "-X 'main.buildVersion=$BUILD_VERSION' -X 'main.buildDate=`date +%Y-%m-%d\ %H:%M`'" -mod vendor -a -o manager main.go +RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH GO111MODULE=on go build -ldflags "-X 'main.buildVersion=$BUILD_VERSION' -X 'main.buildDate=`date +%Y-%m-%d\ %H:%M`'" -mod vendor -a -o manager main.go # Create final image from minimal + built binary -FROM registry.access.redhat.com/ubi9/ubi-minimal:9.1 +FROM --platform=$TARGETPLATFORM registry.access.redhat.com/ubi9/ubi-minimal:9.1 WORKDIR / COPY --from=builder /opt/app-root/manager . USER 65532:65532 diff --git a/Makefile b/Makefile index 9bac7928e..f2e3324b1 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,21 @@ # VERSION defines the project version for the deploy scripts, not for bundles VERSION ?= main -BUILD_VERSION := $(shell git describe --long HEAD) BUILD_DATE := $(shell date +%Y-%m-%d\ %H:%M) +TAG_COMMIT := $(shell git rev-list --abbrev-commit --tags --max-count=1) +TAG := $(shell git describe --abbrev=0 --tags ${TAG_COMMIT} 2>/dev/null || true) BUILD_SHA := $(shell git rev-parse --short HEAD) +BUILD_VERSION := $(TAG:v%=%) +ifneq ($(COMMIT), $(TAG_COMMIT)) + BUILD_VERSION := $(BUILD_VERSION)-$(BUILD_SHA) +endif +ifneq ($(shell git status --porcelain),) + BUILD_VERSION := $(BUILD_VERSION)-dirty +endif + +# Go architecture and targets images to build +GOARCH ?= amd64 +MULTIARCH_TARGETS := amd64 arm64 ppc64le + # Default image repo REPO ?= quay.io/netobserv # Component versions to use in bundle / release (do not use $VERSION for that) @@ -49,17 +62,17 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) # IMAGE_TAG_BASE defines the namespace and part of the image name for remote images. # This variable is used to construct full image tags for bundle and catalog images. # -# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both +# For example, running 'make bundle-push catalog-push' will build and push both # netobserv/network-observability-operator-bundle:$BUNDLE_VERSION and netobserv/network-observability-operator-catalog:$BUNDLE_VERSION. IMAGE_TAG_BASE ?= $(REPO)/network-observability-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$(BUNDLE_VERSION) +# BUNDLE_IMAGE defines the image:tag used for the bundle. +# You can use it as an arg. (E.g make bundle-build BUNDLE_IMAGE=/:) +BUNDLE_IMAGE ?= $(IMAGE_TAG_BASE)-bundle:v$(BUNDLE_VERSION) # Image URL to use all building/pushing image targets -IMG ?= $(IMAGE_TAG_BASE):$(VERSION) -IMG_SHA = $(IMAGE_TAG_BASE):$(BUILD_SHA) +IMAGE ?= $(IMAGE_TAG_BASE):$(VERSION) +IMAGE_SHA = $(IMAGE_TAG_BASE):$(BUILD_SHA) # Produce CRDs that work back to Kubernetes 1.11 (no version conversion) CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false" # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. @@ -74,13 +87,8 @@ GOBIN=$(shell go env GOBIN) endif # Image building tool (docker / podman) -ifndef OCI_BIN -ifeq (,$(shell which podman 2>/dev/null)) -OCI_BIN=docker -else -OCI_BIN=podman -endif -endif +OCI_BIN_PATH = $(shell which podman || which docker) +OCI_BIN ?= $(shell v='$(OCI_BIN_PATH)'; echo "$${v##*/}") DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") @@ -96,6 +104,18 @@ all: help include .bingo/Variables.mk +# build a single arch target provided as argument +define build_target + echo 'building image for arch $(1)'; \ + DOCKER_BUILDKIT=1 $(OCI_BIN) buildx build --load --build-arg TARGETPLATFORM=linux/$(1) --build-arg TARGETARCH=$(1) --build-arg BUILDPLATFORM=linux/amd64 -t ${IMAGE}-$(1) -f Dockerfile .; +endef + +# push a single arch target image +define push_target + echo 'pushing image ${IMAGE}-$(1)'; \ + DOCKER_BUILDKIT=1 $(OCI_BIN) push ${IMAGE}-$(1); +endef + ##@ General # The help target prints out all targets with their descriptions organized @@ -248,27 +268,55 @@ lint: prereqs ## Run linter (golangci-lint). test: envtest ## Run tests. KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverpkg=./... -coverprofile cover.out -coverage-report: +coverage-report: ## Generate coverage report go tool cover --func=./cover.out -coverage-report-html: +coverage-report-html: ## Generate HTML coverage report go tool cover --html=./cover.out build: fmt lint ## Build manager binary. - go build -ldflags "-X 'main.buildVersion=${BUILD_VERSION}' -X 'main.buildDate=${BUILD_DATE}'" -mod vendor -o bin/manager main.go - -image-build: ## Build operator OCI image. - $(OCI_BIN) build --build-arg BUILD_VERSION="${BUILD_VERSION}" -t ${IMG} . + GOARCH=${GOARCH} go build -ldflags "-X 'main.buildVersion=${BUILD_VERSION}' -X 'main.buildDate=${BUILD_DATE}'" -mod vendor -o bin/manager main.go + +##@ Images + +# note: to build and push custom image tag use: IMAGE_ORG=myuser VERSION=dev make images +.PHONY: image-build +image-build: ## Build MULTIARCH_TARGETS images + trap 'exit' INT; \ + $(foreach target,$(MULTIARCH_TARGETS),$(call build_target,$(target))) \ + $(call build_manifest) + +.PHONY: image-push +image-push: ## Push MULTIARCH_TARGETS images + trap 'exit' INT; \ + $(foreach target,$(MULTIARCH_TARGETS),$(call push_target,$(target))) \ + $(call push_manifest) + +.PHONY: manifest-build +manifest-build: ## Build MULTIARCH_TARGETS manifest + @echo 'building manifest $(IMAGE)' + DOCKER_BUILDKIT=1 $(OCI_BIN) manifest create ${IMAGE} $(foreach target,$(MULTIARCH_TARGETS),--amend ${IMAGE}-$(target)); + +.PHONY: manifest-push +manifest-push: ## Push MULTIARCH_TARGETS manifest + @echo 'publish manifest $(IMAGE)' +ifeq (${OCI_BIN}, docker) + DOCKER_BUILDKIT=1 $(OCI_BIN) manifest push ${IMAGE}; +else + DOCKER_BUILDKIT=1 $(OCI_BIN) manifest push ${IMAGE} docker://${IMAGE}; +endif ci-images-build: image-build - $(OCI_BIN) build --build-arg BASE_IMAGE=$(IMG) -t $(IMG_SHA) -f ./shortlived.Dockerfile . + $(OCI_BIN) build --build-arg BASE_IMAGE=$(IMAGE) -t $(IMAGE_SHA) -f ./shortlived.Dockerfile . -image-push: ## Push OCI image with the manager. -ifneq (,$(findstring quay.io/netobserv/,$(IMG))) - $(error Do not push to quay.io/netobserv) -else - $(OCI_BIN) push ${IMG} -endif +.PHONY: ci-images-push +ci-images-push: + DOCKER_BUILDKIT=1 $(OCI_BIN) push $(IMAGE_SHA) + ifeq ($(VERSION), main) + # Also tag "latest" only for branch "main" + DOCKER_BUILDKIT=1 $(OCI_BIN) push ${IMAGE} + DOCKER_BUILDKIT=1 $(OCI_BIN) push $(IMAGE_TAG_BASE):latest + endif ##@ Deployment @@ -279,7 +327,7 @@ uninstall: kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube $(KUSTOMIZE) build config/crd | kubectl --ignore-not-found=true delete -f - || true 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} $(SED) -i -r 's~ebpf-agent:.+~ebpf-agent:main~' ./config/manager/manager.yaml $(SED) -i -r 's~flowlogs-pipeline:.+~flowlogs-pipeline:main~' ./config/manager/manager.yaml $(SED) -i -r 's~console-plugin:.+~console-plugin:main~' ./config/manager/manager.yaml @@ -296,7 +344,7 @@ run: fmt lint ## Run a controller from your host. .PHONY: bundle-prepare bundle-prepare: OPSDK generate kustomize ## Generate bundle manifests and metadata, then validate generated files. $(OPSDK) generate kustomize manifests -q - cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG) + cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMAGE) $(SED) -i -r 's~ebpf-agent:.+~ebpf-agent:$(BPF_VERSION)~' ./config/manager/manager.yaml $(SED) -i -r 's~flowlogs-pipeline:.+~flowlogs-pipeline:$(FLP_VERSION)~' ./config/manager/manager.yaml $(SED) -i -r 's~console-plugin:.+~console-plugin:$(PLG_VERSION)~' ./config/manager/manager.yaml @@ -309,7 +357,7 @@ bundle-prepare: OPSDK generate kustomize ## Generate bundle manifests and metada bundle: bundle-prepare ## Generate final bundle files. $(SED) -e 's/^/ /' config/manifests/bases/description-upstream.md > tmp-desc $(KUSTOMIZE) build config/manifests \ - | $(SED) -e 's~:container-image:~$(IMG)~' \ + | $(SED) -e 's~:container-image:~$(IMAGE)~' \ | $(SED) -e "/':full-description:'/r tmp-desc" \ | $(SED) -e "s/':full-description:'/|\-/" \ | $(OPSDK) generate bundle -q --overwrite --version $(BUNDLE_VERSION) $(BUNDLE_METADATA_OPTS) @@ -328,27 +376,27 @@ update-bundle: bundle ## Prepare a clean bundle to be commited bundle-build: ## Build the bundle image. cp ./bundle/manifests/netobserv-operator.clusterserviceversion.yaml tmp-bundle $(SED) -i -r 's~:created-at:~$(DATE)~' ./bundle/manifests/netobserv-operator.clusterserviceversion.yaml - -$(OCI_BIN) build -f bundle.Dockerfile -t $(BUNDLE_IMG) . + -$(OCI_BIN) build -f bundle.Dockerfile -t $(BUNDLE_IMAGE) . mv tmp-bundle ./bundle/manifests/netobserv-operator.clusterserviceversion.yaml shortlived-bundle-build: ## Build a temporary bundle image, expiring after 2 weeks on quay - $(MAKE) bundle-build BUNDLE_IMG=$(IMAGE_TAG_BASE)-bundle:tmp - $(OCI_BIN) build --build-arg BASE_IMAGE=$(IMAGE_TAG_BASE)-bundle:tmp -t $(BUNDLE_IMG) -f ./shortlived.Dockerfile . + $(MAKE) bundle-build BUNDLE_IMAGE=$(IMAGE_TAG_BASE)-bundle:tmp + $(OCI_BIN) build --build-arg BASE_IMAGE=$(IMAGE_TAG_BASE)-bundle:tmp -t $(BUNDLE_IMAGE) -f ./shortlived.Dockerfile . .PHONY: bundle-push bundle-push: ## Push the bundle image. - $(MAKE) image-push IMG=$(BUNDLE_IMG) + $(MAKE) image-push IMAGE=$(BUNDLE_IMAGE) -# 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). +# A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMAGES=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. -BUNDLE_IMGS ?= $(BUNDLE_IMG) +BUNDLE_IMAGES ?= $(BUNDLE_IMAGE) -# 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$(BUNDLE_VERSION) +# The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMAGE=example.com/operator-catalog:v0.2.0). +CATALOG_IMAGE ?= $(IMAGE_TAG_BASE)-catalog:v$(BUNDLE_VERSION) -# Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image. -ifneq ($(origin CATALOG_BASE_IMG), undefined) -FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG) +# Set CATALOG_BASE_IMAGE to an existing catalog image tag to add $BUNDLE_IMAGES to that image. +ifneq ($(origin CATALOG_BASE_IMAGE), undefined) +FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMAGE) endif # Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'. @@ -356,21 +404,21 @@ endif # https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator .PHONY: catalog-build catalog-build: opm ## Build a catalog image. - $(OPM) index add --container-tool ${OCI_BIN} --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT) + $(OPM) index add --container-tool ${OCI_BIN} --mode semver --tag $(CATALOG_IMAGE) --bundles $(BUNDLE_IMAGES) $(FROM_INDEX_OPT) shortlived-catalog-build: ## Build a temporary catalog image, expiring after 2 weeks on quay - $(MAKE) catalog-build CATALOG_IMG=$(IMAGE_TAG_BASE)-catalog:tmp - $(OCI_BIN) build --build-arg BASE_IMAGE=$(IMAGE_TAG_BASE)-catalog:tmp -t $(CATALOG_IMG) -f ./shortlived.Dockerfile . + $(MAKE) catalog-build CATALOG_IMAGE=$(IMAGE_TAG_BASE)-catalog:tmp + $(OCI_BIN) build --build-arg BASE_IMAGE=$(IMAGE_TAG_BASE)-catalog:tmp -t $(CATALOG_IMAGE) -f ./shortlived.Dockerfile . # Push the catalog image. .PHONY: catalog-push catalog-push: ## Push a catalog image. - $(MAKE) image-push IMG=$(CATALOG_IMG) + $(MAKE) image-push IMAGE=$(CATALOG_IMAGE) # Deploy the catalog. .PHONY: catalog-deploy catalog-deploy: ## Deploy a catalog image. - $(SED) -e 's~~$(CATALOG_IMG)~' ./config/samples/catalog/catalog.yaml | kubectl apply -f - + $(SED) -e 's~~$(CATALOG_IMAGE)~' ./config/samples/catalog/catalog.yaml | kubectl apply -f - # Undeploy the catalog. .PHONY: catalog-undeploy @@ -396,3 +444,4 @@ include .mk/sample.mk include .mk/development.mk include .mk/local.mk include .mk/ocp.mk +include .mk/shortcuts.mk diff --git a/bundle/manifests/netobserv-operator.clusterserviceversion.yaml b/bundle/manifests/netobserv-operator.clusterserviceversion.yaml index 59e8339b4..198349cf8 100644 --- a/bundle/manifests/netobserv-operator.clusterserviceversion.yaml +++ b/bundle/manifests/netobserv-operator.clusterserviceversion.yaml @@ -356,6 +356,11 @@ metadata: operators.operatorframework.io/builder: operator-sdk-v1.25.3 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 repository: https://github.com/netobserv/network-observability-operator + labels: + operatorframework.io/os.linux: supported + operatorframework.io/arch.amd64: supported + operatorframework.io/arch.arm64: supported + operatorframework.io/arch.ppc64le: supported name: netobserv-operator.v1.0.2 namespace: placeholder spec: diff --git a/config/samples/catalog/catalog.yaml b/config/samples/catalog/catalog.yaml index eb14fd5da..af0a917b5 100644 --- a/config/samples/catalog/catalog.yaml +++ b/config/samples/catalog/catalog.yaml @@ -5,7 +5,7 @@ metadata: namespace: openshift-marketplace spec: sourceType: grpc - image: + image: displayName: Network observability development catalog publisher: Me updateStrategy: