Extend the get-cluster.sh script to use sudo if necessary.

pull/6/head
Brendan Burns 2015-04-21 16:11:15 -07:00
parent cf27fd12c1
commit 42121d1809
2 changed files with 20 additions and 5 deletions

View File

@ -25,6 +25,7 @@ source "${KUBE_ROOT}/cluster/common.sh"
NODE_INSTANCE_PREFIX="${INSTANCE_PREFIX}-minion"
KUBE_PROMPT_FOR_UPDATE=y
KUBE_SKIP_UPDATE=${KUBE_SKIP_UPDATE-"n"}
# Verify prereqs
function verify-prereqs {
@ -48,12 +49,19 @@ 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
gcloud ${gcloud_prompt:-} components update preview || true
gcloud ${gcloud_prompt:-} components update || true
if [ ! -w $(dirname `which gcloud`) ]; then
sudo_prefix="sudo"
fi
${sudo_prefix} gcloud ${gcloud_prompt:-} components update preview || true
${sudo_prefix} gcloud ${gcloud_prompt:-} components update alpha || true
${sudo_prefix} gcloud ${gcloud_prompt:-} components update || true
}
# Create a temp dir that'll be deleted at the end of this bash session.

View File

@ -20,6 +20,7 @@
# config-default.sh.
KUBE_PROMPT_FOR_UPDATE=y
KUBE_SKIP_UPDATE=${KUBE_SKIP_UPDATE-"n"}
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
source "${KUBE_ROOT}/cluster/gke/${KUBE_CONFIG_FILE:-config-default.sh}"
@ -86,13 +87,19 @@ 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
gcloud ${gcloud_prompt:-} components update preview || true
gcloud ${gcloud_prompt:-} components update alpha || true
gcloud ${gcloud_prompt:-} components update || true
if [ ! -w $(dirname `which gcloud`) ]; then
sudo_prefix="sudo"
fi
${sudo_prefix} gcloud ${gcloud_prompt:-} components update preview || true
${sudo_prefix} gcloud ${gcloud_prompt:-} components update alpha|| true
${sudo_prefix} gcloud ${gcloud_prompt:-} components update || true
}
# Instantiate a kubernetes cluster