1
- # Copyright 2018 The Kubernetes Authors.
1
+ # Copyright 2021 The Kubernetes Authors.
2
2
#
3
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
4
# you may not use this file except in compliance with the License.
12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
- # If you update this file, please follow
16
- # https://suva.sh/posts/well-documented-makefiles
17
-
18
15
# Ensure Make is run with bash shell as some syntax below is bash-specific
19
16
SHELL: =/usr/bin/env bash
20
17
@@ -61,9 +58,15 @@ REGISTRY ?= gcr.io/$(shell gcloud config get-value project)
61
58
endif
62
59
STAGING_REGISTRY ?= gcr.io/k8s-staging-cluster-api-provider-nested
63
60
PROD_REGISTRY ?= us.gcr.io/k8s-artifacts-prod/cluster-api-provider-nested
61
+
62
+ # Infrastructure
64
63
IMAGE_NAME ?= cluster-api-nested-controller
65
64
CONTROLLER_IMG ?= $(REGISTRY ) /$(IMAGE_NAME )
66
65
66
+ # Control Plane
67
+ CONTROLPLANE_IMAGE_NAME ?= nested-controlplane-controller
68
+ CONTROLPLANE_CONTROLLER_IMG ?= $(REGISTRY ) /$(CONTROLPLANE_IMAGE_NAME )
69
+
67
70
TAG ?= dev
68
71
ARCH ?= amd64
69
72
ALL_ARCH = amd64 arm arm64 ppc64le s390x
@@ -93,13 +96,18 @@ test: ## Run tests.
93
96
.PHONY : binaries
94
97
binaries : managers
95
98
96
- .PHONY : manager
97
- manager-core : # # Build manager binary
98
- go build -ldflags " $( LDFLAGS) " -o $(BIN_DIR ) /manager sigs.k8s.io/cluster-api-provider-nested
99
-
100
99
.PHONY : managers
101
100
managers : # # Build all managers
102
- $(MAKE ) manager-core
101
+ $(MAKE ) manager-nested-infrastructure
102
+ $(MAKE ) manager-nested-controlplane
103
+
104
+ .PHONY : manager-nested-infrastructure
105
+ manager-nested-infrastructure :
106
+ go build -ldflags " $( LDFLAGS) " -o $(BIN_DIR ) /manager sigs.k8s.io/cluster-api-provider-nested
107
+
108
+ .PHONY : manager-nested-controlplane
109
+ manager-nested-controlplane : # # Build manager binary
110
+ go build -ldflags " $( LDFLAGS) " -o $(BIN_DIR ) /nested-controlplane-manager sigs.k8s.io/cluster-api-provider-nested/controlplane/nested
103
111
104
112
$(CONTROLLER_GEN ) : $(TOOLS_DIR ) /go.mod # Build controller-gen from tools folder.
105
113
cd $(TOOLS_DIR ) ; go build -tags=tools -o $(BIN_DIR ) /controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen
@@ -150,24 +158,52 @@ generate:
150
158
.PHONY : generate-go
151
159
generate-go : $(CONTROLLER_GEN ) # # Runs Go related generate targets
152
160
go generate ./...
161
+ $(MAKE ) generate-go-infrastructure
162
+ $(MAKE ) generate-go-controlplane
163
+
164
+ .PHONY : generate-go-infrastructure
165
+ generate-go-infrastructure : $(CONTROLLER_GEN )
166
+ $(CONTROLLER_GEN ) \
167
+ object:headerFile=./hack/boilerplate/boilerplate.generatego.txt \
168
+ paths=./api/...
169
+
170
+ generate-go-controlplane : $(CONTROLLER_GEN )
153
171
$(CONTROLLER_GEN ) \
154
172
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt \
155
- paths=./apis /...
173
+ paths=./controlplane/nested/api /...
156
174
157
175
.PHONY : generate-manifests
158
176
generate-manifests : $(CONTROLLER_GEN ) # # Generate manifests e.g. CRD, RBAC etc.
177
+ $(MAKE ) generate-manifests-infrastructure
178
+ $(MAKE ) generate-manifests-controlplane
179
+ # # Copy files in CI folders.
180
+ mkdir -p ./config/ci/{rbac,manager}
181
+ cp -f ./config/rbac/* .yaml ./config/ci/rbac/
182
+ cp -f ./config/manager/manager* .yaml ./config/ci/manager/
183
+
184
+ .PHONY : generate-manifests-infrastructure
185
+ generate-manifests-infrastructure :
159
186
$(CONTROLLER_GEN ) \
160
- paths=./apis /... \
187
+ paths=./api /... \
161
188
paths=./controllers/... \
162
189
crd:crdVersions=v1 \
163
190
rbac:roleName=manager-role \
164
191
output:crd:dir=./config/crd/bases \
165
192
output:webhook:dir=./config/webhook \
193
+ output:rbac:dir=./config/rbac \
194
+ webhook
195
+
196
+ .PHONY : generate-manifests-controlplane
197
+ generate-manifests-controlplane :
198
+ $(CONTROLLER_GEN ) \
199
+ paths=./controlplane/nested/api/... \
200
+ paths=./controlplane/nested/controllers/... \
201
+ crd:crdVersions=v1 \
202
+ rbac:roleName=manager-role \
203
+ output:crd:dir=./controlplane/nested/config/crd/bases \
204
+ output:webhook:dir=./controlplane/nested/config/webhook \
205
+ output:rbac:dir=./controlplane/nested/config/rbac \
166
206
webhook
167
- # # Copy files in CI folders.
168
- mkdir -p ./config/ci/{rbac,manager}
169
- cp -f ./config/rbac/* .yaml ./config/ci/rbac/
170
- cp -f ./config/manager/manager* .yaml ./config/ci/manager/
171
207
172
208
.PHONY : modules
173
209
modules : # # Runs go mod to ensure modules are up to date.
@@ -184,32 +220,63 @@ docker-pull-prerequisites:
184
220
docker pull docker.io/library/golang:1.15.3
185
221
docker pull gcr.io/distroless/static:latest
186
222
187
- .PHONY : docker-build
188
- docker-build : docker-pull-prerequisites # # Build the docker images for controller managers
223
+ .PHONY : docker-infrastructure- build
224
+ docker-infrastructure- build : docker-pull-prerequisites # # Build the docker images for controller managers
189
225
DOCKER_BUILDKIT=1 docker build --build-arg goproxy=$(GOPROXY ) --build-arg ARCH=$(ARCH ) --build-arg ldflags=" $( LDFLAGS) " . -t $(CONTROLLER_IMG ) -$(ARCH ) :$(TAG )
190
- # $(MAKE) set-manifest-image MANIFEST_IMG=$(CONTROLLER_IMG)-$(ARCH) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./config/manager /manager_image_patch.yaml"
191
- # $(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./config/manager /manager_pull_policy.yaml"
226
+ $(MAKE ) set-manifest-image MANIFEST_IMG=$(CONTROLLER_IMG ) -$(ARCH ) MANIFEST_TAG=$(TAG ) TARGET_RESOURCE=" ./config/default /manager_image_patch.yaml"
227
+ $(MAKE ) set-manifest-pull-policy TARGET_RESOURCE=" ./config/default /manager_pull_policy.yaml"
192
228
193
- .PHONY : docker-push
194
- docker-push : # # Push the docker images
229
+ .PHONY : docker-controlplane-build
230
+ docker-controlplane-build : docker-pull-prerequisites # # Build the docker images for controller managers
231
+ DOCKER_BUILDKIT=1 docker build --build-arg goproxy=$(GOPROXY ) --build-arg ARCH=$(ARCH ) --build-arg ldflags=" $( LDFLAGS) " --build-arg package=./controlplane/nested . -t $(CONTROLPLANE_CONTROLLER_IMG ) -$(ARCH ) :$(TAG )
232
+ $(MAKE ) set-manifest-image MANIFEST_IMG=$(CONTROLPLANE_CONTROLLER_IMG ) -$(ARCH ) MANIFEST_TAG=$(TAG ) TARGET_RESOURCE=" ./controlplane/nested/config/default/manager_image_patch.yaml"
233
+ $(MAKE ) set-manifest-pull-policy TARGET_RESOURCE=" ./controlplane/nested/config/default/manager_pull_policy.yaml"
234
+
235
+
236
+ .PHONY : docker-infrastructure-push
237
+ docker-infrastructure-push : # # Push the docker images
195
238
docker push $(CONTROLLER_IMG ) -$(ARCH ) :$(TAG )
196
239
240
+ .PHONY : docker-controlplane-push
241
+ docker-controlplane-push : # # Push the docker images
242
+ docker push $(CONTROLPLANE_CONTROLLER_IMG ) -$(ARCH ) :$(TAG )
243
+
197
244
# # --------------------------------------
198
245
# # Docker — All ARCH
199
246
# # --------------------------------------
200
247
201
248
.PHONY : docker-build-all # # Build all the architecture docker images
202
- docker-build-all : $(addprefix docker-build-,$(ALL_ARCH ) )
249
+ docker-build-all : $(addprefix docker-infrastructure-build-,$(ALL_ARCH ) ) $(addprefix docker-controlplane-build-,$(ALL_ARCH ) )
250
+
251
+ .PHONY : docker-build
252
+ docker-build :
253
+ $(MAKE ) docker-infrastructure-build
254
+ $(MAKE ) docker-controlplane-build
203
255
204
- docker-build-% :
205
- $(MAKE ) ARCH=$* docker-build
256
+ .PHONY : docker-infrastructure-build
257
+ docker-infrastructure-build-% :
258
+ $(MAKE ) ARCH=$* docker-infrastructure-build
259
+
260
+ .PHONY : docker-controlplane-build
261
+ docker-controlplane-build-% :
262
+ $(MAKE ) ARCH=$* docker-controlplane-build
206
263
207
264
.PHONY : docker-push-all # # Push all the architecture docker images
208
- docker-push-all : $(addprefix docker-push-,$(ALL_ARCH ) )
265
+ docker-push-all : $(addprefix docker-infrastructure-push-, $( ALL_ARCH ) ) $( addprefix docker-controlplane- push-,$(ALL_ARCH ) )
209
266
$(MAKE ) docker-push-core-manifest
210
267
211
- docker-push-% :
212
- $(MAKE ) ARCH=$* docker-push
268
+ .PHONY : docker-push
269
+ docker-push :
270
+ $(MAKE ) docker-infrastructure-push
271
+ $(MAKE ) docker-controlplane-push
272
+
273
+ .PHONY : docker-infrastructure-push
274
+ docker-infrastructure-push-% :
275
+ $(MAKE ) ARCH=$* docker-infrastructure-push
276
+
277
+ .PHONY : docker-controlplane-push
278
+ docker-controlplane-push-% :
279
+ $(MAKE ) ARCH=$* docker-controlplane-push
213
280
214
281
.PHONY : docker-push-core-manifest
215
282
docker-push-core-manifest : # # Push the fat manifest docker image for the core image.
@@ -260,17 +327,28 @@ release: clean-release ## Builds and push container images using the latest git
260
327
.PHONY : release-manifests
261
328
release-manifests : $(RELEASE_DIR ) $(KUSTOMIZE ) # # Builds the manifests to publish with a release
262
329
# Build infrastructure-components.
263
- $(KUSTOMIZE ) build config > $(RELEASE_DIR ) /infrastructure-components.yaml
330
+ $(KUSTOMIZE ) build config/default > $(RELEASE_DIR ) /infrastructure-components.yaml
331
+ # Build control-plane-components.
332
+ $(KUSTOMIZE ) build controlplane/nested/config/default > $(RELEASE_DIR ) /control-plane-components.yaml
333
+
334
+ # # Build cluster-api-provider-nested-components (aggregate of all of the above).
335
+ cat $(RELEASE_DIR)/infrastructure-components.yaml > $(RELEASE_DIR)/cluster-api-provider-nested-components.yaml
336
+ echo "---" >> $(RELEASE_DIR)/cluster-api-provider-nested-components.yaml
337
+ cat $(RELEASE_DIR)/control-plane-components.yaml >> $(RELEASE_DIR)/cluster-api-provider-nested-components.yaml
338
+ # Add metadata to the release artifacts
339
+ cp metadata.yaml $(RELEASE_DIR)/metadata.yaml
340
+
264
341
265
342
.PHONY : release-staging
266
343
release-staging : # # Builds and push container images to the staging bucket.
267
- REGISTRY=$(STAGING_REGISTRY ) $(MAKE ) docker-build docker-push release-alias-tag
344
+ REGISTRY=$(STAGING_REGISTRY ) $(MAKE ) docker-build-all docker-push-all release-alias-tag
268
345
269
346
RELEASE_ALIAS_TAG =$(PULL_BASE_REF )
270
347
271
348
.PHONY : release-alias-tag
272
349
release-alias-tag : # # Adds the tag to the last build tag.
273
350
gcloud container images add-tag $(CONTROLLER_IMG ) :$(TAG ) $(CONTROLLER_IMG ) :$(RELEASE_ALIAS_TAG )
351
+ gcloud container images add-tag $(CONTROLPLANE_CONTROLLER_IMG ) :$(TAG ) $(CONTROLPLANE_CONTROLLER_IMG ) :$(RELEASE_ALIAS_TAG )
274
352
275
353
.PHONY : release-notes
276
354
release-notes : $(RELEASE_NOTES ) # # Generates a release notes template to be used with a release.
0 commit comments