mirror of https://github.com/k3s-io/k3s
Automatically download missing kube binaries in kube-up/kube-down.
parent
641654836b
commit
cbee65a6d2
|
@ -20,7 +20,7 @@ set -o errexit
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
|
KUBE_ROOT=$(cd $(dirname "${BASH_SOURCE}")/.. && pwd)
|
||||||
|
|
||||||
DEFAULT_KUBECONFIG="${HOME}/.kube/config"
|
DEFAULT_KUBECONFIG="${HOME}/.kube/config"
|
||||||
|
|
||||||
|
@ -1008,3 +1008,36 @@ if missing:
|
||||||
' """${version}"""
|
' """${version}"""
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check whether required client and server binaries exist, prompting to download
|
||||||
|
# if missing.
|
||||||
|
# If KUBERNETES_SKIP_CONFIRM is set to y, we'll automatically download binaries
|
||||||
|
# without prompting.
|
||||||
|
function verify-kube-binaries() {
|
||||||
|
local missing_binaries=false
|
||||||
|
if ! "${KUBE_ROOT}/cluster/kubectl.sh" version --client >&/dev/null; then
|
||||||
|
echo "!!! kubectl appears to be broken or missing"
|
||||||
|
missing_binaries=true
|
||||||
|
fi
|
||||||
|
if ! $(find-release-tars); then
|
||||||
|
missing_binaries=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! "${missing_binaries}"; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
get_binaries_script="${KUBE_ROOT}/cluster/get-kube-binaries.sh"
|
||||||
|
local resp="y"
|
||||||
|
if [[ ! "${KUBERNETES_SKIP_CONFIRM:-n}" =~ ^[yY]$ ]]; then
|
||||||
|
echo "Required binaries appear to be missing. Do you wish to download them? [Y/n]"
|
||||||
|
read resp
|
||||||
|
fi
|
||||||
|
if [[ "${resp}" =~ ^[nN]$ ]]; then
|
||||||
|
echo "You must download binaries to continue. You can use "
|
||||||
|
echo " ${get_binaries_script}"
|
||||||
|
echo "to do this for your automatically."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
"${get_binaries_script}"
|
||||||
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ KUBERNETES_RELEASE_URL="${KUBERNETES_RELEASE_URL:-https://storage.googleapis.com
|
||||||
function detect_kube_release() {
|
function detect_kube_release() {
|
||||||
if [[ ! -e "${KUBE_ROOT}/version" ]]; then
|
if [[ ! -e "${KUBE_ROOT}/version" ]]; then
|
||||||
echo "Can't determine Kubernetes release." >&2
|
echo "Can't determine Kubernetes release." >&2
|
||||||
echo "This script should only be run from a prebuilt Kubernetes release." >&2
|
echo "${BASH_SOURCE} should only be run from a prebuilt Kubernetes release." >&2
|
||||||
echo "Did you mean to use get-kube.sh instead?" >&2
|
echo "Did you mean to use get-kube.sh instead?" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -162,8 +162,8 @@ detect_client_info
|
||||||
CLIENT_TAR="kubernetes-client-${CLIENT_PLATFORM}-${CLIENT_ARCH}.tar.gz"
|
CLIENT_TAR="kubernetes-client-${CLIENT_PLATFORM}-${CLIENT_ARCH}.tar.gz"
|
||||||
|
|
||||||
echo "Kubernetes release: ${KUBERNETES_RELEASE}"
|
echo "Kubernetes release: ${KUBERNETES_RELEASE}"
|
||||||
echo "Server: ${SERVER_PLATFORM}/${SERVER_ARCH}"
|
echo "Server: ${SERVER_PLATFORM}/${SERVER_ARCH} (to override, set KUBERNETES_SERVER_ARCH)"
|
||||||
echo "Client: ${CLIENT_PLATFORM}/${CLIENT_ARCH}"
|
echo "Client: ${CLIENT_PLATFORM}/${CLIENT_ARCH} (autodetected)"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# TODO: remove this check and default to true when we stop shipping server
|
# TODO: remove this check and default to true when we stop shipping server
|
||||||
|
@ -201,7 +201,7 @@ if [[ -z "${KUBERNETES_SKIP_CONFIRM-}" ]]; then
|
||||||
read confirm
|
read confirm
|
||||||
if [[ "${confirm}" =~ ^[nN]$ ]]; then
|
if [[ "${confirm}" =~ ^[nN]$ ]]; then
|
||||||
echo "Aborting."
|
echo "Aborting."
|
||||||
exit 0
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ source "${KUBE_ROOT}/cluster/kube-util.sh"
|
||||||
echo "Bringing down cluster using provider: $KUBERNETES_PROVIDER"
|
echo "Bringing down cluster using provider: $KUBERNETES_PROVIDER"
|
||||||
|
|
||||||
verify-prereqs
|
verify-prereqs
|
||||||
|
verify-kube-binaries
|
||||||
kube-down
|
kube-down
|
||||||
|
|
||||||
echo "Done"
|
echo "Done"
|
||||||
|
|
|
@ -69,6 +69,7 @@ if [[ "${push_to_master}" == "true" ]] && [[ "${push_to_node}" == "true" ]]; the
|
||||||
fi
|
fi
|
||||||
|
|
||||||
verify-prereqs
|
verify-prereqs
|
||||||
|
verify-kube-binaries
|
||||||
KUBE_VERSION=${1-}
|
KUBE_VERSION=${1-}
|
||||||
|
|
||||||
if [[ "${push_to_master}" == "false" ]] && [[ "${push_to_node}" == "false" ]]; then
|
if [[ "${push_to_master}" == "false" ]] && [[ "${push_to_node}" == "false" ]]; then
|
||||||
|
|
|
@ -41,6 +41,8 @@ fi
|
||||||
|
|
||||||
echo "... calling verify-prereqs" >&2
|
echo "... calling verify-prereqs" >&2
|
||||||
verify-prereqs
|
verify-prereqs
|
||||||
|
echo "... calling verify-kube-binaries" >&2
|
||||||
|
verify-kube-binaries
|
||||||
|
|
||||||
if [[ "${KUBE_STAGE_IMAGES:-}" == "true" ]]; then
|
if [[ "${KUBE_STAGE_IMAGES:-}" == "true" ]]; then
|
||||||
echo "... staging images" >&2
|
echo "... staging images" >&2
|
||||||
|
|
Loading…
Reference in New Issue