Allow choice of os/arch when downloading client

This patch introduces `KUBERNETES_CLIENT_OS` and
`KUBERNETES_CLIENT_ARCH` to the script `cluster/get-kube-binaries.sh` in
order to download a client that is not the OS/Arch of the host on which
the script is executing.
k3s-v1.15.3
akutz 2019-03-04 10:23:04 -06:00
parent ec1d83b82d
commit 020dc47073
1 changed files with 70 additions and 42 deletions

View File

@ -29,6 +29,21 @@
# * ppc64le # * ppc64le
# * s390x # * s390x
# #
# Set KUBERNETES_CLIENT_OS to choose the client OS to download:
# * current OS [default]
# * linux
# * darwin
# * windows
#
# Set KUBERNETES_CLIENT_ARCH to choose the client architecture to download:
# * current architecture [default]
# * amd64
# * arm
# * arm64
# * ppc64le
# * s390x
# * windows
#
# Set KUBERNETES_SKIP_CONFIRM to skip the installation confirmation prompt. # Set KUBERNETES_SKIP_CONFIRM to skip the installation confirmation prompt.
# Set KUBERNETES_RELEASE_URL to choose where to download binaries from. # Set KUBERNETES_RELEASE_URL to choose where to download binaries from.
# (Defaults to https://storage.googleapis.com/kubernetes-release/release). # (Defaults to https://storage.googleapis.com/kubernetes-release/release).
@ -59,48 +74,57 @@ function detect_kube_release() {
} }
function detect_client_info() { function detect_client_info() {
local kernel machine if [ -n "${KUBERNETES_CLIENT_OS-}" ]; then
kernel="$(uname -s)" CLIENT_PLATFORM="${KUBERNETES_CLIENT_OS}"
case "${kernel}" in else
Darwin) local kernel
CLIENT_PLATFORM="darwin" kernel="$(uname -s)"
;; case "${kernel}" in
Linux) Darwin)
CLIENT_PLATFORM="linux" CLIENT_PLATFORM="darwin"
;; ;;
*) Linux)
echo "Unknown, unsupported platform: ${kernel}." >&2 CLIENT_PLATFORM="linux"
echo "Supported platforms: Linux, Darwin." >&2 ;;
echo "Bailing out." >&2 *)
exit 2 echo "Unknown, unsupported platform: ${kernel}." >&2
esac echo "Supported platforms: Linux, Darwin." >&2
echo "Bailing out." >&2
exit 2
esac
fi
# TODO: migrate the kube::util::host_platform function out of hack/lib and if [ -n "${KUBERNETES_CLIENT_ARCH-}" ]; then
# use it here. CLIENT_ARCH="${KUBERNETES_CLIENT_ARCH}"
machine="$(uname -m)" else
case "${machine}" in # TODO: migrate the kube::util::host_platform function out of hack/lib and
x86_64*|i?86_64*|amd64*) # use it here.
CLIENT_ARCH="amd64" local machine
;; machine="$(uname -m)"
aarch64*|arm64*) case "${machine}" in
CLIENT_ARCH="arm64" x86_64*|i?86_64*|amd64*)
;; CLIENT_ARCH="amd64"
arm*) ;;
CLIENT_ARCH="arm" aarch64*|arm64*)
;; CLIENT_ARCH="arm64"
i?86*) ;;
CLIENT_ARCH="386" arm*)
;; CLIENT_ARCH="arm"
s390x*) ;;
CLIENT_ARCH="s390x" i?86*)
;; CLIENT_ARCH="386"
*) ;;
echo "Unknown, unsupported architecture (${machine})." >&2 s390x*)
echo "Supported architectures x86_64, i686, arm, arm64, s390x." >&2 CLIENT_ARCH="s390x"
echo "Bailing out." >&2 ;;
exit 3 *)
;; echo "Unknown, unsupported architecture (${machine})." >&2
esac echo "Supported architectures x86_64, i686, arm, arm64, s390x." >&2
echo "Bailing out." >&2
exit 3
;;
esac
fi
} }
function md5sum_file() { function md5sum_file() {
@ -174,7 +198,11 @@ CLIENT_TAR="kubernetes-client-${CLIENT_PLATFORM}-${CLIENT_ARCH}.tar.gz"
echo "Kubernetes release: ${KUBE_VERSION}" echo "Kubernetes release: ${KUBE_VERSION}"
echo "Server: ${SERVER_PLATFORM}/${SERVER_ARCH} (to override, set KUBERNETES_SERVER_ARCH)" echo "Server: ${SERVER_PLATFORM}/${SERVER_ARCH} (to override, set KUBERNETES_SERVER_ARCH)"
echo "Client: ${CLIENT_PLATFORM}/${CLIENT_ARCH} (autodetected)" printf "Client: %s/%s" "${CLIENT_PLATFORM}" "${CLIENT_ARCH}"
if [ -z "${KUBERNETES_CLIENT_OS-}" ] && [ -z "${KUBERNETES_CLIENT_ARCH-}" ]; then
printf " (autodetected)"
fi
echo " (to override, set KUBERNETES_CLIENT_OS and/or KUBERNETES_CLIENT_ARCH)"
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