mirror of https://github.com/k3s-io/k3s
Merge pull request #36292 from jlowdermilk/no-gcloud-update
Automatic merge from submit-queue Don't update gcloud in cluster/*/util.sh **What this PR does / why we need it**: Removes automatic gcloud update commands from `cluster/gce/util.sh`, `cluster/gke/util.sh`. Setting env `KUBE_PROMPT_FOR_UPDATE=y` will update required components, otherwise it will only verify that required components are present and at a minimum required version. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #35834 **Special notes for your reviewer**: Inline python is nasty but I *really* don't want to do version comparison in bash. Open to other suggestions for verifying required version of gcloud components. cc @kubernetes/sig-cluster-lifecycle, @kubernetes/sig-testing **Release note**: <!-- Steps to write your release note: 1. Use the release-note-* labels to set the release note state (if you have access) 2. Enter your extended release note in the below block; leaving it blank means using the PR title as the release note. If no release note is required, just write `NONE`. --> ```release-note `kube-up.sh`/`kube-down.sh` no longer force update gcloud for provider=gce|gke. ```pull/6/head
commit
3dac320640
|
@ -963,3 +963,42 @@ function parse-master-env() {
|
|||
KUBELET_CERT_BASE64=$(get-env-val "${master_env}" "KUBELET_CERT")
|
||||
KUBELET_KEY_BASE64=$(get-env-val "${master_env}" "KUBELET_KEY")
|
||||
}
|
||||
|
||||
# Update or verify required gcloud components are installed
|
||||
# at minimum required version.
|
||||
# Assumed vars
|
||||
# KUBE_PROMPT_FOR_UPDATE
|
||||
function update-or-verify-gcloud() {
|
||||
local sudo_prefix=""
|
||||
if [ ! -w $(dirname `which gcloud`) ]; then
|
||||
sudo_prefix="sudo"
|
||||
fi
|
||||
# update and install components as needed
|
||||
if [[ "${KUBE_PROMPT_FOR_UPDATE}" == "y" ]]; then
|
||||
${sudo_prefix} gcloud ${gcloud_prompt:-} components install alpha
|
||||
${sudo_prefix} gcloud ${gcloud_prompt:-} components install beta
|
||||
${sudo_prefix} gcloud ${gcloud_prompt:-} components update
|
||||
else
|
||||
local version=$(${sudo_prefix} gcloud version --format=json)
|
||||
python -c'
|
||||
import json,sys
|
||||
from distutils import version
|
||||
|
||||
minVersion = version.LooseVersion("1.3.0")
|
||||
required = [ "alpha", "beta", "core" ]
|
||||
data = json.loads(sys.argv[1])
|
||||
rel = data.get("Google Cloud SDK")
|
||||
if rel != "HEAD" and version.LooseVersion(rel) < minVersion:
|
||||
print "gcloud version out of date ( < %s )" % minVersion
|
||||
exit(1)
|
||||
missing = []
|
||||
for c in required:
|
||||
if not data.get(c):
|
||||
missing += [c]
|
||||
if missing:
|
||||
for c in missing:
|
||||
print ("missing required gcloud component \"{0}\"".format(c))
|
||||
exit(1)
|
||||
' """${version}"""
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -80,8 +80,7 @@ NODE_TAGS="${NODE_TAG}"
|
|||
|
||||
ALLOCATE_NODE_CIDRS=true
|
||||
|
||||
KUBE_PROMPT_FOR_UPDATE=y
|
||||
KUBE_SKIP_UPDATE=${KUBE_SKIP_UPDATE-"n"}
|
||||
KUBE_PROMPT_FOR_UPDATE=${KUBE_PROMPT_FOR_UPDATE:-"n"}
|
||||
# How long (in seconds) to wait for cluster initialization.
|
||||
KUBE_CLUSTER_INITIALIZATION_TIMEOUT=${KUBE_CLUSTER_INITIALIZATION_TIMEOUT:-300}
|
||||
|
||||
|
@ -99,12 +98,10 @@ function verify-prereqs() {
|
|||
local cmd
|
||||
for cmd in gcloud gsutil; do
|
||||
if ! which "${cmd}" >/dev/null; then
|
||||
local resp
|
||||
local resp="n"
|
||||
if [[ "${KUBE_PROMPT_FOR_UPDATE}" == "y" ]]; then
|
||||
echo "Can't find ${cmd} in PATH. Do you wish to install the Google Cloud SDK? [Y/n]"
|
||||
read resp
|
||||
else
|
||||
resp="y"
|
||||
fi
|
||||
if [[ "${resp}" != "n" && "${resp}" != "N" ]]; then
|
||||
curl https://sdk.cloud.google.com | bash
|
||||
|
@ -116,20 +113,7 @@ function verify-prereqs() {
|
|||
fi
|
||||
fi
|
||||
done
|
||||
if [[ "${KUBE_SKIP_UPDATE}" == "y" ]]; then
|
||||
return
|
||||
fi
|
||||
# update and install components as needed
|
||||
if [[ "${KUBE_PROMPT_FOR_UPDATE}" != "y" ]]; then
|
||||
gcloud_prompt="-q"
|
||||
fi
|
||||
local sudo_prefix=""
|
||||
if [ ! -w $(dirname `which gcloud`) ]; then
|
||||
sudo_prefix="sudo"
|
||||
fi
|
||||
${sudo_prefix} gcloud ${gcloud_prompt:-} components install alpha || true
|
||||
${sudo_prefix} gcloud ${gcloud_prompt:-} components install beta || true
|
||||
${sudo_prefix} gcloud ${gcloud_prompt:-} components update || true
|
||||
update-or-verify-gcloud
|
||||
}
|
||||
|
||||
# Create a temp dir that'll be deleted at the end of this bash session.
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
|
||||
# Uses the config file specified in $KUBE_CONFIG_FILE, or defaults to config-default.sh
|
||||
|
||||
KUBE_PROMPT_FOR_UPDATE=y
|
||||
KUBE_SKIP_UPDATE=${KUBE_SKIP_UPDATE-"n"}
|
||||
KUBE_PROMPT_FOR_UPDATE=${KUBE_PROMPT_FOR_UPDATE:-"n"}
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
||||
source "${KUBE_ROOT}/cluster/gke/${KUBE_CONFIG_FILE:-config-default.sh}"
|
||||
source "${KUBE_ROOT}/cluster/common.sh"
|
||||
|
@ -97,8 +96,6 @@ function verify-prereqs() {
|
|||
if [[ "${KUBE_PROMPT_FOR_UPDATE}" == "y" ]]; then
|
||||
echo "Can't find gcloud in PATH. Do you wish to install the Google Cloud SDK? [Y/n]"
|
||||
read resp
|
||||
else
|
||||
resp="y"
|
||||
fi
|
||||
if [[ "${resp}" != "n" && "${resp}" != "N" ]]; then
|
||||
curl https://sdk.cloud.google.com | bash
|
||||
|
@ -109,21 +106,7 @@ function verify-prereqs() {
|
|||
exit 1
|
||||
fi
|
||||
fi
|
||||
if [[ "${KUBE_SKIP_UPDATE}" == "y" ]]; then
|
||||
return
|
||||
fi
|
||||
# update and install components as needed
|
||||
if [[ "${KUBE_PROMPT_FOR_UPDATE}" != "y" ]]; then
|
||||
gcloud_prompt="-q"
|
||||
fi
|
||||
local sudo_prefix=""
|
||||
if [ ! -w $(dirname `which gcloud`) ]; then
|
||||
sudo_prefix="sudo"
|
||||
fi
|
||||
${sudo_prefix} gcloud ${gcloud_prompt:-} components install alpha || true
|
||||
${sudo_prefix} gcloud ${gcloud_prompt:-} components install beta || true
|
||||
${sudo_prefix} gcloud ${gcloud_prompt:-} components install kubectl|| true
|
||||
${sudo_prefix} gcloud ${gcloud_prompt:-} components update || true
|
||||
update-or-verify-gcloud
|
||||
}
|
||||
|
||||
# Validate a kubernetes cluster
|
||||
|
|
Loading…
Reference in New Issue