Skip to content

Commit 9cdfdba

Browse files
authored
Merge pull request kubernetes#71924 from yujuhong/node-binaries
GCE: enable downloading and staging of the node binaries
2 parents cd06791 + 62db510 commit 9cdfdba

File tree

3 files changed

+57
-4
lines changed

3 files changed

+57
-4
lines changed

cluster/gce/util.sh

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,21 @@ function set-preferred-region() {
248248
# Assumed vars:
249249
# PROJECT
250250
# SERVER_BINARY_TAR
251+
# NODE_BINARY_TAR (optional)
251252
# KUBE_MANIFESTS_TAR
252253
# ZONE
253254
# Vars set:
254255
# SERVER_BINARY_TAR_URL
255256
# SERVER_BINARY_TAR_HASH
257+
# NODE_BINARY_TAR_URL
258+
# NODE_BINARY_TAR_HASH
256259
# KUBE_MANIFESTS_TAR_URL
257260
# KUBE_MANIFESTS_TAR_HASH
258-
function upload-server-tars() {
261+
function upload-tars() {
259262
SERVER_BINARY_TAR_URL=
260263
SERVER_BINARY_TAR_HASH=
264+
NODE_BINARY_TAR_URL=
265+
NODE_BINARY_TAR_HASH=
261266
KUBE_MANIFESTS_TAR_URL=
262267
KUBE_MANIFESTS_TAR_HASH=
263268

@@ -279,11 +284,16 @@ function upload-server-tars() {
279284
fi
280285

281286
SERVER_BINARY_TAR_HASH=$(sha1sum-file "${SERVER_BINARY_TAR}")
287+
288+
if [[ -n "${NODE_BINARY_TAR:-}" ]]; then
289+
NODE_BINARY_TAR_HASH=$(sha1sum-file "${NODE_BINARY_TAR}")
290+
fi
282291
if [[ -n "${KUBE_MANIFESTS_TAR:-}" ]]; then
283292
KUBE_MANIFESTS_TAR_HASH=$(sha1sum-file "${KUBE_MANIFESTS_TAR}")
284293
fi
285294

286295
local server_binary_tar_urls=()
296+
local node_binary_tar_urls=()
287297
local kube_manifest_tar_urls=()
288298

289299
for region in "${PREFERRED_REGION[@]}"; do
@@ -301,12 +311,20 @@ function upload-server-tars() {
301311

302312
local staging_path="${staging_bucket}/${INSTANCE_PREFIX}-devel"
303313

304-
echo "+++ Staging server tars to Google Storage: ${staging_path}"
314+
echo "+++ Staging tars to Google Storage: ${staging_path}"
305315
local server_binary_gs_url="${staging_path}/${SERVER_BINARY_TAR##*/}"
306316
copy-to-staging "${staging_path}" "${server_binary_gs_url}" "${SERVER_BINARY_TAR}" "${SERVER_BINARY_TAR_HASH}"
307317

318+
if [[ -n "${NODE_BINARY_TAR:-}" ]]; then
319+
local node_binary_gs_url="${staging_path}/${NODE_BINARY_TAR##*/}"
320+
copy-to-staging "${staging_path}" "${node_binary_gs_url}" "${NODE_BINARY_TAR}" "${NODE_BINARY_TAR_HASH}"
321+
fi
322+
308323
# Convert from gs:// URL to an https:// URL
309324
server_binary_tar_urls+=("${server_binary_gs_url/gs:\/\//https://storage.googleapis.com/}")
325+
if [[ -n "${NODE_BINARY_TAR:-}" ]]; then
326+
node_binary_tar_urls+=("${node_binary_gs_url/gs:\/\//https://storage.googleapis.com/}")
327+
fi
310328
if [[ -n "${KUBE_MANIFESTS_TAR:-}" ]]; then
311329
local kube_manifests_gs_url="${staging_path}/${KUBE_MANIFESTS_TAR##*/}"
312330
copy-to-staging "${staging_path}" "${kube_manifests_gs_url}" "${KUBE_MANIFESTS_TAR}" "${KUBE_MANIFESTS_TAR_HASH}"
@@ -316,6 +334,9 @@ function upload-server-tars() {
316334
done
317335

318336
SERVER_BINARY_TAR_URL=$(join_csv "${server_binary_tar_urls[@]}")
337+
if [[ -n "${NODE_BINARY_TAR:-}" ]]; then
338+
NODE_BINARY_TAR_URL=$(join_csv "${node_binary_tar_urls[@]}")
339+
fi
319340
if [[ -n "${KUBE_MANIFESTS_TAR:-}" ]]; then
320341
KUBE_MANIFESTS_TAR_URL=$(join_csv "${kube_manifests_tar_urls[@]}")
321342
fi
@@ -436,7 +457,7 @@ function tars_from_version() {
436457

437458
if [[ -z "${KUBE_VERSION-}" ]]; then
438459
find-release-tars
439-
upload-server-tars
460+
upload-tars
440461
elif [[ ${KUBE_VERSION} =~ ${KUBE_RELEASE_VERSION_REGEX} ]]; then
441462
SERVER_BINARY_TAR_URL="https://storage.googleapis.com/kubernetes-release/release/${KUBE_VERSION}/kubernetes-server-linux-amd64.tar.gz"
442463
# TODO: Clean this up.
@@ -1756,7 +1777,7 @@ function kube-up() {
17561777

17571778
# Make sure we have the tar files staged on Google Storage
17581779
find-release-tars
1759-
upload-server-tars
1780+
upload-tars
17601781

17611782
# ensure that environmental variables specifying number of migs to create
17621783
set_num_migs

cluster/get-kube-binaries.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ DOWNLOAD_URL_PREFIX="${KUBERNETES_RELEASE_URL}/${KUBE_VERSION}"
161161
SERVER_PLATFORM="linux"
162162
SERVER_ARCH="${KUBERNETES_SERVER_ARCH:-amd64}"
163163
SERVER_TAR="kubernetes-server-${SERVER_PLATFORM}-${SERVER_ARCH}.tar.gz"
164+
if [[ -n "${KUBERNETES_NODE_PLATFORM-}" || -n "${KUBERNETES_NODE_ARCH-}" ]]; then
165+
NODE_PLATFORM="${KUBERNETES_NODE_PLATFORM:${SERVER_PLATFORM}}"
166+
NODE_ARCH="${KUBERNETES_NODE_ARCH:${SERVER_ARCH}}"
167+
NODE_TAR="kubernetes-node-${NODE_PLATFORM}-${NODE_ARCH}.tar.gz"
168+
fi
164169

165170
detect_client_info
166171
CLIENT_TAR="kubernetes-client-${CLIENT_PLATFORM}-${CLIENT_ARCH}.tar.gz"
@@ -186,6 +191,12 @@ if [[ ! -x "${KUBE_ROOT}/platforms/${CLIENT_PLATFORM}/${CLIENT_ARCH}/kubectl" ]]
186191
echo "Will download and extract ${CLIENT_TAR} from ${DOWNLOAD_URL_PREFIX}"
187192
fi
188193

194+
DOWNLOAD_NODE_TAR=false
195+
if [[ -n "${NODE_TAR:-}" ]]; then
196+
DOWNLOAD_NODE_TAR=true
197+
echo "Will download and extract ${NODE_TAR} from ${DOWNLOAD_URL_PREFIX}"
198+
fi
199+
189200
TESTS_TAR="kubernetes-test.tar.gz"
190201
DOWNLOAD_TESTS_TAR=false
191202
if [[ -n "${KUBERNETES_DOWNLOAD_TESTS-}" ]]; then
@@ -213,6 +224,10 @@ if "${DOWNLOAD_SERVER_TAR}"; then
213224
download_tarball "${KUBE_ROOT}/server" "${SERVER_TAR}"
214225
fi
215226

227+
if "${DOWNLOAD_NODE_TAR}"; then
228+
download_tarball "${KUBE_ROOT}/node" "${NODE_TAR}"
229+
fi
230+
216231
if "${DOWNLOAD_CLIENT_TAR}"; then
217232
download_tarball "${KUBE_ROOT}/client" "${CLIENT_TAR}"
218233
extract_arch_tarball "${KUBE_ROOT}/client/${CLIENT_TAR}" "${CLIENT_PLATFORM}" "${CLIENT_ARCH}"

cluster/get-kube.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,23 @@
3737
# * arm
3838
# * arm64
3939
#
40+
# Set KUBERNETES_NODE_PLATFORM to choose the platform for which to download
41+
# the node binaries. If none of KUBERNETES_NODE_PLATFORM and
42+
# KUBERNETES_NODE_ARCH is set, no node binaries will be downloaded. If only
43+
# one of the two is set, the other will be defaulted to the
44+
# KUBERNETES_SERVER_PLATFORM/ARCH.
45+
# * linux
46+
# * windows
47+
#
48+
# Set KUBERNETES_NODE_ARCH to choose the node architecture to download the
49+
# node binaries. If none of KUBERNETES_NODE_PLATFORM and
50+
# KUBERNETES_NODE_ARCH is set, no node binaries will be downloaded. If only
51+
# one of the two is set, the other will be defaulted to the
52+
# KUBERNETES_SERVER_PLATFORM/ARCH.
53+
# * amd64 [default]
54+
# * arm
55+
# * arm64
56+
#
4057
# Set KUBERNETES_SKIP_DOWNLOAD to skip downloading a release.
4158
# Set KUBERNETES_SKIP_CONFIRM to skip the installation confirmation prompt.
4259
# Set KUBERNETES_SKIP_CREATE_CLUSTER to skip starting a cluster.

0 commit comments

Comments
 (0)