@@ -59,7 +59,9 @@ CONTROLLER_GEN := $(abspath $(TOOLS_BIN_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_
5959CONTROLLER_GEN_PKG := sigs.k8s.io/controller-tools/cmd/controller-gen
6060
6161# Image URL to use all building/pushing image targets
62- IMG ?= controller:latest
62+ IMG_PREFIX ?= controller
63+ IMG_TAG ?= latest
64+
6365
6466# Default value for ignore-not-found flag in undeploy target
6567ignore-not-found ?= true
@@ -170,17 +172,17 @@ run: manifests generate fmt vet ## Run a controller from your host.
170172# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
171173.PHONY : docker-build
172174docker-build : # # Build docker image with the manager.
173- $(CONTAINER_TOOL ) build -t ${IMG } .
175+ $(CONTAINER_TOOL ) build -t ${IMG_PREFIX} : ${IMG_TAG } .
174176
175177.PHONY : docker-push
176178docker-push : # # Push docker image with the manager.
177- $(CONTAINER_TOOL ) push ${IMG }
179+ $(CONTAINER_TOOL ) push ${IMG_PREFIX} : ${IMG_TAG }
178180
179181# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
180- # architectures. (i.e. make docker-buildx IMG =myregistry/mypoperator: 0.0.1). To use this option you need to:
182+ # architectures. (i.e. make docker-buildx IMG_PREFIX =myregistry/mypoperator IMG_TAG= 0.0.1). To use this option you need to:
181183# - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/
182184# - have enabled BuildKit. More info: https://docs.docker.com/develop/develop-images/build_enhancements/
183- # - be able to push the image to your registry (i.e. if you do not set a valid value via IMG=<myregistry/image:<tag>> then the export will fail)
185+ # - be able to push the image to your registry (i.e. if you do not set a valid value via ${IMG_PREFIX}:${IMG_TAG} then the export will fail)
184186# To adequately provide solutions that are compatible with multiple platforms, you should consider using this option.
185187PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
186188.PHONY : docker-buildx
@@ -189,14 +191,14 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
189191 sed -e ' 1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
190192 - $(CONTAINER_TOOL ) buildx create --name nrrcontroller-builder
191193 $(CONTAINER_TOOL ) buildx use nrrcontroller-builder
192- - $(CONTAINER_TOOL ) buildx build --push --platform=$(PLATFORMS ) --tag ${IMG } -f Dockerfile.cross .
194+ - $(CONTAINER_TOOL ) buildx build --push --platform=$(PLATFORMS ) --tag ${IMG_PREFIX} : ${IMG_TAG } -f Dockerfile.cross .
193195 - $(CONTAINER_TOOL ) buildx rm nrrcontroller-builder
194196 rm Dockerfile.cross
195197
196198.PHONY : build-installer
197199build-installer : manifests generate $(KUSTOMIZE ) # # Generate a consolidated YAML with CRDs and deployment.
198200 mkdir -p dist
199- cd config/manager && $(KUSTOMIZE ) edit set image controller=${IMG }
201+ cd config/manager && $(KUSTOMIZE ) edit set image controller=${IMG_PREFIX} : ${IMG_TAG }
200202 $(KUSTOMIZE ) build config/default > dist/install.yaml
201203
202204# # --------------------------------------
@@ -221,7 +223,7 @@ uninstall: manifests $(KUSTOMIZE) ## Uninstall CRDs from the K8s cluster specifi
221223
222224.PHONY : deploy
223225deploy : manifests $(KUSTOMIZE ) # # Deploy controller to the K8s cluster specified in ~/.kube/config.
224- cd config/manager && $(KUSTOMIZE ) edit set image controller=${IMG }
226+ cd config/manager && $(KUSTOMIZE ) edit set image controller=${IMG_PREFIX} : ${IMG_TAG }
225227 $(KUSTOMIZE ) build config/default | $(KUBECTL ) apply -f -
226228
227229.PHONY : undeploy
0 commit comments