Skip to content

Commit a2ffdfe

Browse files
committed
Refactor docker-push* Makefile targets so users can control with ALL_DOCKER_BUILD which images are pushed
1 parent f3e3bda commit a2ffdfe

File tree

1 file changed

+33
-17
lines changed

1 file changed

+33
-17
lines changed

Makefile

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ CAPI_KIND_CLUSTER_NAME ?= capi-test
221221

222222
TAG ?= dev
223223
ARCH ?= $(shell go env GOARCH)
224-
ALL_ARCH = amd64 arm arm64 ppc64le s390x
224+
ALL_ARCH ?= amd64 arm arm64 ppc64le s390x
225225

226226
# Allow overriding the imagePullPolicy
227227
PULL_POLICY ?= Always
@@ -694,7 +694,8 @@ docker-build-all: $(addprefix docker-build-,$(ALL_ARCH)) ## Build docker images
694694
docker-build-%:
695695
$(MAKE) ARCH=$* docker-build
696696

697-
ALL_DOCKER_BUILD = core kubeadm-bootstrap kubeadm-control-plane docker-infrastructure in-memory-infrastructure test-extension clusterctl
697+
# Choice of images to build/push
698+
ALL_DOCKER_BUILD ?= core kubeadm-bootstrap kubeadm-control-plane docker-infrastructure in-memory-infrastructure test-extension clusterctl
698699

699700
.PHONY: docker-build
700701
docker-build: docker-pull-prerequisites ## Run docker-build-* targets for all the images
@@ -1041,26 +1042,17 @@ promote-images: $(KPROMO)
10411042

10421043
.PHONY: docker-push-all
10431044
docker-push-all: $(addprefix docker-push-,$(ALL_ARCH)) ## Push the docker images to be included in the release for all architectures + related multiarch manifests
1044-
$(MAKE) docker-push-manifest-core
1045-
$(MAKE) docker-push-manifest-kubeadm-bootstrap
1046-
$(MAKE) docker-push-manifest-kubeadm-control-plane
1047-
$(MAKE) docker-push-manifest-docker-infrastructure
1048-
$(MAKE) docker-push-manifest-in-memory-infrastructure
1049-
$(MAKE) docker-push-manifest-test-extension
1050-
$(MAKE) docker-push-clusterctl
1045+
$(MAKE) ALL_ARCH="$(ALL_ARCH)" $(addprefix docker-push-manifest-,$(ALL_DOCKER_BUILD))
10511046

10521047
docker-push-%:
10531048
$(MAKE) ARCH=$* docker-push
10541049

10551050
.PHONY: docker-push
1056-
docker-push: ## Push the docker images to be included in the release
1051+
docker-push: $(addprefix docker-push-,$(ALL_DOCKER_BUILD)) ## Push the docker images to be included in the release
1052+
1053+
.PHONY: docker-push-core
1054+
docker-push-core: ## Push the core docker image
10571055
docker push $(CONTROLLER_IMG)-$(ARCH):$(TAG)
1058-
docker push $(KUBEADM_BOOTSTRAP_CONTROLLER_IMG)-$(ARCH):$(TAG)
1059-
docker push $(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG)-$(ARCH):$(TAG)
1060-
docker push $(CLUSTERCTL_IMG)-$(ARCH):$(TAG)
1061-
docker push $(CAPD_CONTROLLER_IMG)-$(ARCH):$(TAG)
1062-
docker push $(CAPIM_CONTROLLER_IMG)-$(ARCH):$(TAG)
1063-
docker push $(TEST_EXTENSION_IMG)-$(ARCH):$(TAG)
10641056

