From 3ab1a4976659d48e8bf10722ab415004cb4d1f81 Mon Sep 17 00:00:00 2001 From: Stephen Augustus Date: Sat, 5 Sep 2020 04:45:42 -0400 Subject: [PATCH] build/lib/release: Explicitly use '--platform' in building server images When we switched to go-runner for building the apiserver, controller-manager, and scheduler server components, we no longer reference the individual architectures in the image names, specifically in the 'FROM' directive of the server image Dockerfiles. As a result, server images for non-amd64 images copy in the go-runner amd64 binary instead of the go-runner that matches that architecture. This commit explicitly sets the '--platform=linux/${arch}' to ensure we're pulling the correct go-runner arch from the manifest list. Before: FROM ${base_image} After: FROM --platform=linux/${arch} ${base_image} Signed-off-by: Stephen Augustus --- build/common.sh | 3 +-- build/lib/release.sh | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/build/common.sh b/build/common.sh index ad7f66105fe..39b297e93cd 100755 --- a/build/common.sh +++ b/build/common.sh @@ -93,7 +93,6 @@ readonly KUBE_CONTAINER_RSYNC_PORT=8730 # # $1 - server architecture kube::build::get_docker_wrapped_binaries() { - local arch=$1 local debian_iptables_version=v12.1.2 local go_runner_version=buster-v2.0.0 ### If you change any of these lists, please also update DOCKERIZED_BINARIES @@ -102,7 +101,7 @@ kube::build::get_docker_wrapped_binaries() { "kube-apiserver,${KUBE_BASE_IMAGE_REGISTRY}/go-runner:${go_runner_version}" "kube-controller-manager,${KUBE_BASE_IMAGE_REGISTRY}/go-runner:${go_runner_version}" "kube-scheduler,${KUBE_BASE_IMAGE_REGISTRY}/go-runner:${go_runner_version}" - "kube-proxy,${KUBE_BASE_IMAGE_REGISTRY}/debian-iptables-${arch}:${debian_iptables_version}" + "kube-proxy,${KUBE_BASE_IMAGE_REGISTRY}/debian-iptables:${debian_iptables_version}" ) echo "${targets[@]}" diff --git a/build/lib/release.sh b/build/lib/release.sh index dae9c21c8e5..6b3d45dfbb0 100644 --- a/build/lib/release.sh +++ b/build/lib/release.sh @@ -334,7 +334,7 @@ function kube::release::create_docker_images_for_server() { local images_dir binary_dir="$1" arch="$2" - binaries=$(kube::build::get_docker_wrapped_binaries "${arch}") + binaries=$(kube::build::get_docker_wrapped_binaries) images_dir="${RELEASE_IMAGES}/${arch}" mkdir -p "${images_dir}" @@ -375,7 +375,7 @@ function kube::release::create_docker_images_for_server() { ln "${KUBE_ROOT}/build/nsswitch.conf" "${docker_build_path}/nsswitch.conf" chmod 0644 "${docker_build_path}/nsswitch.conf" cat < "${docker_file_path}" -FROM ${base_image} +FROM --platform=linux/${arch} ${base_image} COPY ${binary_name} /usr/local/bin/${binary_name} EOF # ensure /etc/nsswitch.conf exists so go's resolver respects /etc/hosts