Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Refactor docker-push* Makefile targets so users can control with ALL_DOCKER_BUILD which images are pushed #8586

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 33 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ CAPI_KIND_CLUSTER_NAME ?= capi-test

TAG ?= dev
ARCH ?= $(shell go env GOARCH)
ALL_ARCH = amd64 arm arm64 ppc64le s390x
ALL_ARCH ?= amd64 arm arm64 ppc64le s390x

# Allow overriding the imagePullPolicy
PULL_POLICY ?= Always
Expand Down Expand Up @@ -694,7 +694,8 @@ docker-build-all: $(addprefix docker-build-,$(ALL_ARCH)) ## Build docker images
docker-build-%:
$(MAKE) ARCH=$* docker-build

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

.PHONY: docker-build
docker-build: docker-pull-prerequisites ## Run docker-build-* targets for all the images
Expand Down Expand Up @@ -1041,26 +1042,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-in-memory-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
sbueringer marked this conversation as resolved.
Show resolved Hide resolved

.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 $(CAPIM_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 @@ -1070,6 +1062,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 @@ -1078,6 +1074,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 @@ -1086,6 +1086,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 @@ -1094,6 +1098,10 @@ 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-in-memory-infrastructure
docker-push-in-memory-infrastructure: ## Push the in-memory infrastructure provider image
docker push $(CAPIM_CONTROLLER_IMG)-$(ARCH):$(TAG)

.PHONY: docker-push-manifest-in-memory-infrastructure
docker-push-manifest-in-memory-infrastructure: ## Push the multiarch manifest for the in-memory infrastructure provider images
docker manifest create --amend $(CAPIM_CONTROLLER_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(CAPIM_CONTROLLER_IMG)\-&:$(TAG)~g")
Expand All @@ -1102,6 +1110,10 @@ docker-push-manifest-in-memory-infrastructure: ## Push the multiarch manifest fo
$(MAKE) set-manifest-image MANIFEST_IMG=$(CAPIM_CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="$(CAPIM_DIR)/config/default/manager_image_patch.yaml"
$(MAKE) set-manifest-pull-policy TARGET_RESOURCE="$(CAPIM_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
docker manifest create --amend $(TEST_EXTENSION_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(TEST_EXTENSION_IMG)\-&:$(TAG)~g")
Expand All @@ -1111,7 +1123,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