Merge pull request #16600 from spowelljr/refactorBuildx

Makefile: refactor buildx related targets
pull/16609/head
Medya Ghazizadeh 2023-05-31 12:00:10 -07:00 committed by GitHub
commit fab9d783de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 21 deletions

View File

@ -698,14 +698,10 @@ storage-provisioner-image-%: out/storage-provisioner-%
docker build -t $(REGISTRY)/storage-provisioner-$*:$(STORAGE_PROVISIONER_TAG) -f deploy/storage-provisioner/Dockerfile --build-arg arch=$* .
X_DOCKER_BUILDER ?= minikube-builder
X_BUILD_ENV ?= DOCKER_CLI_EXPERIMENTAL=enabled
.PHONY: docker-multi-arch-builder
docker-multi-arch-builder:
env $(X_BUILD_ENV) docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
env $(X_BUILD_ENV) docker buildx rm --builder $(X_DOCKER_BUILDER) || true
env $(X_BUILD_ENV) docker buildx create --name $(X_DOCKER_BUILDER) --buildkitd-flags '--debug' || true
.PHONY: docker-multi-arch-build
docker-multi-arch-build:
# installs QEMU static binaries to allow docker multi-arch build, see: https://github.com/docker/setup-qemu-action
docker run --rm --privileged tonistiigi/binfmt:latest --install all
KICBASE_ARCH ?= linux/amd64,linux/arm64,linux/s390x,linux/arm,linux/ppc64le
KICBASE_IMAGE_GCR ?= $(REGISTRY)/kicbase:$(KIC_VERSION)
@ -736,11 +732,11 @@ local-kicbase-debug: local-kicbase ## Builds a local kicbase image and switches
$(SED) 's|Version = .*|Version = \"$(KIC_VERSION)-$(COMMIT_SHORT)\"|;s|baseImageSHA = .*|baseImageSHA = \"\"|;s|gcrRepo = .*|gcrRepo = \"local/kicbase\"|;s|dockerhubRepo = .*|dockerhubRepo = \"local/kicbase\"|' pkg/drivers/kic/types.go
.PHONY: build-kic-base-image
build-kic-base-image: docker-multi-arch-builder ## Build multi-arch local/kicbase:latest
env $(X_BUILD_ENV) docker buildx build -f ./deploy/kicbase/Dockerfile --builder $(X_DOCKER_BUILDER) --platform $(KICBASE_ARCH) $(addprefix -t ,$(KICBASE_IMAGE_REGISTRIES)) --load --build-arg VERSION_JSON=$(VERSION_JSON) --build-arg COMMIT_SHA=${VERSION}-$(COMMIT_NOQUOTES) .
build-kic-base-image: docker-multi-arch-build ## Build multi-arch local/kicbase:latest
docker buildx build -f ./deploy/kicbase/Dockerfile --platform $(KICBASE_ARCH) $(addprefix -t ,$(KICBASE_IMAGE_REGISTRIES)) --build-arg VERSION_JSON=$(VERSION_JSON) --build-arg COMMIT_SHA=${VERSION}-$(COMMIT_NOQUOTES) .
.PHONY: push-kic-base-image
push-kic-base-image: docker-multi-arch-builder ## Push multi-arch local/kicbase:latest to all remote registries
push-kic-base-image: docker-multi-arch-build ## Push multi-arch local/kicbase:latest to all remote registries
ifdef AUTOPUSH
docker login gcr.io/k8s-minikube
docker login docker.pkg.github.com
@ -752,7 +748,7 @@ ifndef CIBUILD
$(call user_confirm, 'Are you sure you want to push $(KICBASE_IMAGE_REGISTRIES) ?')
endif
./deploy/kicbase/build_auto_pause.sh $(KICBASE_ARCH)
env $(X_BUILD_ENV) docker buildx build -f ./deploy/kicbase/Dockerfile --builder $(X_DOCKER_BUILDER) --platform $(KICBASE_ARCH) $(addprefix -t ,$(KICBASE_IMAGE_REGISTRIES)) --push --build-arg VERSION_JSON=$(VERSION_JSON) --build-arg COMMIT_SHA=${VERSION}-$(COMMIT_NOQUOTES) --build-arg PREBUILT_AUTO_PAUSE=true .
docker buildx build -f ./deploy/kicbase/Dockerfile --platform $(KICBASE_ARCH) $(addprefix -t ,$(KICBASE_IMAGE_REGISTRIES)) --push --build-arg VERSION_JSON=$(VERSION_JSON) --build-arg COMMIT_SHA=${VERSION}-$(COMMIT_NOQUOTES) --build-arg PREBUILT_AUTO_PAUSE=true .
out/preload-tool:
go build -ldflags="$(MINIKUBE_LDFLAGS)" -o $@ ./hack/preload-images/*.go
@ -775,9 +771,9 @@ ifndef CIBUILD
docker login gcr.io/k8s-minikube
endif
set -x; for arch in $(ALL_ARCH); do docker push ${IMAGE}-$${arch}:${TAG}; done
$(X_BUILD_ENV) docker manifest create --amend $(IMAGE):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(IMAGE)\-&:$(TAG)~g")
set -x; for arch in $(ALL_ARCH); do $(X_BUILD_ENV) docker manifest annotate --arch $${arch} ${IMAGE}:${TAG} ${IMAGE}-$${arch}:${TAG}; done
$(X_BUILD_ENV) docker manifest push $(STORAGE_PROVISIONER_MANIFEST)
docker manifest create --amend $(IMAGE):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(IMAGE)\-&:$(TAG)~g")
set -x; for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${IMAGE}:${TAG} ${IMAGE}-$${arch}:${TAG}; done
docker manifest push $(STORAGE_PROVISIONER_MANIFEST)
.PHONY: push-docker
push-docker: # Push docker image base on to IMAGE variable (used internally by other targets)
@ -876,9 +872,7 @@ kvm-image-amd64: installers/linux/kvm/Dockerfile.amd64 ## Convenient alias to b
@echo "$(@) successfully built"
.PHONY: kvm-image-arm64
kvm-image-arm64: installers/linux/kvm/Dockerfile.arm64 ## Convenient alias to build the docker container
# line below installs QEMU static binaries to allow docker multi-arch build, see: https://github.com/docker/setup-qemu-action
docker run --rm --privileged tonistiigi/binfmt:latest --install all
kvm-image-arm64: installers/linux/kvm/Dockerfile.arm64 docker-multi-arch-build ## Convenient alias to build the docker container
docker buildx build --platform linux/arm64 --build-arg "GO_VERSION=$(KVM_GO_VERSION)" -t $(KVM_BUILD_IMAGE_ARM64) -f $< $(dir $<)
@echo ""
@echo "$(@) successfully built"

View File

@ -24,10 +24,10 @@ import (
const (
// Version is the current version of kic
Version = "v0.0.39-1685034446-16582"
Version = "v0.0.39-1685477270-16600"
// SHA of the kic base image
baseImageSHA = "aa728b22374c829d1e5b0a5d64d51d3e0ae0f2b191381d957516fdff68f357c8"
baseImageSHA = "c81b94f0b25b3fcc844c9d1acd1fbfa391b977b9269dbe87eea9194ab72e03b3"
// The name of the GCR kicbase repository
gcrRepo = "gcr.io/k8s-minikube/kicbase-builds"
// The name of the Dockerhub kicbase repository

View File

@ -26,7 +26,7 @@ minikube start [flags]
--apiserver-names strings A set of apiserver names which are used in the generated certificate for kubernetes. This can be used if you want to make the apiserver available from outside the machine
--apiserver-port int The apiserver listening port (default 8443)
--auto-update-drivers If set, automatically updates drivers to the latest version. Defaults to true. (default true)
--base-image string The base image to use for docker/podman drivers. Intended for local development. (default "gcr.io/k8s-minikube/kicbase-builds:v0.0.39-1685034446-16582@sha256:aa728b22374c829d1e5b0a5d64d51d3e0ae0f2b191381d957516fdff68f357c8")
--base-image string The base image to use for docker/podman drivers. Intended for local development. (default "gcr.io/k8s-minikube/kicbase-builds:v0.0.39-1685477270-16600@sha256:c81b94f0b25b3fcc844c9d1acd1fbfa391b977b9269dbe87eea9194ab72e03b3")
--binary-mirror string Location to fetch kubectl, kubelet, & kubeadm binaries from.
--cache-images If true, cache docker images for the current bootstrapper and load them into the machine. Always false with --driver=none. (default true)
--cert-expiration duration Duration until minikube certificate expiration, defaults to three years (26280h). (default 26280h0m0s)