Use gsutil to download kube binaries and release

Default to using gsutil to download kube artifacts to avoid network
interruptions.

Signed-off-by: Eddie Zaneski <eddiezane@gmail.com>
This commit is contained in:
Eddie Zaneski 2020-10-15 16:23:58 -06:00
parent fd5d61060a
commit cebb1b3393
No known key found for this signature in database
GPG Key ID: 6B264594A44BB3EF
2 changed files with 9 additions and 4 deletions

View File

@ -156,7 +156,10 @@ function download_tarball() {
fi
url="${DOWNLOAD_URL_PREFIX}/${file}"
mkdir -p "${download_path}"
if [[ $(which curl) ]]; then
if [[ $(which gsutil) ]] && [[ "$url" =~ ^https://storage.googleapis.com/.* ]]; then
gsutil cp "${url//'https://storage.googleapis.com/'/'gs://'}" "${download_path}/${file}"
elif [[ $(which curl) ]]; then
# if the url belongs to GCS API we should use oauth2_token in the headers
curl_headers=""
if { [[ "${KUBERNETES_PROVIDER:-gce}" == "gce" ]] || [[ "${KUBERNETES_PROVIDER}" == "gke" ]] ; } &&
@ -167,7 +170,7 @@ function download_tarball() {
elif [[ $(which wget) ]]; then
wget "${url}" -O "${download_path}/${file}"
else
echo "Couldn't find curl or wget. Bailing out." >&2
echo "Couldn't find gsutil, curl, or wget. Bailing out." >&2
exit 4
fi
echo

View File

@ -240,7 +240,9 @@ if [[ -z "${KUBERNETES_SKIP_CONFIRM-}" ]]; then
fi
if "${need_download}"; then
if [[ $(which curl) ]]; then
if [[ $(which gsutil) ]] && [[ "$kubernetes_tar_url" =~ ^https://storage.googleapis.com/.* ]]; then
gsutil cp "${kubernetes_tar_url//'https://storage.googleapis.com/'/'gs://'}" "${file}"
elif [[ $(which curl) ]]; then
# if the url belongs to GCS API we should use oauth2_token in the headers
curl_headers=""
if { [[ "${KUBERNETES_PROVIDER:-gce}" == "gce" ]] || [[ "${KUBERNETES_PROVIDER}" == "gke" ]] ; } &&
@ -251,7 +253,7 @@ if "${need_download}"; then
elif [[ $(which wget) ]]; then
wget "${kubernetes_tar_url}"
else
echo "Couldn't find curl or wget. Bailing out."
echo "Couldn't find gsutil, curl, or wget. Bailing out."
exit 1
fi
fi