2
2
# Image URL to use all building/pushing image targets
3
3
IMG ?= controller:latest
4
4
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
5
- ENVTEST_K8S_VERSION = 1.26.0
5
+ ENVTEST_K8S_VERSION = 1.27.1
6
6
7
7
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
8
8
ifeq (,$(shell go env GOBIN) )
11
11
GOBIN =$(shell go env GOBIN)
12
12
endif
13
13
14
+ # CONTAINER_TOOL defines the container tool to be used for building images.
15
+ # Be aware that the target commands are only tested with Docker which is
16
+ # scaffolded by default. However, you might want to replace it to use other
17
+ # tools. (i.e. podman)
18
+ CONTAINER_TOOL ?= docker
19
+
14
20
# Setting SHELL to bash allows bash commands to be executed by recipes.
15
21
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
16
22
SHELL = /usr/bin/env bash -o pipefail
@@ -44,7 +50,7 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
44
50
45
51
.PHONY : generate
46
52
generate : controller-gen # # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
47
- $(CONTROLLER_GEN ) object:headerFile= " hack/boilerplate.go.txt " paths=" ./..."
53
+ $(CONTROLLER_GEN ) object paths=" ./..."
48
54
49
55
.PHONY : fmt
50
56
fmt : # # Run go fmt against code.
@@ -62,22 +68,22 @@ test: manifests generate fmt vet envtest ## Run tests.
62
68
63
69
.PHONY : build
64
70
build : manifests generate fmt vet # # Build manager binary.
65
- go build -o bin/manager main.go
71
+ go build -o bin/manager cmd/ main.go
66
72
67
73
.PHONY : run
68
74
run : manifests generate fmt vet # # Run a controller from your host.
69
- go run ./main.go
75
+ go run ./cmd/ main.go
70
76
71
77
# If you wish built the manager image targeting other platforms you can use the --platform flag.
72
78
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
73
79
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
74
80
.PHONY : docker-build
75
81
docker-build : test # # Build docker image with the manager.
76
- docker build -t ${IMG} .
82
+ $( CONTAINER_TOOL ) build -t ${IMG} .
77
83
78
84
.PHONY : docker-push
79
85
docker-push : # # Push docker image with the manager.
80
- docker push ${IMG}
86
+ $( CONTAINER_TOOL ) push ${IMG}
81
87
82
88
# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
83
89
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
@@ -90,10 +96,10 @@ PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
90
96
docker-buildx : test # # Build and push docker image for the manager for cross-platform support
91
97
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
92
98
sed -e ' 1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
93
- - docker buildx create --name project-v3-builder
94
- docker buildx use project-v3-builder
95
- - docker buildx build --push --platform=$(PLATFORMS ) --tag ${IMG} -f Dockerfile.cross .
96
- - docker buildx rm project-v3-builder
99
+ - $( CONTAINER_TOOL ) buildx create --name project-v3-builder
100
+ $( CONTAINER_TOOL ) buildx use project-v3-builder
101
+ - $( CONTAINER_TOOL ) buildx build --push --platform=$(PLATFORMS ) --tag ${IMG} -f Dockerfile.cross .
102
+ - $( CONTAINER_TOOL ) buildx rm project-v3-builder
97
103
rm Dockerfile.cross
98
104
99
105
# #@ Deployment
@@ -104,20 +110,20 @@ endif
104
110
105
111
.PHONY : install
106
112
install : manifests kustomize # # Install CRDs into the K8s cluster specified in ~/.kube/config.
107
- $(KUSTOMIZE ) build config/crd | kubectl apply -f -
113
+ $(KUSTOMIZE ) build config/crd | $( KUBECTL ) apply -f -
108
114
109
115
.PHONY : uninstall
110
116
uninstall : manifests kustomize # # Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
111
- $(KUSTOMIZE ) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found ) -f -
117
+ $(KUSTOMIZE ) build config/crd | $( KUBECTL ) delete --ignore-not-found=$(ignore-not-found ) -f -
112
118
113
119
.PHONY : deploy
114
120
deploy : manifests kustomize # # Deploy controller to the K8s cluster specified in ~/.kube/config.
115
121
cd config/manager && $(KUSTOMIZE ) edit set image controller=${IMG}
116
- $(KUSTOMIZE ) build config/default | kubectl apply -f -
122
+ $(KUSTOMIZE ) build config/default | $( KUBECTL ) apply -f -
117
123
118
124
.PHONY : undeploy
119
125
undeploy : # # Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
120
- $(KUSTOMIZE ) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found ) -f -
126
+ $(KUSTOMIZE ) build config/default | $( KUBECTL ) delete --ignore-not-found=$(ignore-not-found ) -f -
121
127
122
128
# #@ Build Dependencies
123
129
@@ -127,23 +133,23 @@ $(LOCALBIN):
127
133
mkdir -p $(LOCALBIN )
128
134
129
135
# # Tool Binaries
136
+ KUBECTL ?= kubectl
130
137
KUSTOMIZE ?= $(LOCALBIN ) /kustomize
131
138
CONTROLLER_GEN ?= $(LOCALBIN ) /controller-gen
132
139
ENVTEST ?= $(LOCALBIN ) /setup-envtest
133
140
134
141
# # Tool Versions
135
- KUSTOMIZE_VERSION ?= v3.8.7
136
- CONTROLLER_TOOLS_VERSION ?= v0.11.1
142
+ KUSTOMIZE_VERSION ?= v5.0.1
143
+ CONTROLLER_TOOLS_VERSION ?= v0.12.0
137
144
138
- KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
139
145
.PHONY : kustomize
140
146
kustomize : $(KUSTOMIZE ) # # Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading.
141
147
$(KUSTOMIZE ) : $(LOCALBIN )
142
148
@if test -x $(LOCALBIN ) /kustomize && ! $(LOCALBIN ) /kustomize version | grep -q $(KUSTOMIZE_VERSION ) ; then \
143
149
echo " $( LOCALBIN) /kustomize version is not expected $( KUSTOMIZE_VERSION) . Removing it before installing." ; \
144
150
rm -rf $(LOCALBIN ) /kustomize; \
145
151
fi
146
- test -s $(LOCALBIN ) /kustomize || { curl -Ss $( KUSTOMIZE_INSTALL_SCRIPT ) | bash -s -- $( subst v,, $( KUSTOMIZE_VERSION) ) $( LOCALBIN ) ; }
152
+ test -s $(LOCALBIN ) /kustomize || GOBIN= $( LOCALBIN ) GO111MODULE=on go install sigs.k8s.io/kustomize/kustomize/v5@ $( KUSTOMIZE_VERSION )
147
153
148
154
.PHONY : controller-gen
149
155
controller-gen : $(CONTROLLER_GEN ) # # Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten.
0 commit comments