mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
all wrapped binaries to use a configurable image as the base image
This commit is contained in:
parent
54e6db0896
commit
d68c36a268
@ -93,10 +93,12 @@ readonly RELEASE_DIR="${LOCAL_OUTPUT_ROOT}/release-tars"
|
|||||||
readonly GCS_STAGE="${LOCAL_OUTPUT_ROOT}/gcs-stage"
|
readonly GCS_STAGE="${LOCAL_OUTPUT_ROOT}/gcs-stage"
|
||||||
|
|
||||||
# The set of master binaries that run in Docker (on Linux)
|
# The set of master binaries that run in Docker (on Linux)
|
||||||
|
# Entry format is "<name-of-binary>,<base-image>".
|
||||||
|
# Binaries are placed in /usr/local/bin inside the image.
|
||||||
readonly KUBE_DOCKER_WRAPPED_BINARIES=(
|
readonly KUBE_DOCKER_WRAPPED_BINARIES=(
|
||||||
kube-apiserver
|
kube-apiserver,busybox
|
||||||
kube-controller-manager
|
kube-controller-manager,busybox
|
||||||
kube-scheduler
|
kube-scheduler,busybox
|
||||||
)
|
)
|
||||||
|
|
||||||
# The set of addons images that should be prepopulated
|
# The set of addons images that should be prepopulated
|
||||||
@ -734,30 +736,44 @@ function kube::release::sha1() {
|
|||||||
|
|
||||||
# This will take binaries that run on master and creates Docker images
|
# This will take binaries that run on master and creates Docker images
|
||||||
# that wrap the binary in them. (One docker image per binary)
|
# that wrap the binary in them. (One docker image per binary)
|
||||||
|
# Args:
|
||||||
|
# $1 - binary_dir, the directory to save the tared images to.
|
||||||
|
# Globals:
|
||||||
|
# KUBE_DOCKER_WRAPPED_BINARIES
|
||||||
function kube::release::create_docker_images_for_server() {
|
function kube::release::create_docker_images_for_server() {
|
||||||
# Create a sub-shell so that we don't pollute the outer environment
|
# Create a sub-shell so that we don't pollute the outer environment
|
||||||
(
|
(
|
||||||
|
local binary_dir="$1"
|
||||||
local binary_name
|
local binary_name
|
||||||
for binary_name in "${KUBE_DOCKER_WRAPPED_BINARIES[@]}"; do
|
for wrappable in "${KUBE_DOCKER_WRAPPED_BINARIES[@]}"; do
|
||||||
|
|
||||||
|
local oldifs=$IFS
|
||||||
|
IFS=","
|
||||||
|
set $wrappable
|
||||||
|
IFS=$oldifs
|
||||||
|
|
||||||
|
local binary_name="$1"
|
||||||
|
local base_image="$2"
|
||||||
|
|
||||||
kube::log::status "Starting Docker build for image: ${binary_name}"
|
kube::log::status "Starting Docker build for image: ${binary_name}"
|
||||||
|
|
||||||
(
|
(
|
||||||
local md5_sum
|
local md5_sum
|
||||||
md5_sum=$(kube::release::md5 "$1/${binary_name}")
|
md5_sum=$(kube::release::md5 "${binary_dir}/${binary_name}")
|
||||||
|
|
||||||
local docker_build_path="$1/${binary_name}.dockerbuild"
|
local docker_build_path="${binary_dir}/${binary_name}.dockerbuild"
|
||||||
local docker_file_path="${docker_build_path}/Dockerfile"
|
local docker_file_path="${docker_build_path}/Dockerfile"
|
||||||
local binary_file_path="$1/${binary_name}"
|
local binary_file_path="${binary_dir}/${binary_name}"
|
||||||
|
|
||||||
rm -rf ${docker_build_path}
|
rm -rf ${docker_build_path}
|
||||||
mkdir -p ${docker_build_path}
|
mkdir -p ${docker_build_path}
|
||||||
ln $1/${binary_name} ${docker_build_path}/${binary_name}
|
ln ${binary_dir}/${binary_name} ${docker_build_path}/${binary_name}
|
||||||
printf " FROM busybox \n ADD ${binary_name} /usr/local/bin/${binary_name}\n" > ${docker_file_path}
|
printf " FROM ${base_image} \n ADD ${binary_name} /usr/local/bin/${binary_name}\n" > ${docker_file_path}
|
||||||
|
|
||||||
local docker_image_tag=gcr.io/google_containers/$binary_name:$md5_sum
|
local docker_image_tag=gcr.io/google_containers/$binary_name:$md5_sum
|
||||||
docker build -q -t "${docker_image_tag}" ${docker_build_path} >/dev/null
|
docker build -q -t "${docker_image_tag}" ${docker_build_path} >/dev/null
|
||||||
docker save ${docker_image_tag} > ${1}/${binary_name}.tar
|
docker save ${docker_image_tag} > ${binary_dir}/${binary_name}.tar
|
||||||
echo $md5_sum > ${1}/${binary_name}.docker_tag
|
echo $md5_sum > ${binary_dir}/${binary_name}.docker_tag
|
||||||
|
|
||||||
rm -rf ${docker_build_path}
|
rm -rf ${docker_build_path}
|
||||||
|
|
||||||
@ -769,6 +785,7 @@ function kube::release::create_docker_images_for_server() {
|
|||||||
kube::util::wait-for-jobs || { kube::log::error "previous Docker build failed"; return 1; }
|
kube::util::wait-for-jobs || { kube::log::error "previous Docker build failed"; return 1; }
|
||||||
kube::log::status "Docker builds done"
|
kube::log::status "Docker builds done"
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# This will pull and save docker images for addons which need to placed
|
# This will pull and save docker images for addons which need to placed
|
||||||
|
Loading…
Reference in New Issue
Block a user