Skip to content

Commit

Permalink
Revert "build: Adds Windows kube-proxy image"
Browse files Browse the repository at this point in the history
This reverts commit 3b0cec3.
  • Loading branch information
jeremyrickard committed Jun 1, 2024
1 parent f386b4c commit f62cf39
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 105 deletions.
13 changes: 3 additions & 10 deletions build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,35 +107,28 @@ readonly KUBE_APISERVER_BASE_IMAGE="${KUBE_APISERVER_BASE_IMAGE:-$KUBE_GORUNNER_
readonly KUBE_CONTROLLER_MANAGER_BASE_IMAGE="${KUBE_CONTROLLER_MANAGER_BASE_IMAGE:-$KUBE_GORUNNER_IMAGE}"
readonly KUBE_SCHEDULER_BASE_IMAGE="${KUBE_SCHEDULER_BASE_IMAGE:-$KUBE_GORUNNER_IMAGE}"
readonly KUBE_PROXY_BASE_IMAGE="${KUBE_PROXY_BASE_IMAGE:-$KUBE_BASE_IMAGE_REGISTRY/distroless-iptables:$__default_distroless_iptables_version}"
readonly KUBE_PROXY_WINDOWS_BASE_IMAGE="${KUBE_PROXY_WINDOWS_BASE_IMAGE:-mcr.microsoft.com/oss/kubernetes/windows-host-process-containers-base-image:v1.0.0}"
readonly KUBECTL_BASE_IMAGE="${KUBECTL_BASE_IMAGE:-$KUBE_GORUNNER_IMAGE}"

# This is the image used in a multi-stage build to apply capabilities to Docker-wrapped binaries.
readonly KUBE_BUILD_SETCAP_IMAGE="${KUBE_BUILD_SETCAP_IMAGE:-$KUBE_BASE_IMAGE_REGISTRY/setcap:$__default_setcap_version}"

# Get the set of master binaries that run in Docker (on Linux), or as Host Process Containers (on Windows).
# Get the set of master binaries that run in Docker (on Linux)
# Entry format is "<binary-name>,<base-image>".
# Binaries are placed in /usr/local/bin inside the image (Linux), or C:\hpc (Windows).
# Binaries are placed in /usr/local/bin inside the image.
# `make` users can override any or all of the base images using the associated
# environment variables.
#
# $1 - OS name - the targets returned will be based on the OS name given.
# $1 - server architecture
kube::build::get_docker_wrapped_binaries() {
### If you change any of these lists, please also update DOCKERIZED_BINARIES
### in build/BUILD. And kube::golang::server_image_targets
local os_name="${1:-}"
local targets=(
"kube-apiserver,${KUBE_APISERVER_BASE_IMAGE}"
"kube-controller-manager,${KUBE_CONTROLLER_MANAGER_BASE_IMAGE}"
"kube-scheduler,${KUBE_SCHEDULER_BASE_IMAGE}"
"kube-proxy,${KUBE_PROXY_BASE_IMAGE}"
"kubectl,${KUBECTL_BASE_IMAGE}"
)
if [[ "${os_name}" = "windows" ]]; then
targets=(
"kube-proxy.exe,${KUBE_PROXY_WINDOWS_BASE_IMAGE}"
)
fi

echo "${targets[@]}"
}
Expand Down
85 changes: 26 additions & 59 deletions build/lib/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ readonly RELEASE_TARS="${LOCAL_OUTPUT_ROOT}/release-tars"
readonly RELEASE_IMAGES="${LOCAL_OUTPUT_ROOT}/release-images"

KUBE_BUILD_CONFORMANCE=${KUBE_BUILD_CONFORMANCE:-n}
KUBE_BUILD_WINDOWS=${KUBE_BUILD_WINDOWS:-n}
KUBE_BUILD_PULL_LATEST_IMAGES=${KUBE_BUILD_PULL_LATEST_IMAGES:-y}

# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -147,7 +146,7 @@ function kube::release::package_node_tarballs() {
"${release_stage}/node/bin/"

# TODO: Docker images here
# kube::release::create_docker_images_for_server "${release_stage}/server/bin" "${arch}" "${os}"
# kube::release::create_docker_images_for_server "${release_stage}/server/bin" "${arch}"

