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.1.21
6+ VERSION ?= 0.1.22
77
88# CHANNELS define the bundle channels used in the bundle.
99# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
@@ -41,12 +41,25 @@ TAG ?= latest
4141# lunar.tech/cluster-routing-controller-bundle:$VERSION and lunar.tech/cluster-routing-controller-catalog:$VERSION.
4242IMAGE_TAG_BASE ?= ${REG}/${ORG}/${PROJECT}
4343
44+ # BUNDLE_IMG defines the image:tag used for the bundle.
45+ # You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
46+ BUNDLE_IMG ?= $(IMAGE_TAG_BASE ) -bundle:v$(VERSION )
47+
48+ # BUNDLE_GEN_FLAGS are the flags passed to the operator-sdk generate bundle command
49+ BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(VERSION ) $(BUNDLE_METADATA_OPTS )
50+
51+ # USE_IMAGE_DIGESTS defines if images are resolved via tags or digests
52+ # You can enable this value if you would like to use SHA Based Digests
53+ # To enable set flag to true
54+ USE_IMAGE_DIGESTS ?= false
55+ ifeq ($(USE_IMAGE_DIGESTS ) , true)
56+ BUNDLE_GEN_FLAGS += --use-image-digests
57+ endif
58+
4459IMG ?= ${IMAGE_TAG_BASE}:${TAG}
4560
46- # Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
47- CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
4861# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
49- ENVTEST_K8S_VERSION = 1.21
62+ ENVTEST_K8S_VERSION = 1.24.2
5063
5164# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
5265ifeq (,$(shell go env GOBIN) )
6174SHELL = /usr/bin/env bash -o pipefail
6275.SHELLFLAGS = -ec
6376
77+ .PHONY : all
6478all : build
6579
6680# #@ General
@@ -76,67 +90,102 @@ all: build
7690# More info on the awk command:
7791# http://linuxcommand.org/lc3_adv_awk.php
7892
93+ .PHONY : help
7994help : # # Display this help.
8095 @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 )
8196
8297# #@ Development
8398
99+ .PHONY : manifests
84100manifests : controller-gen # # Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
85- $(CONTROLLER_GEN ) $(CRD_OPTIONS ) rbac:roleName=manager-role webhook paths=" ./..." output:crd:artifacts:config=config/crd/bases
101+ $(CONTROLLER_GEN ) $(CRD_OPTIONS ) rbac:roleName=manager-role crd webhook paths=" ./..." output:crd:artifacts:config=config/crd/bases
86102
103+ .PHONY : generate
87104generate : controller-gen # # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
88105 $(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate.go.txt" paths=" ./..."
89106
107+ .PHONY : fmt
90108fmt : # # Run go fmt against code.
91109 go fmt ./...
92110
111+ .PHONY : vet
93112vet : # # Run go vet against code.
94113 go vet ./...
95114
115+ .PHONY : test
96116test : manifests generate fmt vet envtest # # Run tests.
97117 KUBEBUILDER_ASSETS=" $( shell $( ENVTEST) use $( ENVTEST_K8S_VERSION) -p path) " go test ./... -coverprofile cover.out
98118
99119# #@ Build
100-
120+ .PHONY : build
101121build : generate fmt vet # # Build manager binary.
102122 go build -o bin/manager main.go
103123
124+ .PHONY : run
104125run : manifests generate fmt vet # # Run a controller from your host.
105126 go run ./main.go
106127
128+ .PHONY : docker-build
107129docker-build : test # # Build docker image with the manager.
108130 docker build -t ${IMG} .
109131
132+ .PHONY : docker-push
110133docker-push : # # Push docker image with the manager.
111134 docker push ${IMG}
112135
113136# #@ Deployment
114137
138+ ifndef ignore-not-found
139+ ignore-not-found = false
140+ endif
141+
142+ .PHONY : install
115143install : manifests kustomize # # Install CRDs into the K8s cluster specified in ~/.kube/config.
116144 $(KUSTOMIZE ) build config/crd | kubectl apply -f -
117145
146+ .PHONY : uninstall
118147uninstall : manifests kustomize # # Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
119- $(KUSTOMIZE ) build config/crd | kubectl delete -f -
148+ $(KUSTOMIZE ) build config/crd | kubectl delete --ignore-not-found= $( ignore-not-found ) - f -
120149
150+ .PHONY : deploy
121151deploy : manifests kustomize # # Deploy controller to the K8s cluster specified in ~/.kube/config.
122152 cd config/manager && $(KUSTOMIZE ) edit set image controller=${IMG}
123153 $(KUSTOMIZE ) build config/default | kubectl apply -f -
124154
155+ .PHONY : undeploy
125156undeploy : # # Undeploy controller from the K8s cluster specified in ~/.kube/config.
126- $(KUSTOMIZE ) build config/default | kubectl delete -f -
157+ $(KUSTOMIZE ) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found ) -f -
158+
159+ # # Location to install dependencies to
160+ LOCALBIN ?= $(shell pwd) /bin
161+ $(LOCALBIN ) :
162+ mkdir -p $(LOCALBIN )
163+
164+ # # Tool Binaries
165+ KUSTOMIZE ?= $(LOCALBIN ) /kustomize
166+ CONTROLLER_GEN ?= $(LOCALBIN ) /controller-gen
167+ ENVTEST ?= $(LOCALBIN ) /setup-envtest
168+
169+ # # Tool Versions
170+ KUSTOMIZE_VERSION ?= v3.8.7
171+ CONTROLLER_TOOLS_VERSION ?= v0.9.2
127172
173+ KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
174+ .PHONY : kustomize
175+ kustomize : $(KUSTOMIZE ) # # Download kustomize locally if necessary.
176+ $(KUSTOMIZE ) : $(LOCALBIN )
177+ test -s $(LOCALBIN ) /kustomize || { curl -s $( KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $( subst v,,$( KUSTOMIZE_VERSION) ) $( LOCALBIN) ; }
128178
129- CONTROLLER_GEN = $(shell pwd) /bin/controller-gen
130- controller-gen : # # Download controller-gen locally if necessary.
131- $(call go-get-tool,$(CONTROLLER_GEN ) ,sigs.k8s.io/controller-tools/cmd/[email protected] ) 179+ .PHONY : controller-gen
180+ controller-gen : $(CONTROLLER_GEN ) # # Download controller-gen locally if necessary.
181+ $(CONTROLLER_GEN ) : $(LOCALBIN )
182+ test -s $(LOCALBIN ) /controller-gen || GOBIN=$(LOCALBIN ) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION )
132183
133- KUSTOMIZE = $(shell pwd) /bin/kustomize
134- kustomize : # # Download kustomize locally if necessary.
135- $(call go-get-tool,$(KUSTOMIZE ) ,sigs.k8s.io/kustomize/kustomize/[email protected] ) 184+ .PHONY : envtest
185+ envtest : $(ENVTEST ) # # Download envtest-setup locally if necessary.
186+ $(ENVTEST ) : $(LOCALBIN )
187+ test -s $(LOCALBIN ) /setup-envtest || GOBIN=$(LOCALBIN ) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
136188
137- ENVTEST = $(shell pwd) /bin/setup-envtest
138- envtest : # # Download envtest-setup locally if necessary.
139- $(call go-get-tool,$(ENVTEST ) ,sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)
140189
141190# go-get-tool will 'go get' any package $2 and install it to $1.
142191PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST ) ) ) )
@@ -156,7 +205,7 @@ endef
156205bundle : manifests kustomize # # Generate bundle manifests and metadata, then validate generated files.
157206 operator-sdk generate kustomize manifests -q
158207 cd config/manager && $(KUSTOMIZE ) edit set image controller=$(IMG )
159- $(KUSTOMIZE ) build config/manifests | operator-sdk generate bundle -q --overwrite --version $( VERSION ) $( BUNDLE_METADATA_OPTS )
208+ $(KUSTOMIZE ) build config/manifests | operator-sdk generate bundle $( BUNDLE_GEN_FLAGS )
160209 operator-sdk bundle validate ./bundle
161210
162211.PHONY : bundle-build
@@ -176,7 +225,7 @@ ifeq (,$(shell which opm 2>/dev/null))
176225 set -e ;\
177226 mkdir -p $(dir $(OPM)) ;\
178227 OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
179- curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.15.1 /$${OS}-$${ARCH}-opm ;\
228+ curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.23.0 /$${OS}-$${ARCH}-opm ;\
180229 chmod +x $(OPM) ;\
181230 }
182231else
0 commit comments