@@ -153,6 +153,10 @@ KUBEADM_BOOTSTRAP_CONTROLLER_IMG ?= $(REGISTRY)/$(KUBEADM_BOOTSTRAP_IMAGE_NAME)
153
153
KUBEADM_CONTROL_PLANE_IMAGE_NAME ?= kubeadm-control-plane-controller
154
154
KUBEADM_CONTROL_PLANE_CONTROLLER_IMG ?= $(REGISTRY ) /$(KUBEADM_CONTROL_PLANE_IMAGE_NAME )
155
155
156
+ # capd
157
+ CAPD_IMAGE_NAME ?= capd-manager
158
+ CAPD_CONTROLLER_IMG ?= $(REGISTRY ) /$(CAPD_IMAGE_NAME )
159
+
156
160
# clusterctl
157
161
CLUSTERCTL_MANIFEST_DIR := cmd/clusterctl/config
158
162
CLUSTERCTL_IMAGE_NAME ?= clusterctl
@@ -188,12 +192,11 @@ help: # Display this help
188
192
189
193
# #@ generate:
190
194
191
- ALL_GENERATE_MODULES = core kubeadm-bootstrap kubeadm-control-plane
195
+ ALL_GENERATE_MODULES = core kubeadm-bootstrap kubeadm-control-plane capd
192
196
193
197
.PHONY : generate
194
198
generate : # # Run all generate-manifests-*, generate-go-deepcopy-*, generate-go-conversions-* and generate-go-openapi targets
195
199
$(MAKE ) generate-modules generate-manifests generate-go-deepcopy generate-go-conversions generate-go-openapi
196
- $(MAKE ) -C $(CAPD_DIR ) generate
197
200
198
201
.PHONY : generate-manifests
199
202
generate-manifests : $(addprefix generate-manifests-,$(ALL_GENERATE_MODULES ) ) # # Run all generate-manifests-* targets
@@ -246,6 +249,19 @@ generate-manifests-kubeadm-control-plane: $(CONTROLLER_GEN) ## Generate manifest
246
249
output:webhook:dir=./controlplane/kubeadm/config/webhook \
247
250
webhook
248
251
252
+ .PHONY : generate-manifests-capd
253
+ generate-manifests-capd : $(CONTROLLER_GEN ) # # Generate manifests e.g. CRD, RBAC etc. for capd provider
254
+ cd $(CAPD_DIR ) ; $(CONTROLLER_GEN ) \
255
+ paths=./api/... \
256
+ paths=./$(EXP_DIR ) /api/... \
257
+ paths=./$(EXP_DIR ) /internal/controllers/... \
258
+ paths=./internal/controllers/... \
259
+ crd:crdVersions=v1 \
260
+ rbac:roleName=manager-role \
261
+ output:crd:dir=./config/crd/bases \
262
+ output:webhook:dir=./config/webhook \
263
+ webhook
264
+
249
265
.PHONY : generate-go-deepcopy
250
266
generate-go-deepcopy : # # Run all generate-go-deepcopy-* targets
251
267
$(MAKE ) $(addprefix generate-go-deepcopy-,$(ALL_GENERATE_MODULES ) )
@@ -276,6 +292,13 @@ generate-go-deepcopy-kubeadm-control-plane: $(CONTROLLER_GEN) ## Generate deepco
276
292
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt \
277
293
paths=./controlplane/kubeadm/api/...
278
294
295
+ .PHONY : generate-go-deepcopy-capd
296
+ generate-go-deepcopy-capd : $(CONTROLLER_GEN ) # # Generate deepcopy go code for capd
297
+ cd $(CAPD_DIR ) ; $(CONTROLLER_GEN ) \
298
+ object:headerFile=../../../hack/boilerplate/boilerplate.generatego.txt \
299
+ paths=./api/... \
300
+ paths=./$(EXP_DIR ) /api/...
301
+
279
302
.PHONY : generate-go-conversions
280
303
generate-go-conversions : # # Run all generate-go-conversions-* targets
281
304
$(MAKE ) $(addprefix generate-go-conversions-,$(ALL_GENERATE_MODULES ) )
@@ -353,6 +376,19 @@ generate-go-conversions-kubeadm-control-plane: $(CONVERSION_GEN) ## Generate con
353
376
--output-file-base=zz_generated.conversion $(CONVERSION_GEN_OUTPUT_BASE ) \
354
377
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt
355
378
379
+ .PHONY : generate-go-conversions-capd
380
+ generate-go-conversions-capd : $(CONVERSION_GEN ) # # Generate conversions go code for capd
381
+ cd $(CAPD_DIR ) ; $(CONVERSION_GEN ) \
382
+ --input-dirs=./api/v1alpha3 \
383
+ --input-dirs=./api/v1alpha4 \
384
+ --input-dirs=./$(EXP_DIR ) /api/v1alpha3 \
385
+ --input-dirs=./$(EXP_DIR ) /api/v1alpha4 \
386
+ --build-tag=ignore_autogenerated_capd \
387
+ --extra-peer-dirs=sigs.k8s.io/cluster-api/api/v1alpha3 \
388
+ --extra-peer-dirs=sigs.k8s.io/cluster-api/api/v1alpha4 \
389
+ --output-file-base=zz_generated.conversion $(CONVERSION_GEN_OUTPUT_BASE ) \
390
+ --go-header-file=../../../hack/boilerplate/boilerplate.generatego.txt
391
+
356
392
.PHONY : generate-go-openapi
357
393
generate-go-openapi : $(OPENAPI_GEN ) $(CONTROLLER_GEN ) # # Generate openapi go code for runtime SDK
358
394
@for pkg in " api/v1beta1" " $( EXP_DIR) /runtime/hooks/api/v1alpha1" ; do \
@@ -401,7 +437,7 @@ APIDIFF_OLD_COMMIT ?= $(shell git rev-parse origin/main)
401
437
apidiff : $(GO_APIDIFF ) # # Check for API differences
402
438
$(GO_APIDIFF ) $(APIDIFF_OLD_COMMIT ) --print-compatible
403
439
404
- ALL_VERIFY_CHECKS = doctoc boilerplate shellcheck tiltfile modules gen conversions docker-provider
440
+ ALL_VERIFY_CHECKS = doctoc boilerplate shellcheck tiltfile modules gen conversions
405
441
406
442
.PHONY : verify
407
443
verify : $(addprefix verify-,$(ALL_VERIFY_CHECKS ) ) # # Run all verify-* targets
@@ -444,11 +480,6 @@ verify-shellcheck: ## Verify shell files
444
480
verify-tiltfile : # # Verify Tiltfile format
445
481
./hack/verify-starlark.sh
446
482
447
- .PHONY : verify-docker-provider
448
- verify-docker-provider :
449
- @echo " Verifying CAPD"
450
- cd $(CAPD_DIR ) ; $(MAKE ) verify
451
-
452
483
# # --------------------------------------
453
484
# # Binaries
454
485
# # --------------------------------------
@@ -459,7 +490,7 @@ verify-docker-provider:
459
490
clusterctl : # # Build the clusterctl binary
460
491
go build -trimpath -ldflags " $( LDFLAGS) " -o $(BIN_DIR ) /clusterctl sigs.k8s.io/cluster-api/cmd/clusterctl
461
492
462
- ALL_MANAGERS = core kubeadm-bootstrap kubeadm-control-plane
493
+ ALL_MANAGERS = core kubeadm-bootstrap kubeadm-control-plane capd
463
494
464
495
.PHONY : managers
465
496
managers : $(addprefix manager-,$(ALL_MANAGERS ) ) # # Run all manager-* targets
@@ -476,6 +507,10 @@ manager-kubeadm-bootstrap: ## Build the kubeadm bootstrap manager binary into th
476
507
manager-kubeadm-control-plane : # # Build the kubeadm control plane manager binary into the ./bin folder
477
508
go build -trimpath -ldflags " $( LDFLAGS) " -o $(BIN_DIR ) /kubeadm-control-plane-manager sigs.k8s.io/cluster-api/controlplane/kubeadm
478
509
510
+ .PHONY : manager-capd
511
+ manager-capd : # # Build the kubeadm control plane manager binary into the ./bin folder
512
+ cd $(CAPD_DIR ) ; go build -trimpath -ldflags " $( LDFLAGS) " -o ../../../$(BIN_DIR ) /capd-manager sigs.k8s.io/cluster-api/test/infrastructure/docker
513
+
479
514
.PHONY : docker-pull-prerequisites
480
515
docker-pull-prerequisites :
481
516
docker pull docker.io/docker/dockerfile:1.1-experimental
@@ -516,6 +551,9 @@ docker-build-kubeadm-control-plane: ## Build the docker image for kubeadm contro
516
551
docker-build-clusterctl : # # Build the docker image for clusterctl with output binary name as 'clusterctl'
517
552
DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE ) --build-arg goproxy=$(GOPROXY ) --build-arg ARCH=$(ARCH ) --build-arg package=./cmd/clusterctl --build-arg ldflags=" $( LDFLAGS) " -f ./cmd/clusterctl/Dockerfile . -t $(CLUSTERCTL_IMG ) -$(ARCH ) :$(TAG )
518
553
554
+ .PHONY : docker-capd-build-all
555
+ docker-capd-build-all : $(addprefix docker-capd-build-,$(ALL_ARCH ) ) # # Build capd docker images for all architectures
556
+
519
557
.PHONY : e2e-framework
520
558
e2e-framework : # # Builds the CAPI e2e framework
521
559
cd $(E2E_FRAMEWORK_DIR ) ; go build ./...
@@ -528,6 +566,15 @@ build-book: ## Build the book
528
566
serve-book : # # Build and serve the book (with live-reload)
529
567
$(MAKE ) -C docs/book serve
530
568
569
+ docker-capd-build-% :
570
+ $(MAKE ) ARCH=$* docker-capd-build
571
+
572
+ .PHONY : docker-capd-build
573
+ docker-capd-build : # # Build the docker image for capd
574
+ cd $(CAPD_DIR ) ; DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE ) --build-arg goproxy=$(GOPROXY ) --build-arg ARCH=$(ARCH ) --build-arg ldflags=" $( LDFLAGS) " ../../.. -t $(CAPD_CONTROLLER_IMG ) -$(ARCH ) :$(TAG ) --file Dockerfile
575
+ $(MAKE ) set-manifest-image MANIFEST_IMG=$(CAPD_CONTROLLER_IMG ) -$(ARCH ) MANIFEST_TAG=$(TAG ) TARGET_RESOURCE=" $( CAPD_DIR) /config/default/manager_image_patch.yaml"
576
+ $(MAKE ) set-manifest-pull-policy TARGET_RESOURCE=" $( CAPD_DIR) /config/default/manager_pull_policy.yaml"
577
+
531
578
# # --------------------------------------
532
579
# # Testing
533
580
# # --------------------------------------
@@ -566,14 +613,28 @@ test-cover: ## Run unit and integration tests and generate a coverage report
566
613
test-e2e : # # Run e2e tests
567
614
$(MAKE ) -C $(TEST_DIR ) /e2e run
568
615
616
+ .PHONY : test-capd
617
+ test-capd : $(SETUP_ENVTEST ) # # Run unit and integration tests for capd
618
+ cd $(CAPD_DIR ) ; KUBEBUILDER_ASSETS=" $( KUBEBUILDER_ASSETS) " go test ./... $(TEST_ARGS )
619
+
620
+ .PHONY : test-capd-verbose
621
+ test-capd-verbose : # # Run unit and integration tests with verbose flag
622
+ $(MAKE ) test-capd TEST_ARGS=" $( TEST_ARGS) -v"
623
+
624
+ .PHONY : test-capd-junit
625
+ test-capd-junit : $(SETUP_ENVTEST ) $(GOTESTSUM ) # # Run unit and integration tests and generate a junit report for capd
626
+ cd $(CAPD_DIR ) ; set +o errexit; (KUBEBUILDER_ASSETS=" $( KUBEBUILDER_ASSETS) " go test -json ./... $( TEST_ARGS) ; echo $$ ? > $( ARTIFACTS) /junit.infra_docker.exitcode) | tee $(ARTIFACTS ) /junit.infra_docker.stdout
627
+ $(GOTESTSUM ) --junitfile $(ARTIFACTS ) /junit.infra_docker.xml --raw-command cat $(ARTIFACTS ) /junit.infra_docker.stdout
628
+ exit $$(cat $(ARTIFACTS ) /junit.infra_docker.exitcode )
629
+
569
630
.PHONY : kind-cluster
570
631
kind-cluster : # # Create a new kind cluster designed for development with Tilt
571
632
hack/kind-install-for-capd.sh
572
633
573
634
.PHONY : docker-build-e2e
574
635
docker-build-e2e : # # Rebuild all Cluster API provider images to be used in the e2e tests
575
- make docker-build REGISTRY=gcr.io/k8s-staging-cluster-api PULL_POLICY=IfNotPresent
576
- $(MAKE ) -C $( CAPD_DIR ) docker-build REGISTRY=gcr.io/k8s-staging-cluster-api PULL_POLICY=IfNotPresent
636
+ $( MAKE ) docker-build REGISTRY=gcr.io/k8s-staging-cluster-api PULL_POLICY=IfNotPresent
637
+ $(MAKE ) docker-capd -build REGISTRY=gcr.io/k8s-staging-cluster-api PULL_POLICY=IfNotPresent
577
638
578
639
# # --------------------------------------
579
640
# # Release
@@ -626,9 +687,13 @@ manifest-modification: # Set the manifest images to the staging/production bucke
626
687
$(MAKE ) set-manifest-image \
627
688
MANIFEST_IMG=$(REGISTRY ) /$(KUBEADM_CONTROL_PLANE_IMAGE_NAME ) MANIFEST_TAG=$(RELEASE_TAG ) \
628
689
TARGET_RESOURCE=" ./controlplane/kubeadm/config/default/manager_image_patch.yaml"
690
+ $(MAKE ) set-manifest-image \
691
+ MANIFEST_IMG=$(REGISTRY ) /$(CAPD_IMAGE_NAME ) MANIFEST_TAG=$(RELEASE_TAG ) \
692
+ TARGET_RESOURCE=" $( CAPD_DIR) /config/default/manager_image_patch.yaml"
629
693
$(MAKE ) set-manifest-pull-policy PULL_POLICY=IfNotPresent TARGET_RESOURCE=" ./config/default/manager_pull_policy.yaml"
630
694
$(MAKE ) set-manifest-pull-policy PULL_POLICY=IfNotPresent TARGET_RESOURCE=" ./bootstrap/kubeadm/config/default/manager_pull_policy.yaml"
631
695
$(MAKE ) set-manifest-pull-policy PULL_POLICY=IfNotPresent TARGET_RESOURCE=" ./controlplane/kubeadm/config/default/manager_pull_policy.yaml"
696
+ $(MAKE ) set-manifest-pull-policy PULL_POLICY=IfNotPresent TARGET_RESOURCE=" $( CAPD_DIR) /config/default/manager_pull_policy.yaml"
632
697
633
698
.PHONY : release-manifests
634
699
release-manifests : $(RELEASE_DIR ) $(KUSTOMIZE ) $(RUNTIME_OPENAPI_GEN ) # # Build the manifests to publish with a release
@@ -652,11 +717,8 @@ release-manifests: $(RELEASE_DIR) $(KUSTOMIZE) $(RUNTIME_OPENAPI_GEN) ## Build t
652
717
$(RUNTIME_OPENAPI_GEN) --version $(RELEASE_TAG) --output-file $(RELEASE_DIR)/runtime-sdk-openapi.yaml
653
718
654
719
.PHONY : release-manifests-dev
655
- release-manifests-dev : # # Build the development manifests and copies them in the release folder
656
- # Release CAPD components and add them to the release dir
657
- $(MAKE ) -C $(CAPD_DIR ) release
658
- cp $(CAPD_DIR ) /out/infrastructure-components.yaml $(RELEASE_DIR ) /infrastructure-components-development.yaml
659
- # Adds CAPD templates
720
+ release-manifests-dev : $(RELEASE_DIR ) $(KUSTOMIZE ) # # Build the development manifests and copies them in the release folder
721
+ cd $(CAPD_DIR ) ; $(KUSTOMIZE ) build config/default > ../../../$(RELEASE_DIR ) /infrastructure-components-development.yaml
660
722
cp $(CAPD_DIR ) /templates/* $(RELEASE_DIR ) /
661
723
662
724
release-binaries : # # Build the binaries to publish with a release
@@ -701,6 +763,26 @@ release-alias-tag: ## Add the release alias tag to the last build tag
701
763
gcloud container images add-tag $(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG ) :$(TAG ) $(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG ) :$(RELEASE_ALIAS_TAG )
702
764
gcloud container images add-tag $(CLUSTERCTL_IMG ) :$(TAG ) $(CLUSTERCTL_IMG ) :$(RELEASE_ALIAS_TAG )
703
765
766
+ .PHONY : release-capd-staging
767
+ release-capd-staging : # # Build and push container images to the staging bucket
768
+ REGISTRY=$(STAGING_REGISTRY ) $(MAKE ) docker-capd-build-all docker-capd-push-all release-capd-alias-tag
769
+
770
+ .PHONY : release-capd-staging-nightly
771
+ release-capd-staging-nightly : # # Tag and push container images to the staging bucket. Example image tag: cluster-api-controller:nightly_main_20210121
772
+ $(eval NEW_RELEASE_ALIAS_TAG := nightly_$(RELEASE_ALIAS_TAG ) _$(shell date +'% Y% m% d') )
773
+ echo $(NEW_RELEASE_ALIAS_TAG )
774
+ $(MAKE ) release-capd-alias-tag TAG=$(RELEASE_ALIAS_TAG ) RELEASE_ALIAS_TAG=$(NEW_RELEASE_ALIAS_TAG )
775
+ # Set the manifest image to the staging bucket.
776
+ $(MAKE ) manifest-modification REGISTRY=$(STAGING_REGISTRY ) RELEASE_TAG=$(NEW_RELEASE_ALIAS_TAG )
777
+ # # Build the manifests
778
+ $(MAKE ) release-manifests-dev
779
+ # Example manifest location: artifacts.k8s-staging-cluster-api.appspot.com/components/nightly_main_20210121/infrastructure-components.yaml
780
+ gsutil cp $(RELEASE_DIR ) /* gs://$(STAGING_BUCKET ) /components/$(NEW_RELEASE_ALIAS_TAG )
781
+
782
+ .PHONY : release-capd-alias-tag
783
+ release-capd-alias-tag : # # Add the release alias tag to the last build tag
784
+ gcloud container images add-tag $(CAPD_CONTROLLER_IMG ) :$(TAG ) $(CAPD_CONTROLLER_IMG ) :$(RELEASE_ALIAS_TAG )
785
+
704
786
.PHONY : release-notes
705
787
release-notes : $(RELEASE_NOTES_DIR ) $(RELEASE_NOTES )
706
788
if [ -n " ${PRE_RELEASE} " ]; then \
@@ -734,6 +816,17 @@ docker-push-all: $(addprefix docker-push-,$(ALL_ARCH)) ## Push all the architec
734
816
docker-push-% :
735
817
$(MAKE ) ARCH=$* docker-push
736
818
819
+ .PHONY : docker-capd-push
820
+ docker-capd-push : # # Push the capd docker image
821
+ docker push $(CAPD_CONTROLLER_IMG ) -$(ARCH ) :$(TAG )
822
+
823
+ .PHONY : docker-capd-push-all
824
+ docker-capd-push-all : $(addprefix docker-capd-push-,$(ALL_ARCH ) ) # # Push all the architecture docker images
825
+ $(MAKE ) docker-capd-push-manifest
826
+
827
+ docker-capd-push-% :
828
+ $(MAKE ) ARCH=$* docker-capd-push
829
+
737
830
.PHONY : docker-push-manifest-core
738
831
docker-push-manifest-core : # # Push the multiarch manifest for the core docker images
739
832
# # Minimum docker version 18.06.0 is required for creating and pushing manifest images.
@@ -761,6 +854,15 @@ docker-push-manifest-kubeadm-control-plane: ## Push the multiarch manifest for t
761
854
$(MAKE ) set-manifest-image MANIFEST_IMG=$(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG ) MANIFEST_TAG=$(TAG ) TARGET_RESOURCE=" ./controlplane/kubeadm/config/default/manager_image_patch.yaml"
762
855
$(MAKE ) set-manifest-pull-policy TARGET_RESOURCE=" ./controlplane/kubeadm/config/default/manager_pull_policy.yaml"
763
856
857
+ .PHONY : docker-push-manifest-capd
858
+ docker-capd-push-manifest : # # Push the multiarch manifest for the the capd docker images
859
+ # # Minimum docker version 18.06.0 is required for creating and pushing manifest images.
860
+ docker manifest create --amend $(CAPD_CONTROLLER_IMG ) :$(TAG ) $(shell echo $(ALL_ARCH ) | sed -e "s~[^ ]* ~$(CAPD_CONTROLLER_IMG ) \-&:$(TAG ) ~g")
861
+ @for arch in $(ALL_ARCH ) ; do docker manifest annotate --arch $$ {arch} ${CAPD_CONTROLLER_IMG} :${TAG} ${CAPD_CONTROLLER_IMG} -$$ {arch}:${TAG} ; done
862
+ docker manifest push --purge $(CAPD_CONTROLLER_IMG ) :$(TAG )
863
+ $(MAKE ) set-manifest-image MANIFEST_IMG=$(CAPD_CONTROLLER_IMG ) MANIFEST_TAG=$(TAG ) TARGET_RESOURCE=" $( CAPD_DIR) /config/default/manager_image_patch.yaml"
864
+ $(MAKE ) set-manifest-pull-policy TARGET_RESOURCE=" $( CAPD_DIR) /config/default/manager_pull_policy.yaml"
865
+
764
866
.PHONY : docker-push-clusterctl
765
867
docker-push-clusterctl : # # Push the clusterctl images
766
868
# # Minimum docker version 18.06.0 is required for creating and pushing manifest images.
0 commit comments