# Include the client binaries here too as they are useful debugging tools.
local client_bins=("${KUBE_CLIENT_BINARIES[@]}")
Expand Down Expand Up @@ -175,24 +174,14 @@ function kube::release::package_node_tarballs() {
# Package up all of the server binaries in docker images
function kube::release::build_server_images() {
kube::util::ensure-docker-buildx
docker buildx create --name img-builder --use || true
docker buildx inspect --bootstrap
kube::util::trap_add 'docker buildx rm' EXIT

platforms=("${KUBE_SERVER_PLATFORMS[@]}")
if [[ "${KUBE_BUILD_WINDOWS}" =~ [yY] ]]; then
platforms=("${KUBE_SERVER_PLATFORMS[@]}" "windows/amd64")
fi

# Clean out any old images
rm -rf "${RELEASE_IMAGES}"
local platform
for platform in "${platforms[@]}"; do
for platform in "${KUBE_SERVER_PLATFORMS[@]}"; do
local platform_tag
local os
local arch
platform_tag=${platform/\//-} # Replace a "/" for a "-"
os=$(dirname "${platform}")
arch=$(basename "${platform}")
kube::log::status "Building images: $platform_tag"

Expand All @@ -203,16 +192,11 @@ function kube::release::build_server_images() {

# This fancy expression will expand to prepend a path
# (${LOCAL_OUTPUT_BINPATH}/${platform}/) to every item in the
# KUBE_SERVER_LINUX_IMAGE_BINARIES / KUBE_SERVER_WINDOWS_IMAGE_BINARIES array.
if [[ "${os}" = "windows" ]]; then
cp "${KUBE_SERVER_WINDOWS_IMAGE_BINARIES[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
"${release_stage}/server/bin/"
else
cp "${KUBE_SERVER_LINUX_IMAGE_BINARIES[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
"${release_stage}/server/bin/"
fi
# KUBE_SERVER_IMAGE_BINARIES array.
cp "${KUBE_SERVER_IMAGE_BINARIES[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
"${release_stage}/server/bin/"

kube::release::create_docker_images_for_server "${release_stage}/server/bin" "${arch}" "${os}"
kube::release::create_docker_images_for_server "${release_stage}/server/bin" "${arch}"
done
}

Expand Down Expand Up @@ -301,19 +285,16 @@ function kube::release::build_conformance_image() {
# Args:
# $1 - binary_dir, the directory to save the tared images to.
# $2 - arch, architecture for which we are building docker images.
# $3 - os, the OS for which we are building docker images.
function kube::release::create_docker_images_for_server() {
# Create a sub-shell so that we don't pollute the outer environment
(
local binary_dir
local os
local arch
local binaries
local images_dir
binary_dir="$1"
arch="$2"
os="${3:-linux}"
binaries=$(kube::build::get_docker_wrapped_binaries "${os}")
binaries=$(kube::build::get_docker_wrapped_binaries)
images_dir="${RELEASE_IMAGES}/${arch}"
mkdir -p "${images_dir}"

Expand All @@ -339,65 +320,51 @@ function kube::release::create_docker_images_for_server() {

for wrappable in $binaries; do

# The full binary name might have a file extension (.exe).
local full_binary_name=${wrappable%%,*}
local binary_name=${full_binary_name%%.*}
local binary_name=${wrappable%%,*}
local base_image=${wrappable##*,}
local binary_file_path="${binary_dir}/${full_binary_name}"
local tar_path="${binary_dir}/${full_binary_name}.tar"
local binary_file_path="${binary_dir}/${binary_name}"
local docker_build_path="${binary_file_path}.dockerbuild"
local docker_image_tag="${docker_registry}/${binary_name}-${arch}:${docker_tag}"

local docker_file_path="${KUBE_ROOT}/build/server-image/Dockerfile"
# If this binary has its own Dockerfile use that else use the generic Dockerfile.
if [[ "${os}" = "windows" && -f "${KUBE_ROOT}/build/server-image/${binary_name}/Dockerfile_windows" ]]; then
docker_file_path="${KUBE_ROOT}/build/server-image/${binary_name}/Dockerfile_windows"
elif [[ -f "${KUBE_ROOT}/build/server-image/${binary_name}/Dockerfile" ]]; then
if [[ -f "${KUBE_ROOT}/build/server-image/${binary_name}/Dockerfile" ]]; then
docker_file_path="${KUBE_ROOT}/build/server-image/${binary_name}/Dockerfile"
fi

kube::log::status "Starting docker build for image: ${binary_name}-${os}-${arch}"
kube::log::status "Starting docker build for image: ${binary_name}-${arch}"
(
rm -rf "${docker_build_path}"
mkdir -p "${docker_build_path}"
ln "${binary_file_path}" "${docker_build_path}/${full_binary_name}"

# If we are building an official/alpha/beta release we want to keep
# docker images and tag them appropriately.
local additional_tag=()
local release_docker_image_tag="${KUBE_DOCKER_REGISTRY-$docker_registry}/${binary_name}-${arch}:${KUBE_DOCKER_IMAGE_TAG-$docker_tag}"

# append the OS name only for Windows images into the image name.
if [[ "${os}" = "windows" ]]; then
docker_image_tag="${docker_registry}/${binary_name}-${os}-${arch}:${docker_tag}"
release_docker_image_tag="${KUBE_DOCKER_REGISTRY-$docker_registry}/${binary_name}-${os}-${arch}:${KUBE_DOCKER_IMAGE_TAG-$docker_tag}"
fi

if [[ "${release_docker_image_tag}" != "${docker_image_tag}" ]]; then
kube::log::status "Adding additional tag ${release_docker_image_tag} for docker image ${docker_image_tag}"
"${DOCKER[@]}" rmi "${release_docker_image_tag}" 2>/dev/null || true
additional_tag=("-t" "${release_docker_image_tag}")
fi
ln "${binary_file_path}" "${docker_build_path}/${binary_name}"

local build_log="${docker_build_path}/build.log"
if ! DOCKER_CLI_EXPERIMENTAL=enabled "${DOCKER[@]}" buildx build \
-f "${docker_file_path}" \
--platform "${os}/${arch}" \
--output type=docker,dest="${tar_path}" \
${docker_build_opts:+"${docker_build_opts}"} \
-t "${docker_image_tag}" "${additional_tag[@]}" \
--platform linux/"${arch}" \
--load ${docker_build_opts:+"${docker_build_opts}"} \
-t "${docker_image_tag}" \
--build-arg BASEIMAGE="${base_image}" \
--build-arg SETCAP_IMAGE="${KUBE_BUILD_SETCAP_IMAGE}" \
--build-arg BINARY="${full_binary_name}" \
--build-arg BINARY="${binary_name}" \
"${docker_build_path}" >"${build_log}" 2>&1; then
cat "${build_log}"
exit 1
fi
rm "${build_log}"

# If we are building an official/alpha/beta release we want to keep
# docker images and tag them appropriately.
local -r release_docker_image_tag="${KUBE_DOCKER_REGISTRY-$docker_registry}/${binary_name}-${arch}:${KUBE_DOCKER_IMAGE_TAG-$docker_tag}"
if [[ "${release_docker_image_tag}" != "${docker_image_tag}" ]]; then
kube::log::status "Tagging docker image ${docker_image_tag} as ${release_docker_image_tag}"
"${DOCKER[@]}" rmi "${release_docker_image_tag}" 2>/dev/null || true
"${DOCKER[@]}" tag "${docker_image_tag}" "${release_docker_image_tag}" 2>/dev/null
fi
"${DOCKER[@]}" save -o "${binary_file_path}.tar" "${docker_image_tag}" "${release_docker_image_tag}"
echo "${docker_tag}" > "${binary_file_path}.docker_tag"
rm -rf "${docker_build_path}"
ln "${tar_path}" "${images_dir}/"
ln "${binary_file_path}.tar" "${images_dir}/"

kube::log::status "Deleting docker image ${docker_image_tag}"
"${DOCKER[@]}" rmi "${docker_image_tag}" &>/dev/null || true
Expand Down
4 changes: 0 additions & 4 deletions build/release-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ kube::build::verify_prereqs
kube::build::build_image
kube::build::run_build_command make all WHAT="${CMD_TARGETS}" KUBE_BUILD_PLATFORMS="${KUBE_SERVER_PLATFORMS[*]}" DBG="${DBG:-}"

if [[ "${KUBE_BUILD_WINDOWS}" =~ [yY] ]]; then
kube::build::run_build_command make all WHAT="cmd/kube-proxy" KUBE_BUILD_PLATFORMS="windows/amd64"
fi

kube::build::copy_output

kube::release::build_server_images
2 changes: 0 additions & 2 deletions build/root/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ define RELEASE_IMAGES_HELP_INFO
# Args:
# KUBE_BUILD_CONFORMANCE: Whether to build conformance testing image as well. Set to 'n' to skip.
# DBG: If set to "1", build with optimizations disabled for easier debugging. Any other value is ignored.
# KUBE_BUILD_WINDOWS: Whether to build images for Windows as well. Set to 'y' to enable.
#
# Example:
# make release-images
Expand Down Expand Up @@ -439,7 +438,6 @@ define QUICK_RELEASE_IMAGES_HELP_INFO
# KUBE_FASTBUILD: Whether to cross-compile for other architectures. Set to 'false' to do so.
# KUBE_BUILD_CONFORMANCE: Whether to build conformance testing image as well. Set to 'y' to do so.
# DBG: If set to "1", build with optimizations disabled for easier debugging. Any other value is ignored.
# KUBE_BUILD_WINDOWS: Whether to build images for Windows as well. Set to 'y' to enable.
#
# Example:
# make quick-release-images
Expand Down
28 changes: 0 additions & 28 deletions build/server-image/kube-proxy/Dockerfile_windows

This file was deleted.

3 changes: 1 addition & 2 deletions hack/lib/golang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ kube::golang::server_image_targets() {

IFS=" " read -ra KUBE_SERVER_IMAGE_TARGETS <<< "$(kube::golang::server_image_targets)"
readonly KUBE_SERVER_IMAGE_TARGETS
readonly KUBE_SERVER_LINUX_IMAGE_BINARIES=("${KUBE_SERVER_IMAGE_TARGETS[@]##*/}")
readonly KUBE_SERVER_WINDOWS_IMAGE_BINARIES=("kube-proxy.exe")
readonly KUBE_SERVER_IMAGE_BINARIES=("${KUBE_SERVER_IMAGE_TARGETS[@]##*/}")

# The set of conformance targets we build docker image for
kube::golang::conformance_image_targets() {
Expand Down

0 comments on commit f62cf39

Please sign in to comment.