From f87fcf6ce8a324c8130da96ef5017b4b41fec49c Mon Sep 17 00:00:00 2001 From: Yu-Ju Hong Date: Mon, 10 Dec 2018 15:07:02 -0800 Subject: [PATCH 1/2] GCE: enable downloading and staging of the node binaries Currently, only kubernetes-server-linux-.tar.gz will be downloaded and staged for tests. It is not possible to test a cluster where the platform/arch of the nodes differs from that of the master control-plane. This changes allows downloading and staging node binaries, in addition to the existing server binaries. --- cluster/gce/util.sh | 29 +++++++++++++++++++++++++---- cluster/get-kube-binaries.sh | 15 +++++++++++++++ cluster/get-kube.sh | 11 +++++++++++ 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/cluster/gce/util.sh b/cluster/gce/util.sh index c6129198ce..c907d1dee7 100755 --- a/cluster/gce/util.sh +++ b/cluster/gce/util.sh @@ -248,16 +248,21 @@ function set-preferred-region() { # Assumed vars: # PROJECT # SERVER_BINARY_TAR +# NODE_BINARY_TAR (optional) # KUBE_MANIFESTS_TAR # ZONE # Vars set: # SERVER_BINARY_TAR_URL # SERVER_BINARY_TAR_HASH +# NODE_BINARY_TAR_URL +# NODE_BINARY_TAR_HASH # KUBE_MANIFESTS_TAR_URL # KUBE_MANIFESTS_TAR_HASH -function upload-server-tars() { +function upload-tars() { SERVER_BINARY_TAR_URL= SERVER_BINARY_TAR_HASH= + NODE_BINARY_TAR_URL= + NODE_BINARY_TAR_HASH= KUBE_MANIFESTS_TAR_URL= KUBE_MANIFESTS_TAR_HASH= @@ -279,11 +284,16 @@ function upload-server-tars() { fi SERVER_BINARY_TAR_HASH=$(sha1sum-file "${SERVER_BINARY_TAR}") + + if [[ -n "${NODE_BINARY_TAR:-}" ]]; then + NODE_BINARY_TAR_HASH=$(sha1sum-file "${NODE_BINARY_TAR}") + fi if [[ -n "${KUBE_MANIFESTS_TAR:-}" ]]; then KUBE_MANIFESTS_TAR_HASH=$(sha1sum-file "${KUBE_MANIFESTS_TAR}") fi local server_binary_tar_urls=() + local node_binary_tar_urls=() local kube_manifest_tar_urls=() for region in "${PREFERRED_REGION[@]}"; do @@ -301,12 +311,20 @@ function upload-server-tars() { local staging_path="${staging_bucket}/${INSTANCE_PREFIX}-devel" - echo "+++ Staging server tars to Google Storage: ${staging_path}" + echo "+++ Staging tars to Google Storage: ${staging_path}" local server_binary_gs_url="${staging_path}/${SERVER_BINARY_TAR##*/}" copy-to-staging "${staging_path}" "${server_binary_gs_url}" "${SERVER_BINARY_TAR}" "${SERVER_BINARY_TAR_HASH}" + if [[ -n "${NODE_BINARY_TAR:-}" ]]; then + local node_binary_gs_url="${staging_path}/${NODE_BINARY_TAR##*/}" + copy-to-staging "${staging_path}" "${node_binary_gs_url}" "${NODE_BINARY_TAR}" "${NODE_BINARY_TAR_HASH}" + fi + # Convert from gs:// URL to an https:// URL server_binary_tar_urls+=("${server_binary_gs_url/gs:\/\//https://storage.googleapis.com/}") + if [[ -n "${NODE_BINARY_TAR:-}" ]]; then + node_binary_tar_urls+=("${node_binary_gs_url/gs:\/\//https://storage.googleapis.com/}") + fi if [[ -n "${KUBE_MANIFESTS_TAR:-}" ]]; then local kube_manifests_gs_url="${staging_path}/${KUBE_MANIFESTS_TAR##*/}" copy-to-staging "${staging_path}" "${kube_manifests_gs_url}" "${KUBE_MANIFESTS_TAR}" "${KUBE_MANIFESTS_TAR_HASH}" @@ -316,6 +334,9 @@ function upload-server-tars() { done SERVER_BINARY_TAR_URL=$(join_csv "${server_binary_tar_urls[@]}") + if [[ -n "${NODE_BINARY_TAR:-}" ]]; then + NODE_BINARY_TAR_URL=$(join_csv "${node_binary_tar_urls[@]}") + fi if [[ -n "${KUBE_MANIFESTS_TAR:-}" ]]; then KUBE_MANIFESTS_TAR_URL=$(join_csv "${kube_manifests_tar_urls[@]}") fi @@ -436,7 +457,7 @@ function tars_from_version() { if [[ -z "${KUBE_VERSION-}" ]]; then find-release-tars - upload-server-tars + upload-tars elif [[ ${KUBE_VERSION} =~ ${KUBE_RELEASE_VERSION_REGEX} ]]; then SERVER_BINARY_TAR_URL="https://storage.googleapis.com/kubernetes-release/release/${KUBE_VERSION}/kubernetes-server-linux-amd64.tar.gz" # TODO: Clean this up. @@ -1756,7 +1777,7 @@ function kube-up() { # Make sure we have the tar files staged on Google Storage find-release-tars - upload-server-tars + upload-tars # ensure that environmental variables specifying number of migs to create set_num_migs diff --git a/cluster/get-kube-binaries.sh b/cluster/get-kube-binaries.sh index b78cb8d3bc..0664e7a0ab 100755 --- a/cluster/get-kube-binaries.sh +++ b/cluster/get-kube-binaries.sh @@ -161,6 +161,11 @@ DOWNLOAD_URL_PREFIX="${KUBERNETES_RELEASE_URL}/${KUBE_VERSION}" SERVER_PLATFORM="linux" SERVER_ARCH="${KUBERNETES_SERVER_ARCH:-amd64}" SERVER_TAR="kubernetes-server-${SERVER_PLATFORM}-${SERVER_ARCH}.tar.gz" +if [[ -n "${KUBERNETES_NODE_PLATFORM-}" ]]; then + NODE_PLATFORM="${KUBERNETES_NODE_PLATFORM}" + NODE_ARCH="${KUBERNETES_NODE_ARCH:-amd64}" + NODE_TAR="kubernetes-node-${NODE_PLATFORM}-${NODE_ARCH}.tar.gz" +fi detect_client_info CLIENT_TAR="kubernetes-client-${CLIENT_PLATFORM}-${CLIENT_ARCH}.tar.gz" @@ -186,6 +191,12 @@ if [[ ! -x "${KUBE_ROOT}/platforms/${CLIENT_PLATFORM}/${CLIENT_ARCH}/kubectl" ]] echo "Will download and extract ${CLIENT_TAR} from ${DOWNLOAD_URL_PREFIX}" fi +DOWNLOAD_NODE_TAR=false +if [[ -n "${NODE_TAR:-}" ]]; then + DOWNLOAD_NODE_TAR=true + echo "Will download and extract ${NODE_TAR} from ${DOWNLOAD_URL_PREFIX}" +fi + TESTS_TAR="kubernetes-test.tar.gz" DOWNLOAD_TESTS_TAR=false if [[ -n "${KUBERNETES_DOWNLOAD_TESTS-}" ]]; then @@ -213,6 +224,10 @@ if "${DOWNLOAD_SERVER_TAR}"; then download_tarball "${KUBE_ROOT}/server" "${SERVER_TAR}" fi +if "${DOWNLOAD_NODE_TAR}"; then + download_tarball "${KUBE_ROOT}/node" "${NODE_TAR}" +fi + if "${DOWNLOAD_CLIENT_TAR}"; then download_tarball "${KUBE_ROOT}/client" "${CLIENT_TAR}" extract_arch_tarball "${KUBE_ROOT}/client/${CLIENT_TAR}" "${CLIENT_PLATFORM}" "${CLIENT_ARCH}" diff --git a/cluster/get-kube.sh b/cluster/get-kube.sh index b733bd2187..9468c4105e 100755 --- a/cluster/get-kube.sh +++ b/cluster/get-kube.sh @@ -37,6 +37,17 @@ # * arm # * arm64 # +# Set KUBERNETES_NODE_PLATFORM to choose the platform for which to download +# the node binaries. If not set (the default) no node binaries will be +# downloaded. The options are: +# * linux +# * windows +# +# Set KUBERNETES_NODE_ARCH to choose the node architecture to download: +# * amd64 [default] +# * arm +# * arm64 +# # Set KUBERNETES_SKIP_DOWNLOAD to skip downloading a release. # Set KUBERNETES_SKIP_CONFIRM to skip the installation confirmation prompt. # Set KUBERNETES_SKIP_CREATE_CLUSTER to skip starting a cluster. From 62db510fe0067e9c8dcdf734fe19a5f681fc17a6 Mon Sep 17 00:00:00 2001 From: Yu-Ju Hong Date: Wed, 19 Dec 2018 10:25:34 -0800 Subject: [PATCH 2/2] Allow setting KUBERNETES_NODE_ARCH to download node binaries --- cluster/get-kube-binaries.sh | 6 +++--- cluster/get-kube.sh | 12 +++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cluster/get-kube-binaries.sh b/cluster/get-kube-binaries.sh index 0664e7a0ab..70e18a6a84 100755 --- a/cluster/get-kube-binaries.sh +++ b/cluster/get-kube-binaries.sh @@ -161,9 +161,9 @@ DOWNLOAD_URL_PREFIX="${KUBERNETES_RELEASE_URL}/${KUBE_VERSION}" SERVER_PLATFORM="linux" SERVER_ARCH="${KUBERNETES_SERVER_ARCH:-amd64}" SERVER_TAR="kubernetes-server-${SERVER_PLATFORM}-${SERVER_ARCH}.tar.gz" -if [[ -n "${KUBERNETES_NODE_PLATFORM-}" ]]; then - NODE_PLATFORM="${KUBERNETES_NODE_PLATFORM}" - NODE_ARCH="${KUBERNETES_NODE_ARCH:-amd64}" +if [[ -n "${KUBERNETES_NODE_PLATFORM-}" || -n "${KUBERNETES_NODE_ARCH-}" ]]; then + NODE_PLATFORM="${KUBERNETES_NODE_PLATFORM:${SERVER_PLATFORM}}" + NODE_ARCH="${KUBERNETES_NODE_ARCH:${SERVER_ARCH}}" NODE_TAR="kubernetes-node-${NODE_PLATFORM}-${NODE_ARCH}.tar.gz" fi diff --git a/cluster/get-kube.sh b/cluster/get-kube.sh index 9468c4105e..3c2180b5aa 100755 --- a/cluster/get-kube.sh +++ b/cluster/get-kube.sh @@ -38,12 +38,18 @@ # * arm64 # # Set KUBERNETES_NODE_PLATFORM to choose the platform for which to download -# the node binaries. If not set (the default) no node binaries will be -# downloaded. The options are: +# the node binaries. If none of KUBERNETES_NODE_PLATFORM and +# KUBERNETES_NODE_ARCH is set, no node binaries will be downloaded. If only +# one of the two is set, the other will be defaulted to the +# KUBERNETES_SERVER_PLATFORM/ARCH. # * linux # * windows # -# Set KUBERNETES_NODE_ARCH to choose the node architecture to download: +# Set KUBERNETES_NODE_ARCH to choose the node architecture to download the +# node binaries. If none of KUBERNETES_NODE_PLATFORM and +# KUBERNETES_NODE_ARCH is set, no node binaries will be downloaded. If only +# one of the two is set, the other will be defaulted to the +# KUBERNETES_SERVER_PLATFORM/ARCH. # * amd64 [default] # * arm # * arm64