@@ -4,27 +4,34 @@ IMG ?= quay.io/joelanford/nginx-operator
4
4
5
5
all : docker-build
6
6
7
+ # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
8
+ ifeq (,$(shell go env GOBIN) )
9
+ GOBIN =$(shell go env GOPATH) /bin
10
+ else
11
+ GOBIN =$(shell go env GOBIN)
12
+ endif
13
+
7
14
# Run against the configured Kubernetes cluster in ~/.kube/config
8
15
run :
9
16
go run ../main.go
10
17
11
18
# Install CRDs into a cluster
12
- install :
13
- kustomize build config/crd | kubectl apply -f -
19
+ install : kustomize
20
+ $( KUSTOMIZE ) build config/crd | kubectl apply -f -
14
21
15
22
# Uninstall CRDs from a cluster
16
- uninstall :
17
- kustomize build config/crd | kubectl delete -f -
23
+ uninstall : kustomize
24
+ $( KUSTOMIZE ) build config/crd | kubectl delete -f -
18
25
19
26
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
20
- deploy :
21
- cd config/manager && kustomize edit set image controller=${IMG}
22
- kustomize build config/default | kubectl apply -f -
27
+ deploy : kustomize
28
+ cd config/manager && $( KUSTOMIZE ) edit set image controller=${IMG}
29
+ $( KUSTOMIZE ) build config/default | kubectl apply -f -
23
30
24
31
# Undeploy controller in the configured Kubernetes cluster in ~/.kube/config
25
- undeploy :
26
- cd config/manager && kustomize edit set image controller=${IMG}
27
- kustomize build config/default | kubectl delete -f -
32
+ undeploy : kustomize
33
+ cd config/manager && $( KUSTOMIZE ) edit set image controller=${IMG}
34
+ $( KUSTOMIZE ) build config/default | kubectl delete -f -
28
35
29
36
# Build the docker image
30
37
docker-build :
@@ -33,3 +40,18 @@ docker-build:
33
40
# Push the docker image
34
41
docker-push :
35
42
docker push ${IMG}
43
+
44
+ kustomize :
45
+ ifeq (, $(shell which kustomize) )
46
+ @{ \
47
+ set -e ;\
48
+ KUSTOMIZE_GEN_TMP_DIR=$$(mktemp -d) ;\
49
+ cd $$KUSTOMIZE_GEN_TMP_DIR ;\
50
+ go mod init tmp ;\
51
+ go get sigs.k8s.io/kustomize/kustomize/
[email protected] ;\
52
+ rm -rf $$KUSTOMIZE_GEN_TMP_DIR ;\
53
+ }
54
+ KUSTOMIZE =$(GOBIN ) /kustomize
55
+ else
56
+ KUSTOMIZE =$(shell which kustomize)
57
+ endif
0 commit comments