Skip to content

Commit

Permalink
Refactor docker-push* Makefile targets so users can control with ALL_…
Browse files Browse the repository at this point in the history
…DOCKER_BUILD which images are pushed
  • Loading branch information
AndiDog committed May 2, 2023
1 parent e2aab8a commit 3805a23
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ docker-build-all: $(addprefix docker-build-,$(ALL_ARCH)) ## Build docker images
docker-build-%:
$(MAKE) ARCH=$* docker-build

# Choice of images to build/push
ALL_DOCKER_BUILD = core kubeadm-bootstrap kubeadm-control-plane docker-infrastructure test-extension clusterctl

.PHONY: docker-build
Expand Down Expand Up @@ -994,24 +995,17 @@ promote-images: $(KPROMO)

.PHONY: docker-push-all
docker-push-all: $(addprefix docker-push-,$(ALL_ARCH)) ## Push the docker images to be included in the release for all architectures + related multiarch manifests
$(MAKE) docker-push-manifest-core
$(MAKE) docker-push-manifest-kubeadm-bootstrap
$(MAKE) docker-push-manifest-kubeadm-control-plane
$(MAKE) docker-push-manifest-docker-infrastructure
$(MAKE) docker-push-manifest-test-extension
$(MAKE) docker-push-clusterctl
$(MAKE) ALL_ARCH="$(ALL_ARCH)" $(addprefix docker-push-manifest-,$(ALL_DOCKER_BUILD))

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

.PHONY: docker-push
docker-push: ## Push the docker images to be included in the release
docker-push: $(addprefix docker-push-,$(ALL_DOCKER_BUILD)) ## Push the docker images to be included in the release

.PHONY: docker-push-core
docker-push-core: ## Push the core docker image
docker push $(CONTROLLER_IMG)-$(ARCH):$(TAG)
docker push $(KUBEADM_BOOTSTRAP_CONTROLLER_IMG)-$(ARCH):$(TAG)
docker push $(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG)-$(ARCH):$(TAG)
docker push $(CLUSTERCTL_IMG)-$(ARCH):$(TAG)
docker push $(CAPD_CONTROLLER_IMG)-$(ARCH):$(TAG)
docker push $(TEST_EXTENSION_IMG)-$(ARCH):$(TAG)

.PHONY: docker-push-manifest-core
docker-push-manifest-core: ## Push the multiarch manifest for the core docker images
Expand All @@ -1021,6 +1015,10 @@ docker-push-manifest-core: ## Push the multiarch manifest for the core docker im
$(MAKE) set-manifest-image MANIFEST_IMG=$(CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./config/default/manager_image_patch.yaml"
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./config/default/manager_pull_policy.yaml"

.PHONY: docker-push-kubeadm-bootstrap
docker-push-kubeadm-bootstrap: ## Push the kubeadm bootstrap docker image
docker push $(KUBEADM_BOOTSTRAP_CONTROLLER_IMG)-$(ARCH):$(TAG)

.PHONY: docker-push-manifest-kubeadm-bootstrap
docker-push-manifest-kubeadm-bootstrap: ## Push the multiarch manifest for the kubeadm bootstrap docker images
docker manifest create --amend $(KUBEADM_BOOTSTRAP_CONTROLLER_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(KUBEADM_BOOTSTRAP_CONTROLLER_IMG)\-&:$(TAG)~g")
Expand All @@ -1029,6 +1027,10 @@ docker-push-manifest-kubeadm-bootstrap: ## Push the multiarch manifest for the k
$(MAKE) set-manifest-image MANIFEST_IMG=$(KUBEADM_BOOTSTRAP_CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./bootstrap/kubeadm/config/default/manager_image_patch.yaml"
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./bootstrap/kubeadm/config/default/manager_pull_policy.yaml"

.PHONY: docker-push-kubeadm-control-plane
docker-push-kubeadm-control-plane: ## Push the kubeadm control plane docker image
docker push $(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG)-$(ARCH):$(TAG)

.PHONY: docker-push-manifest-kubeadm-control-plane
docker-push-manifest-kubeadm-control-plane: ## Push the multiarch manifest for the kubeadm control plane docker images
docker manifest create --amend $(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG)\-&:$(TAG)~g")
Expand All @@ -1037,6 +1039,10 @@ docker-push-manifest-kubeadm-control-plane: ## Push the multiarch manifest for t
$(MAKE) set-manifest-image MANIFEST_IMG=$(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./controlplane/kubeadm/config/default/manager_image_patch.yaml"
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./controlplane/kubeadm/config/default/manager_pull_policy.yaml"

.PHONY: docker-push-docker-infrastructure
docker-push-docker-infrastructure: ## Push the docker infrastructure provider image
docker push $(CAPD_CONTROLLER_IMG)-$(ARCH):$(TAG)

.PHONY: docker-push-manifest-docker-infrastructure
docker-push-manifest-docker-infrastructure: ## Push the multiarch manifest for the docker infrastructure provider images
docker manifest create --amend $(CAPD_CONTROLLER_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(CAPD_CONTROLLER_IMG)\-&:$(TAG)~g")
Expand All @@ -1045,6 +1051,9 @@ docker-push-manifest-docker-infrastructure: ## Push the multiarch manifest for t
$(MAKE) set-manifest-image MANIFEST_IMG=$(CAPD_CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="$(CAPD_DIR)/config/default/manager_image_patch.yaml"
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="$(CAPD_DIR)/config/default/manager_pull_policy.yaml"

.PHONY: docker-push-test-extension
docker-push-test-extension: ## Push the test extension provider image
docker push $(TEST_EXTENSION_IMG)-$(ARCH):$(TAG)

.PHONY: docker-push-manifest-test-extension
docker-push-manifest-test-extension: ## Push the multiarch manifest for the test extension provider images
Expand All @@ -1055,7 +1064,11 @@ docker-push-manifest-test-extension: ## Push the multiarch manifest for the test
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./test/extension/config/default/manager_pull_policy.yaml"

.PHONY: docker-push-clusterctl
docker-push-clusterctl: ## Push the clusterctl images
docker-push-clusterctl: ## Push the clusterctl image
docker push $(CLUSTERCTL_IMG)-$(ARCH):$(TAG)

.PHONY: docker-push-manifest-clusterctl
docker-push-manifest-clusterctl: ## Push the multiarch manifest for the clusterctl images
docker manifest create --amend $(CLUSTERCTL_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(CLUSTERCTL_IMG)\-&:$(TAG)~g")
@for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${CLUSTERCTL_IMG}:${TAG} ${CLUSTERCTL_IMG}-$${arch}:${TAG}; done
docker manifest push --purge $(CLUSTERCTL_IMG):$(TAG)
Expand Down

0 comments on commit 3805a23

Please sign in to comment.