10651057
.PHONY: docker-push-manifest-core
10661058
docker-push-manifest-core: ## Push the multiarch manifest for the core docker images
@@ -1070,6 +1062,10 @@ docker-push-manifest-core: ## Push the multiarch manifest for the core docker im
10701062
$(MAKE) set-manifest-image MANIFEST_IMG=$(CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./config/default/manager_image_patch.yaml"
10711063
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./config/default/manager_pull_policy.yaml"
10721064

1065+
.PHONY: docker-push-kubeadm-bootstrap
1066+
docker-push-kubeadm-bootstrap: ## Push the kubeadm bootstrap docker image
1067+
docker push $(KUBEADM_BOOTSTRAP_CONTROLLER_IMG)-$(ARCH):$(TAG)
1068+
10731069
.PHONY: docker-push-manifest-kubeadm-bootstrap
10741070
docker-push-manifest-kubeadm-bootstrap: ## Push the multiarch manifest for the kubeadm bootstrap docker images
10751071
docker manifest create --amend $(KUBEADM_BOOTSTRAP_CONTROLLER_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(KUBEADM_BOOTSTRAP_CONTROLLER_IMG)\-&:$(TAG)~g")
@@ -1078,6 +1074,10 @@ docker-push-manifest-kubeadm-bootstrap: ## Push the multiarch manifest for the k
10781074
$(MAKE) set-manifest-image MANIFEST_IMG=$(KUBEADM_BOOTSTRAP_CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./bootstrap/kubeadm/config/default/manager_image_patch.yaml"
10791075
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./bootstrap/kubeadm/config/default/manager_pull_policy.yaml"
10801076

1077+
.PHONY: docker-push-kubeadm-control-plane
1078+
docker-push-kubeadm-control-plane: ## Push the kubeadm control plane docker image
1079+
docker push $(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG)-$(ARCH):$(TAG)
1080+
10811081
.PHONY: docker-push-manifest-kubeadm-control-plane
10821082
docker-push-manifest-kubeadm-control-plane: ## Push the multiarch manifest for the kubeadm control plane docker images
10831083
docker manifest create --amend $(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG)\-&:$(TAG)~g")
@@ -1086,6 +1086,10 @@ docker-push-manifest-kubeadm-control-plane: ## Push the multiarch manifest for t
10861086
$(MAKE) set-manifest-image MANIFEST_IMG=$(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./controlplane/kubeadm/config/default/manager_image_patch.yaml"
10871087
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./controlplane/kubeadm/config/default/manager_pull_policy.yaml"
10881088

1089+
.PHONY: docker-push-docker-infrastructure
1090+
docker-push-docker-infrastructure: ## Push the docker infrastructure provider image
1091+
docker push $(CAPD_CONTROLLER_IMG)-$(ARCH):$(TAG)
1092+
10891093
.PHONY: docker-push-manifest-docker-infrastructure
10901094
docker-push-manifest-docker-infrastructure: ## Push the multiarch manifest for the docker infrastructure provider images
10911095
docker manifest create --amend $(CAPD_CONTROLLER_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(CAPD_CONTROLLER_IMG)\-&:$(TAG)~g")
@@ -1094,6 +1098,10 @@ docker-push-manifest-docker-infrastructure: ## Push the multiarch manifest for t
10941098
$(MAKE) set-manifest-image MANIFEST_IMG=$(CAPD_CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="$(CAPD_DIR)/config/default/manager_image_patch.yaml"
10951099
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="$(CAPD_DIR)/config/default/manager_pull_policy.yaml"
10961100

1101+
.PHONY: docker-push-in-memory-infrastructure
1102+
docker-push-in-memory-infrastructure: ## Push the in-memory infrastructure provider image
1103+
docker push $(CAPIM_CONTROLLER_IMG)-$(ARCH):$(TAG)
1104+
10971105
.PHONY: docker-push-manifest-in-memory-infrastructure
10981106
docker-push-manifest-in-memory-infrastructure: ## Push the multiarch manifest for the in-memory infrastructure provider images
10991107
docker manifest create --amend $(CAPIM_CONTROLLER_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(CAPIM_CONTROLLER_IMG)\-&:$(TAG)~g")
@@ -1102,6 +1110,10 @@ docker-push-manifest-in-memory-infrastructure: ## Push the multiarch manifest fo
11021110
$(MAKE) set-manifest-image MANIFEST_IMG=$(CAPIM_CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="$(CAPIM_DIR)/config/default/manager_image_patch.yaml"
11031111
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="$(CAPIM_DIR)/config/default/manager_pull_policy.yaml"
11041112

1113+
.PHONY: docker-push-test-extension
1114+
docker-push-test-extension: ## Push the test extension provider image
1115+
docker push $(TEST_EXTENSION_IMG)-$(ARCH):$(TAG)
1116+
11051117
.PHONY: docker-push-manifest-test-extension
11061118
docker-push-manifest-test-extension: ## Push the multiarch manifest for the test extension provider images
11071119
docker manifest create --amend $(TEST_EXTENSION_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(TEST_EXTENSION_IMG)\-&:$(TAG)~g")
@@ -1111,7 +1123,11 @@ docker-push-manifest-test-extension: ## Push the multiarch manifest for the test
11111123
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./test/extension/config/default/manager_pull_policy.yaml"
11121124

11131125
.PHONY: docker-push-clusterctl
1114-
docker-push-clusterctl: ## Push the clusterctl images
1126+
docker-push-clusterctl: ## Push the clusterctl image
1127+
docker push $(CLUSTERCTL_IMG)-$(ARCH):$(TAG)
1128+
1129+
.PHONY: docker-push-manifest-clusterctl
1130+
docker-push-manifest-clusterctl: ## Push the multiarch manifest for the clusterctl images
11151131
docker manifest create --amend $(CLUSTERCTL_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(CLUSTERCTL_IMG)\-&:$(TAG)~g")
11161132
@for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${CLUSTERCTL_IMG}:${TAG} ${CLUSTERCTL_IMG}-$${arch}:${TAG}; done
11171133
docker manifest push --purge $(CLUSTERCTL_IMG):$(TAG)

0 commit comments

Comments
 (0)