33# To re-generate a bundle for another specific version without changing the standard setup, you can:
44# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
55# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
6- VERSION ?= 0.0.6
6+ VERSION ?= 0.0.1
77
88# CHANNELS define the bundle channels used in the bundle.
9- # Add a new line here if you would like to change its default config. (E.g CHANNELS = "preview ,fast,stable")
9+ # Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate ,fast,stable")
1010# To re-generate a bundle for other specific channels without changing the standard setup, you can:
11- # - use the CHANNELS as arg of the bundle target (e.g make bundle CHANNELS=preview ,fast,stable)
12- # - use environment variables to overwrite this value (e.g export CHANNELS="preview ,fast,stable")
11+ # - use the CHANNELS as arg of the bundle target (e.g make bundle CHANNELS=candidate ,fast,stable)
12+ # - use environment variables to overwrite this value (e.g export CHANNELS="candidate ,fast,stable")
1313ifneq ($(origin CHANNELS ) , undefined)
1414BUNDLE_CHANNELS := --channels=$(CHANNELS )
1515endif
@@ -35,9 +35,25 @@ IMAGE_TAG_BASE ?= kubealex.com/k8s-mediaserver-operator
3535# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
3636BUNDLE_IMG ?= $(IMAGE_TAG_BASE ) -bundle:v$(VERSION )
3737
38+ # BUNDLE_GEN_FLAGS are the flags passed to the operator-sdk generate bundle command
39+ BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(VERSION ) $(BUNDLE_METADATA_OPTS )
40+
41+ # USE_IMAGE_DIGESTS defines if images are resolved via tags or digests
42+ # You can enable this value if you would like to use SHA Based Digests
43+ # To enable set flag to true
44+ USE_IMAGE_DIGESTS ?= false
45+ ifeq ($(USE_IMAGE_DIGESTS ) , true)
46+ BUNDLE_GEN_FLAGS += --use-image-digests
47+ endif
48+
49+ # Set the Operator SDK version to use. By default, what is installed on the system is used.
50+ # This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit.
51+ OPERATOR_SDK_VERSION ?= v1.32.0
52+
3853# Image URL to use all building/pushing image targets
3954IMG ?= controller:latest
4055
56+ .PHONY : all
4157all : docker-build
4258
4359# #@ General
@@ -53,37 +69,62 @@ all: docker-build
5369# More info on the awk command:
5470# http://linuxcommand.org/lc3_adv_awk.php
5571
72+ .PHONY : help
5673help : # # Display this help.
5774 @awk ' BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
5875
5976# #@ Build
6077
78+ .PHONY : run
6179run : helm-operator # # Run against the configured Kubernetes cluster in ~/.kube/config
6280 $(HELM_OPERATOR ) run
6381
82+ .PHONY : docker-build
6483docker-build : # # Build docker image with the manager.
6584 docker build -t ${IMG} .
6685
86+ .PHONY : docker-push
6787docker-push : # # Push docker image with the manager.
6888 docker push ${IMG}
6989
90+ # PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
91+ # architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
92+ # - able to use docker buildx . More info: https://docs.docker.com/build/buildx/
93+ # - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
94+ # - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=<myregistry/image:<tag>> than the export will fail)
95+ # To properly provided solutions that supports more than one platform you should use this option.
96+ PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
97+ .PHONY : docker-buildx
98+ docker-buildx : test # # Build and push docker image for the manager for cross-platform support
99+ # copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
100+ sed -e ' 1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
101+ - docker buildx create --name project-v3-builder
102+ docker buildx use project-v3-builder
103+ - docker buildx build --push --platform=$(PLATFORMS ) --tag ${IMG} -f Dockerfile.cross .
104+ - docker buildx rm project-v3-builder
105+ rm Dockerfile.cross
106+
70107# #@ Deployment
71108
109+ .PHONY : install
72110install : kustomize # # Install CRDs into the K8s cluster specified in ~/.kube/config.
73111 $(KUSTOMIZE ) build config/crd | kubectl apply -f -
74112
113+ .PHONY : uninstall
75114uninstall : kustomize # # Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
76115 $(KUSTOMIZE ) build config/crd | kubectl delete -f -
77116
117+ .PHONY : deploy
78118deploy : kustomize # # Deploy controller to the K8s cluster specified in ~/.kube/config.
79119 cd config/manager && $(KUSTOMIZE ) edit set image controller=${IMG}
80120 $(KUSTOMIZE ) build config/default | kubectl apply -f -
81121
122+ .PHONY : undeploy
82123undeploy : # # Undeploy controller from the K8s cluster specified in ~/.kube/config.
83124 $(KUSTOMIZE ) build config/default | kubectl delete -f -
84125
85126OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
86- ARCH := $(shell uname -m | sed 's/x86_64/amd64/')
127+ ARCH := $(shell uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/' )
87128
88129.PHONY : kustomize
89130KUSTOMIZE = $(shell pwd) /bin/kustomize
@@ -93,7 +134,7 @@ ifeq (,$(shell which kustomize 2>/dev/null))
93134 @{ \
94135 set -e ;\
95136 mkdir -p $(dir $(KUSTOMIZE)) ;\
96- curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v3 .5.4/kustomize_v3 .5.4_ $(OS)_$(ARCH).tar.gz | \
137+ curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4 .5.7/kustomize_v4 .5.7_ $(OS)_$(ARCH).tar.gz | \
97138 tar xzf - -C bin/ ;\
98139 }
99140else
@@ -109,20 +150,36 @@ ifeq (,$(shell which helm-operator 2>/dev/null))
109150 @{ \
110151 set -e ;\
111152 mkdir -p $(dir $(HELM_OPERATOR)) ;\
112- curl -sSLo $(HELM_OPERATOR) https://github.com/operator-framework/operator-sdk/releases/download/v1.8 .0/helm-operator_$(OS)_$(ARCH) ;\
153+ curl -sSLo $(HELM_OPERATOR) https://github.com/operator-framework/operator-sdk/releases/download/v1.32 .0/helm-operator_$(OS)_$(ARCH) ;\
113154 chmod +x $(HELM_OPERATOR) ;\
114155 }
115156else
116157HELM_OPERATOR = $(shell which helm-operator)
117158endif
118159endif
119160
161+ .PHONY : operator-sdk
162+ OPERATOR_SDK ?= ./bin/operator-sdk
163+ operator-sdk : # # Download operator-sdk locally if necessary.
164+ ifeq (,$(wildcard $(OPERATOR_SDK ) ) )
165+ ifeq (, $(shell which operator-sdk 2>/dev/null) )
166+ @{ \
167+ set -e ;\
168+ mkdir -p $(dir $(OPERATOR_SDK)) ;\
169+ curl -sSLo $(OPERATOR_SDK) https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk_$(OS)_$(ARCH) ;\
170+ chmod +x $(OPERATOR_SDK) ;\
171+ }
172+ else
173+ OPERATOR_SDK = $(shell which operator-sdk)
174+ endif
175+ endif
176+
120177.PHONY : bundle
121- bundle : kustomize # # Generate bundle manifests and metadata, then validate generated files.
122- operator-sdk generate kustomize manifests -q
178+ bundle : kustomize operator-sdk # # Generate bundle manifests and metadata, then validate generated files.
179+ $( OPERATOR_SDK ) generate kustomize manifests -q
123180 cd config/manager && $(KUSTOMIZE ) edit set image controller=$(IMG )
124- $(KUSTOMIZE ) build config/manifests | operator-sdk generate bundle -q --overwrite --version $( VERSION ) $( BUNDLE_METADATA_OPTS )
125- operator-sdk bundle validate ./bundle
181+ $(KUSTOMIZE ) build config/manifests | $( OPERATOR_SDK ) generate bundle $( BUNDLE_GEN_FLAGS )
182+ $( OPERATOR_SDK ) bundle validate ./bundle
126183
127184.PHONY : bundle-build
128185bundle-build : # # Build the bundle image.
@@ -140,7 +197,7 @@ ifeq (,$(shell which opm 2>/dev/null))
140197 @{ \
141198 set -e ;\
142199 mkdir -p $(dir $(OPM)) ;\
143- curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.15.1 /$(OS)-$(ARCH)-opm ;\
200+ curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.23.0 /$(OS)-$(ARCH)-opm ;\
144201 chmod +x $(OPM) ;\
145202 }
146203else
0 commit comments