1
-
2
- # Image URL to use all building/pushing image targets
3
- IMG ?= controller:latest
1
+ REGISTRY ?= docker.io/linode
2
+ IMAGE_NAME ?= cluster-api-provider-linode
3
+ CONTROLLER_IMAGE ?= $(REGISTRY ) /$(IMAGE_NAME )
4
+ TAG ?= dev
4
5
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
5
6
ENVTEST_K8S_VERSION = 1.28.0
6
7
OS =$(shell uname -s | tr '[:upper:]' '[:lower:]')
@@ -47,11 +48,22 @@ all: build
47
48
# More info on the awk command:
48
49
# http://linuxcommand.org/lc3_adv_awk.php
49
50
51
+
52
+ # # --------------------------------------
53
+ # # Help
54
+ # # --------------------------------------
55
+
56
+ # #@ Help:
57
+
50
58
.PHONY : help
51
59
help : # # Display this help.
52
60
@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 )
53
61
54
- # #@ Development
62
+ # # --------------------------------------
63
+ # # Generate
64
+ # # --------------------------------------
65
+
66
+ # #@ Generate:
55
67
56
68
.PHONY : manifests
57
69
manifests : controller-gen # # Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
@@ -61,6 +73,12 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
61
73
generate : controller-gen # # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
62
74
$(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate.go.txt" paths=" ./..."
63
75
76
+ # # --------------------------------------
77
+ # # Development
78
+ # # --------------------------------------
79
+
80
+ # #@ Development:
81
+
64
82
.PHONY : fmt
65
83
fmt : # # Run go fmt against code.
66
84
go fmt ./...
@@ -85,6 +103,12 @@ nilcheck: nilaway ## Run nil check against code.
85
103
vulncheck : govulncheck # # Run vulnerability check against code.
86
104
govulncheck ./...
87
105
106
+ # # --------------------------------------
107
+ # # Testing
108
+ # # --------------------------------------
109
+
110
+ # #@ Testing:
111
+
88
112
.PHONY : test
89
113
test : manifests generate fmt vet envtest # # Run tests.
90
114
KUBEBUILDER_ASSETS=" $( shell $( ENVTEST) use $( ENVTEST_K8S_VERSION) --bin-dir $( LOCALBIN) -p path) " go test -race -timeout 60s ./... -coverprofile cover.out
@@ -101,7 +125,11 @@ _e2etest-infra: kind ctlptl tilt kuttl kustomize clusterctl envsubst
101
125
_e2etest : manifests generate envsubst _e2etest-infra
102
126
ROOT_DIR=" $( PWD) " $(KUTTL ) test --config e2e/kuttl-config.yaml
103
127
104
- # #@ Build
128
+ # # --------------------------------------
129
+ # # Build
130
+ # # --------------------------------------
131
+
132
+ # #@ Build:
105
133
106
134
.PHONY : build
107
135
build : manifests generate fmt vet # # Build manager binary.
@@ -116,11 +144,11 @@ run: manifests generate fmt vet ## Run a controller from your host.
116
144
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
117
145
.PHONY : docker-build
118
146
docker-build : # # Build docker image with the manager.
119
- $(CONTAINER_TOOL ) build $(BUILD_ARGS ) -t ${IMG} .
147
+ $(CONTAINER_TOOL ) build $(BUILD_ARGS ) . -t $( CONTROLLER_IMAGE ) : $( TAG )
120
148
121
149
.PHONY : docker-push
122
150
docker-push : # # Push docker image with the manager.
123
- $(CONTAINER_TOOL ) push ${IMG}
151
+ $(CONTAINER_TOOL ) push $( CONTROLLER_IMAGE ) : $( TAG )
124
152
125
153
# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
126
154
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
@@ -135,40 +163,63 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
135
163
sed -e ' 1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
136
164
- $(CONTAINER_TOOL ) buildx create --name project-v3-builder
137
165
$(CONTAINER_TOOL ) buildx use project-v3-builder
138
- - $(CONTAINER_TOOL ) buildx build $(BUILD_ARGS ) --push --platform=$(PLATFORMS ) --tag ${IMG} -f Dockerfile.cross .
166
+ - $(CONTAINER_TOOL ) buildx build $(BUILD_ARGS ) --push --platform=$(PLATFORMS ) --tag $( CONTROLLER_IMAGE ) : $( TAG ) -f Dockerfile.cross .
139
167
- $(CONTAINER_TOOL ) buildx rm project-v3-builder
140
168
rm Dockerfile.cross
141
169
142
- # #@ Deployment
170
+ # # --------------------------------------
171
+ # # Deployment
172
+ # # --------------------------------------
173
+
174
+ # #@ Deployment:
143
175
144
176
ifndef ignore-not-found
145
177
ignore-not-found = false
146
178
endif
147
179
148
- .PHONY : install
149
- install : manifests kustomize # # Install CRDs into the K8s cluster specified in ~/.kube/config.
150
- $(KUSTOMIZE ) build config/crd | $(KUBECTL ) apply -f -
151
-
152
- .PHONY : uninstall
153
- 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.
154
- $(KUSTOMIZE ) build config/crd | $(KUBECTL ) delete --ignore-not-found=$(ignore-not-found ) -f -
155
-
156
- .PHONY : deploy
157
- deploy : manifests kustomize # # Deploy controller to the K8s cluster specified in ~/.kube/config.
158
- cd config/manager && $(KUSTOMIZE ) edit set image controller=${IMG}
159
- $(KUSTOMIZE ) build config/default | $(KUBECTL ) apply -f -
160
-
161
- .PHONY : undeploy
162
- 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.
163
- $(KUSTOMIZE ) build config/default | $(KUBECTL ) delete --ignore-not-found=$(ignore-not-found ) -f -
164
-
165
180
.PHONY : tilt-cluster
166
181
tilt-cluster : ctlptl tilt kind clusterctl
167
182
@echo -n " LINODE_TOKEN=$( LINODE_TOKEN) " > config/default/.env.linode
168
183
$(CTLPTL ) apply -f .tilt/ctlptl-config.yaml
169
184
$(TILT ) up --stream
170
185
171
- # #@ Build Dependencies
186
+ # # --------------------------------------
187
+ # # Release
188
+ # # --------------------------------------
189
+
190
+ # #@ Release:
191
+
192
+ RELEASE_DIR ?= release
193
+ RELEASE_TAG ?= $(shell git describe --abbrev=0 2>/dev/null)
194
+
195
+ .PHONY : set-manifest-image
196
+ set-manifest-image : # # Update kustomize image patch file for default resource.
197
+ sed -i' ' -e ' s@image: .*@image: ' " ${MANIFEST_IMG} :${MANIFEST_TAG} " ' @' ./config/default/manager_image_patch.yaml
198
+
199
+ .PHONY : release
200
+ release : $(KUSTOMIZE )
201
+ rm -rf $(RELEASE_DIR )
202
+ mkdir -p $(RELEASE_DIR ) /
203
+ $(MAKE ) set-manifest-image MANIFEST_IMG=$(REGISTRY ) /$(IMAGE_NAME ) MANIFEST_TAG=$(RELEASE_TAG )
204
+ $(KUSTOMIZE ) build config/default > $(RELEASE_DIR ) /infrastructure-components.yaml
205
+ cp templates/cluster-template* $(RELEASE_DIR ) /
206
+ cp metadata.yaml $(RELEASE_DIR ) /metadata.yaml
207
+
208
+ # # --------------------------------------
209
+ # # Cleanup
210
+ # # --------------------------------------
211
+
212
+ # #@ Cleanup:
213
+
214
+ .PHONY : clean
215
+ clean :
216
+ rm -rf $(LOCALBIN )
217
+
218
+ # # --------------------------------------
219
+ # # Build Dependencies
220
+ # # --------------------------------------
221
+
222
+ # #@ Build Dependencies:
172
223
173
224
# # Location to install dependencies to
174
225
@@ -188,7 +239,12 @@ export PATH := $(CACHE_BIN):$(PATH)
188
239
$(LOCALBIN ) :
189
240
mkdir -p $(LOCALBIN )
190
241
191
- # # Tool Binaries
242
+ # # --------------------------------------
243
+ # # Tooling Binaries
244
+ # # --------------------------------------
245
+
246
+ # #@ Tooling Binaries:
247
+
192
248
KUBECTL ?= kubectl
193
249
KUSTOMIZE ?= $(LOCALBIN ) /kustomize
194
250
CTLPTL ?= $(LOCALBIN ) /ctlptl
@@ -290,7 +346,3 @@ $(NILAWAY): $(LOCALBIN)
290
346
govulncheck : $(GOVULNC ) # # Download govulncheck locally if necessary.
291
347
$(GOVULNC ) : $(LOCALBIN )
292
348
GOBIN=$(LOCALBIN ) go install golang.org/x/vuln/cmd/govulncheck@$(GOVULNC_VERSION )
293
-
294
- .PHONY : clean
295
- clean :
296
- rm -rf $(LOCALBIN )
0 commit comments