11
22# Image URL to use all building/pushing image targets
33IMG ?= controller:latest
4- # Namespace used for this example
5- NAMESPACE =memcached-operator-system
64# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
75CRD_OPTIONS ?= "crd:trivialVersions=true"
86
@@ -28,24 +26,23 @@ run: generate fmt vet manifests
2826 go run ./main.go
2927
3028# Install CRDs into a cluster
31- install : manifests
32- kustomize build config/crd | kubectl apply -f -
29+ install : manifests kustomize
30+ $( KUSTOMIZE ) build config/crd | kubectl apply -f -
3331
3432# Uninstall CRDs from a cluster
35- uninstall : manifests
36- @echo ....... Uninstalling .......
37- kustomize build config/crd | kubectl delete -f -
38- - kubectl delete deployments,service -l control-plane=controller-manager -n ${NAMESPACE}
39- - kubectl delete role,rolebinding --all -n ${NAMESPACE}
40- @echo ....... Deleting namespace ${NAMESPACE} .......
41- - kubectl delete namespace ${NAMESPACE}
33+ uninstall : manifests kustomize
34+ $(KUSTOMIZE ) build config/crd | kubectl delete -f -
4235
4336# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
44- deploy : manifests
37+ deploy : manifests kustomize
4538 cd config/manager && kustomize edit set image controller=${IMG}
46- kustomize build config/default | kubectl apply -f -
47- - kubectl create -f config/samples/cache_v1alpha1_memcached.yaml -n ${NAMESPACE}
39+ $(KUSTOMIZE ) build config/default | kubectl apply -f -
4840
41+ # UnDeploy controller from the configured Kubernetes cluster in ~/.kube/config
42+ # Note that it was added for we are allowed to uninstall the files. However, it will be present by default in the future
43+ # versions.
44+ undeploy :
45+ $(KUSTOMIZE ) build config/default | kubectl delete -f -
4946
5047# Generate manifests e.g. CRD, RBAC etc.
5148manifests : controller-gen
@@ -80,10 +77,25 @@ ifeq (, $(shell which controller-gen))
8077 CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
8178 cd $$CONTROLLER_GEN_TMP_DIR ;\
8279 go mod init tmp ;\
83- go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.5 ;\
80+ go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.3.0 ;\
8481 rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
8582 }
8683CONTROLLER_GEN =$(GOBIN ) /controller-gen
8784else
8885CONTROLLER_GEN =$(shell which controller-gen)
8986endif
87+
88+ kustomize :
89+ ifeq (, $(shell which kustomize) )
90+ @{ \
91+ set -e ;\
92+ KUSTOMIZE_GEN_TMP_DIR=$$(mktemp -d) ;\
93+ cd $$KUSTOMIZE_GEN_TMP_DIR ;\
94+ go mod init tmp ;\
95+ go get sigs.k8s.io/kustomize/kustomize/v3@v3.5.4 ;\
96+ rm -rf $$KUSTOMIZE_GEN_TMP_DIR ;\
97+ }
98+ KUSTOMIZE =$(GOBIN ) /kustomize
99+ else
100+ KUSTOMIZE =$(shell which kustomize)
101+ endif
0 commit comments