Skip to content

Commit bb26882

Browse files
authored
Merge pull request #8586 from AndiDog/makefile-push
🌱 Refactor docker-push* Makefile targets so users can control with ALL_DOCKER_BUILD which images are pushed
2 parents 8d0c60f + a2ffdfe commit bb26882

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
@@ -228,7 +228,7 @@ CAPI_KIND_CLUSTER_NAME ?= capi-test
228228

229229
TAG ?= dev
230230
ARCH ?= $(shell go env GOARCH)
231-
ALL_ARCH = amd64 arm arm64 ppc64le s390x
231+
ALL_ARCH ?= amd64 arm arm64 ppc64le s390x
232232

233233
# Allow overriding the imagePullPolicy
234234
PULL_POLICY ?= Always
@@ -724,7 +724,8 @@ docker-build-all: $(addprefix docker-build-,$(ALL_ARCH)) ## Build docker images
724724
docker-build-%:
725725
$(MAKE) ARCH=$* docker-build
726726

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

729730
.PHONY: docker-build
730731
docker-build: docker-pull-prerequisites ## Run docker-build-* targets for all the images
@@ -1071,26 +1072,17 @@ promote-images: $(KPROMO)
10711072

10721073
.PHONY: docker-push-all
10731074
docker-push-all: $(addprefix docker-push-,$(ALL_ARCH)) ## Push the docker images to be included in the release for all architectures + related multiarch manifests
1074-
$(MAKE) docker-push-manifest-core
1075-
$(MAKE) docker-push-manifest-kubeadm-bootstrap
1076-
$(MAKE) docker-push-manifest-kubeadm-control-plane
1077-
$(MAKE) docker-push-manifest-docker-infrastructure
1078-
$(MAKE) docker-push-manifest-in-memory-infrastructure
1079-
$(MAKE) docker-push-manifest-test-extension
1080-
$(MAKE) docker-push-clusterctl
1075+
$(MAKE) ALL_ARCH="$(ALL_ARCH)" $(addprefix docker-push-manifest-,$(ALL_DOCKER_BUILD))
10811076

10821077
docker-push-%:
10831078
$(MAKE) ARCH=$* docker-push
10841079

10851080
.PHONY: docker-push
1086-
docker-push: ## Push the docker images to be included in the release
1081+
docker-push: $(addprefix docker-push-,$(ALL_DOCKER_BUILD)) ## Push the docker images to be included in the release
1082+
1083+
.PHONY: docker-push-core
1084+
docker-push-core: ## Push the core docker image
10871085
docker push $(CONTROLLER_IMG)-$(ARCH):$(TAG)
1088-
docker push $(KUBEADM_BOOTSTRAP_CONTROLLER_IMG)-$(ARCH):$(TAG)
1089-
docker push $(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG)-$(ARCH):$(TAG)
1090-
docker push $(CLUSTERCTL_IMG)-$(ARCH):$(TAG)
1091-
docker push $(CAPD_CONTROLLER_IMG)-$(ARCH):$(TAG)
1092-
docker push $(CAPIM_CONTROLLER_IMG)-$(ARCH):$(TAG)
1093-
docker push $(TEST_EXTENSION_IMG)-$(ARCH):$(TAG)
10941086

