@@ -29,7 +29,6 @@ readonly RELEASE_TARS="${LOCAL_OUTPUT_ROOT}/release-tars"
29
29
readonly RELEASE_IMAGES=" ${LOCAL_OUTPUT_ROOT} /release-images"
30
30
31
31
KUBE_BUILD_CONFORMANCE=${KUBE_BUILD_CONFORMANCE:- n}
32
- KUBE_BUILD_WINDOWS=${KUBE_BUILD_WINDOWS:- n}
33
32
KUBE_BUILD_PULL_LATEST_IMAGES=${KUBE_BUILD_PULL_LATEST_IMAGES:- y}
34
33
35
34
# ---------------------------------------------------------------------------
@@ -147,7 +146,7 @@ function kube::release::package_node_tarballs() {
147
146
" ${release_stage} /node/bin/"
148
147
149
148
# TODO: Docker images here
150
- # kube::release::create_docker_images_for_server "${release_stage}/server/bin" "${arch}" "${os}"
149
+ # kube::release::create_docker_images_for_server "${release_stage}/server/bin" "${arch}"
151
150
152
151
# Include the client binaries here too as they are useful debugging tools.
153
152
local client_bins=(" ${KUBE_CLIENT_BINARIES[@]} " )
@@ -175,24 +174,14 @@ function kube::release::package_node_tarballs() {
175
174
# Package up all of the server binaries in docker images
176
175
function kube::release::build_server_images() {
177
176
kube::util::ensure-docker-buildx
178
- docker buildx create --name img-builder --use || true
179
- docker buildx inspect --bootstrap
180
- kube::util::trap_add ' docker buildx rm' EXIT
181
-
182
- platforms=(" ${KUBE_SERVER_PLATFORMS[@]} " )
183
- if [[ " ${KUBE_BUILD_WINDOWS} " =~ [yY] ]]; then
184
- platforms=(" ${KUBE_SERVER_PLATFORMS[@]} " " windows/amd64" )
185
- fi
186
177
187
178
# Clean out any old images
188
179
rm -rf " ${RELEASE_IMAGES} "
189
180
local platform
190
- for platform in " ${platforms [@]} " ; do
181
+ for platform in " ${KUBE_SERVER_PLATFORMS [@]} " ; do
191
182
local platform_tag
192
- local os
193
183
local arch
194
184
platform_tag=${platform/ \/ / -} # Replace a "/" for a "-"
195
- os=$( dirname " ${platform} " )
196
185
arch=$( basename " ${platform} " )
197
186
kube::log::status " Building images: $platform_tag "
198
187
@@ -203,16 +192,11 @@ function kube::release::build_server_images() {
203
192
204
193
# This fancy expression will expand to prepend a path
205
194
# (${LOCAL_OUTPUT_BINPATH}/${platform}/) to every item in the
206
- # KUBE_SERVER_LINUX_IMAGE_BINARIES / KUBE_SERVER_WINDOWS_IMAGE_BINARIES array.
207
- if [[ " ${os} " = " windows" ]]; then
208
- cp " ${KUBE_SERVER_WINDOWS_IMAGE_BINARIES[@]/#/ ${LOCAL_OUTPUT_BINPATH} / ${platform} / } " \
209
- " ${release_stage} /server/bin/"
210
- else
211
- cp " ${KUBE_SERVER_LINUX_IMAGE_BINARIES[@]/#/ ${LOCAL_OUTPUT_BINPATH} / ${platform} / } " \
212
- " ${release_stage} /server/bin/"
213
- fi
195
+ # KUBE_SERVER_IMAGE_BINARIES array.
196
+ cp " ${KUBE_SERVER_IMAGE_BINARIES[@]/#/ ${LOCAL_OUTPUT_BINPATH} / ${platform} / } " \
197
+ " ${release_stage} /server/bin/"
214
198
215
- kube::release::create_docker_images_for_server " ${release_stage} /server/bin" " ${arch} " " ${os} "
199
+ kube::release::create_docker_images_for_server " ${release_stage} /server/bin" " ${arch} "
216
200
done
217
201
}
218
202
@@ -301,19 +285,16 @@ function kube::release::build_conformance_image() {
301
285
# Args:
302
286
# $1 - binary_dir, the directory to save the tared images to.
303
287
# $2 - arch, architecture for which we are building docker images.
304
- # $3 - os, the OS for which we are building docker images.
305
288
function kube::release::create_docker_images_for_server() {
306
289
# Create a sub-shell so that we don't pollute the outer environment
307
290
(
308
291
local binary_dir
309
- local os
310
292
local arch
311
293
local binaries
312
294
local images_dir
313
295
binary_dir=" $1 "
314
296
arch=" $2 "
315
- os=" ${3:- linux} "
316
- binaries=$( kube::build::get_docker_wrapped_binaries " ${os} " )
297
+ binaries=$( kube::build::get_docker_wrapped_binaries)
317
298
images_dir=" ${RELEASE_IMAGES} /${arch} "
318
299
mkdir -p " ${images_dir} "
319
300
@@ -339,65 +320,51 @@ function kube::release::create_docker_images_for_server() {
339
320
340
321
for wrappable in $binaries ; do
341
322
342
- # The full binary name might have a file extension (.exe).
343
- local full_binary_name=${wrappable%% ,* }
344
- local binary_name=${full_binary_name%% .* }
323
+ local binary_name=${wrappable%% ,* }
345
324
local base_image=${wrappable##* ,}
346
- local binary_file_path=" ${binary_dir} /${full_binary_name} "
347
- local tar_path=" ${binary_dir} /${full_binary_name} .tar"
325
+ local binary_file_path=" ${binary_dir} /${binary_name} "
348
326
local docker_build_path=" ${binary_file_path} .dockerbuild"
349
327
local docker_image_tag=" ${docker_registry} /${binary_name} -${arch} :${docker_tag} "
350
328
351
329
local docker_file_path=" ${KUBE_ROOT} /build/server-image/Dockerfile"
352
330
# If this binary has its own Dockerfile use that else use the generic Dockerfile.
353
- if [[ " ${os} " = " windows" && -f " ${KUBE_ROOT} /build/server-image/${binary_name} /Dockerfile_windows" ]]; then
354
- docker_file_path=" ${KUBE_ROOT} /build/server-image/${binary_name} /Dockerfile_windows"
355
- elif [[ -f " ${KUBE_ROOT} /build/server-image/${binary_name} /Dockerfile" ]]; then
331
+ if [[ -f " ${KUBE_ROOT} /build/server-image/${binary_name} /Dockerfile" ]]; then
356
332
docker_file_path=" ${KUBE_ROOT} /build/server-image/${binary_name} /Dockerfile"
357
333
fi
358
334
359
- kube::log::status " Starting docker build for image: ${binary_name} -${os} - ${ arch}"
335
+ kube::log::status " Starting docker build for image: ${binary_name} -${arch} "
360
336
(
361
337
rm -rf " ${docker_build_path} "
362
338
mkdir -p " ${docker_build_path} "
363
- ln " ${binary_file_path} " " ${docker_build_path} /${full_binary_name} "
364
-
365
- # If we are building an official/alpha/beta release we want to keep
366
- # docker images and tag them appropriately.
367
- local additional_tag=()
368
- local release_docker_image_tag=" ${KUBE_DOCKER_REGISTRY-$docker_registry } /${binary_name} -${arch} :${KUBE_DOCKER_IMAGE_TAG-$docker_tag } "
369
-
370
- # append the OS name only for Windows images into the image name.
371
- if [[ " ${os} " = " windows" ]]; then
372
- docker_image_tag=" ${docker_registry} /${binary_name} -${os} -${arch} :${docker_tag} "
373
- release_docker_image_tag=" ${KUBE_DOCKER_REGISTRY-$docker_registry } /${binary_name} -${os} -${arch} :${KUBE_DOCKER_IMAGE_TAG-$docker_tag } "
374
- fi
375
-
376
- if [[ " ${release_docker_image_tag} " != " ${docker_image_tag} " ]]; then
377
- kube::log::status " Adding additional tag ${release_docker_image_tag} for docker image ${docker_image_tag} "
378
- " ${DOCKER[@]} " rmi " ${release_docker_image_tag} " 2> /dev/null || true
379
- additional_tag=(" -t" " ${release_docker_image_tag} " )
380
- fi
339
+ ln " ${binary_file_path} " " ${docker_build_path} /${binary_name} "
381
340
382
341
local build_log=" ${docker_build_path} /build.log"
383
342
if ! DOCKER_CLI_EXPERIMENTAL=enabled " ${DOCKER[@]} " buildx build \
384
343
-f " ${docker_file_path} " \
385
- --platform " ${os} /${arch} " \
386
- --output type=docker,dest=" ${tar_path} " \
387
- ${docker_build_opts: +" ${docker_build_opts} " } \
388
- -t " ${docker_image_tag} " " ${additional_tag[@]} " \
344
+ --platform linux/" ${arch} " \
345
+ --load ${docker_build_opts: +" ${docker_build_opts} " } \
346
+ -t " ${docker_image_tag} " \
389
347
--build-arg BASEIMAGE=" ${base_image} " \
390
348
--build-arg SETCAP_IMAGE=" ${KUBE_BUILD_SETCAP_IMAGE} " \
391
- --build-arg BINARY=" ${full_binary_name } " \
349
+ --build-arg BINARY=" ${binary_name } " \
392
350
" ${docker_build_path} " > " ${build_log} " 2>&1 ; then
393
351
cat " ${build_log} "
394
352
exit 1
395
353
fi
396
354
rm " ${build_log} "
397
355
356
+ # If we are building an official/alpha/beta release we want to keep
357
+ # docker images and tag them appropriately.
358
+ local -r release_docker_image_tag=" ${KUBE_DOCKER_REGISTRY-$docker_registry } /${binary_name} -${arch} :${KUBE_DOCKER_IMAGE_TAG-$docker_tag } "
359
+ if [[ " ${release_docker_image_tag} " != " ${docker_image_tag} " ]]; then
360
+ kube::log::status " Tagging docker image ${docker_image_tag} as ${release_docker_image_tag} "
361
+ " ${DOCKER[@]} " rmi " ${release_docker_image_tag} " 2> /dev/null || true
362
+ " ${DOCKER[@]} " tag " ${docker_image_tag} " " ${release_docker_image_tag} " 2> /dev/null
363
+ fi
364
+ " ${DOCKER[@]} " save -o " ${binary_file_path} .tar" " ${docker_image_tag} " " ${release_docker_image_tag} "
398
365
echo " ${docker_tag} " > " ${binary_file_path} .docker_tag"
399
366
rm -rf " ${docker_build_path} "
400
- ln " ${tar_path} " " ${images_dir} /"
367
+ ln " ${binary_file_path} .tar " " ${images_dir} /"
401
368
402
369
kube::log::status " Deleting docker image ${docker_image_tag} "
403
370
" ${DOCKER[@]} " rmi " ${docker_image_tag} " & > /dev/null || true
0 commit comments