10951087
.PHONY: docker-push-manifest-core
10961088
docker-push-manifest-core: ## Push the multiarch manifest for the core docker images
@@ -1100,6 +1092,10 @@ docker-push-manifest-core: ## Push the multiarch manifest for the core docker im
11001092
$(MAKE) set-manifest-image MANIFEST_IMG=$(CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./config/default/manager_image_patch.yaml"
11011093
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./config/default/manager_pull_policy.yaml"
11021094

1095+
.PHONY: docker-push-kubeadm-bootstrap
1096+
docker-push-kubeadm-bootstrap: ## Push the kubeadm bootstrap docker image
1097+
docker push $(KUBEADM_BOOTSTRAP_CONTROLLER_IMG)-$(ARCH):$(TAG)
1098+
11031099
.PHONY: docker-push-manifest-kubeadm-bootstrap
11041100
docker-push-manifest-kubeadm-bootstrap: ## Push the multiarch manifest for the kubeadm bootstrap docker images
11051101
docker manifest create --amend $(KUBEADM_BOOTSTRAP_CONTROLLER_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(KUBEADM_BOOTSTRAP_CONTROLLER_IMG)\-&:$(TAG)~g")
@@ -1108,6 +1104,10 @@ docker-push-manifest-kubeadm-bootstrap: ## Push the multiarch manifest for the k
11081104
$(MAKE) set-manifest-image MANIFEST_IMG=$(KUBEADM_BOOTSTRAP_CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./bootstrap/kubeadm/config/default/manager_image_patch.yaml"
11091105
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./bootstrap/kubeadm/config/default/manager_pull_policy.yaml"
11101106

1107+
.PHONY: docker-push-kubeadm-control-plane
1108+
docker-push-kubeadm-control-plane: ## Push the kubeadm control plane docker image
1109+
docker push $(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG)-$(ARCH):$(TAG)
1110+
11111111
.PHONY: docker-push-manifest-kubeadm-control-plane
11121112
docker-push-manifest-kubeadm-control-plane: ## Push the multiarch manifest for the kubeadm control plane docker images
11131113
docker manifest create --amend $(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG)\-&:$(TAG)~g")
@@ -1116,6 +1116,10 @@ docker-push-manifest-kubeadm-control-plane: ## Push the multiarch manifest for t
11161116
$(MAKE) set-manifest-image MANIFEST_IMG=$(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./controlplane/kubeadm/config/default/manager_image_patch.yaml"
11171117
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./controlplane/kubeadm/config/default/manager_pull_policy.yaml"
11181118

1119+
.PHONY: docker-push-docker-infrastructure
1120+
docker-push-docker-infrastructure: ## Push the docker infrastructure provider image
1121+
docker push $(CAPD_CONTROLLER_IMG)-$(ARCH):$(TAG)
1122+
11191123
.PHONY: docker-push-manifest-docker-infrastructure
11201124
docker-push-manifest-docker-infrastructure: ## Push the multiarch manifest for the docker infrastructure provider images
11211125
docker manifest create --amend $(CAPD_CONTROLLER_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(CAPD_CONTROLLER_IMG)\-&:$(TAG)~g")
@@ -1124,6 +1128,10 @@ docker-push-manifest-docker-infrastructure: ## Push the multiarch manifest for t
11241128
$(MAKE) set-manifest-image MANIFEST_IMG=$(CAPD_CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="$(CAPD_DIR)/config/default/manager_image_patch.yaml"
11251129
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="$(CAPD_DIR)/config/default/manager_pull_policy.yaml"
11261130

1131+
.PHONY: docker-push-in-memory-infrastructure
1132+
docker-push-in-memory-infrastructure: ## Push the in-memory infrastructure provider image
1133+
docker push $(CAPIM_CONTROLLER_IMG)-$(ARCH):$(TAG)
1134+
11271135
.PHONY: docker-push-manifest-in-memory-infrastructure
11281136
docker-push-manifest-in-memory-infrastructure: ## Push the multiarch manifest for the in-memory infrastructure provider images
11291137
docker manifest create --amend $(CAPIM_CONTROLLER_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(CAPIM_CONTROLLER_IMG)\-&:$(TAG)~g")
@@ -1132,6 +1140,10 @@ docker-push-manifest-in-memory-infrastructure: ## Push the multiarch manifest fo
11321140
$(MAKE) set-manifest-image MANIFEST_IMG=$(CAPIM_CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="$(CAPIM_DIR)/config/default/manager_image_patch.yaml"
11331141
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="$(CAPIM_DIR)/config/default/manager_pull_policy.yaml"
11341142

1143+
.PHONY: docker-push-test-extension
1144+
docker-push-test-extension: ## Push the test extension provider image
1145+
docker push $(TEST_EXTENSION_IMG)-$(ARCH):$(TAG)
1146+
11351147
.PHONY: docker-push-manifest-test-extension
11361148
docker-push-manifest-test-extension: ## Push the multiarch manifest for the test extension provider images
11371149
docker manifest create --amend $(TEST_EXTENSION_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(TEST_EXTENSION_IMG)\-&:$(TAG)~g")
@@ -1141,7 +1153,11 @@ docker-push-manifest-test-extension: ## Push the multiarch manifest for the test
11411153
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./test/extension/config/default/manager_pull_policy.yaml"
11421154

11431155
.PHONY: docker-push-clusterctl
1144-
docker-push-clusterctl: ## Push the clusterctl images
1156+
docker-push-clusterctl: ## Push the clusterctl image
1157+
docker push $(CLUSTERCTL_IMG)-$(ARCH):$(TAG)
1158+
1159+
.PHONY: docker-push-manifest-clusterctl
1160+
docker-push-manifest-clusterctl: ## Push the multiarch manifest for the clusterctl images
11451161
docker manifest create --amend $(CLUSTERCTL_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(CLUSTERCTL_IMG)\-&:$(TAG)~g")
11461162
@for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${CLUSTERCTL_IMG}:${TAG} ${CLUSTERCTL_IMG}-$${arch}:${TAG}; done
11471163
docker manifest push --purge $(CLUSTERCTL_IMG):$(TAG)

0 commit comments

Comments
 (0)