Skip to content

Commit 657951c

Browse files
authored
Merge pull request kubernetes#74889 from akutz/feature/get-kube-binaries-client-choice
Allow choice of os/arch when downloading client
2 parents 22621ca + 020dc47 commit 657951c

File tree

1 file changed

+71
-43
lines changed

1 file changed

+71
-43
lines changed

cluster/get-kube-binaries.sh

Lines changed: 71 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@
2929
# * ppc64le
3030
# * s390x
3131
#
32+
# Set KUBERNETES_CLIENT_OS to choose the client OS to download:
33+
# * current OS [default]
34+
# * linux
35+
# * darwin
36+
# * windows
37+
#
38+
# Set KUBERNETES_CLIENT_ARCH to choose the client architecture to download:
39+
# * current architecture [default]
40+
# * amd64
41+
# * arm
42+
# * arm64
43+
# * ppc64le
44+
# * s390x
45+
# * windows
46+
#
3247
# Set KUBERNETES_SKIP_CONFIRM to skip the installation confirmation prompt.
3348
# Set KUBERNETES_RELEASE_URL to choose where to download binaries from.
3449
# (Defaults to https://storage.googleapis.com/kubernetes-release/release).
@@ -59,48 +74,57 @@ function detect_kube_release() {
5974
}
6075

6176
function detect_client_info() {
62-
local kernel machine
63-
kernel="$(uname -s)"
64-
case "${kernel}" in
65-
Darwin)
66-
CLIENT_PLATFORM="darwin"
67-
;;
68-
Linux)
69-
CLIENT_PLATFORM="linux"
70-
;;
71-
*)
72-
echo "Unknown, unsupported platform: ${kernel}." >&2
73-
echo "Supported platforms: Linux, Darwin." >&2
74-
echo "Bailing out." >&2
75-
exit 2
76-
esac
77-
78-
# TODO: migrate the kube::util::host_platform function out of hack/lib and
79-
# use it here.
80-
machine="$(uname -m)"
81-
case "${machine}" in
82-
x86_64*|i?86_64*|amd64*)
83-
CLIENT_ARCH="amd64"
84-
;;
85-
aarch64*|arm64*)
86-
CLIENT_ARCH="arm64"
87-
;;
88-
arm*)
89-
CLIENT_ARCH="arm"
90-
;;
91-
i?86*)
92-
CLIENT_ARCH="386"
93-
;;
94-
s390x*)
95-
CLIENT_ARCH="s390x"
96-
;;
97-
*)
98-
echo "Unknown, unsupported architecture (${machine})." >&2
99-
echo "Supported architectures x86_64, i686, arm, arm64, s390x." >&2
100-
echo "Bailing out." >&2
101-
exit 3
102-
;;
103-
esac
77+
if [ -n "${KUBERNETES_CLIENT_OS-}" ]; then
78+
CLIENT_PLATFORM="${KUBERNETES_CLIENT_OS}"
79+
else
80+
local kernel
81+
kernel="$(uname -s)"
82+
case "${kernel}" in
83+
Darwin)
84+
CLIENT_PLATFORM="darwin"
85+
;;
86+
Linux)
87+
CLIENT_PLATFORM="linux"
88+
;;
89+
*)
90+
echo "Unknown, unsupported platform: ${kernel}." >&2
91+
echo "Supported platforms: Linux, Darwin." >&2
92+
echo "Bailing out." >&2
93+
exit 2
94+
esac
95+
fi
96+
97+
if [ -n "${KUBERNETES_CLIENT_ARCH-}" ]; then
98+
CLIENT_ARCH="${KUBERNETES_CLIENT_ARCH}"
99+
else
100+
# TODO: migrate the kube::util::host_platform function out of hack/lib and
101+
# use it here.
102+
local machine
103+
machine="$(uname -m)"
104+
case "${machine}" in
105+
x86_64*|i?86_64*|amd64*)
106+
CLIENT_ARCH="amd64"
107+
;;
108+
aarch64*|arm64*)
109+
CLIENT_ARCH="arm64"
110+
;;
111+
arm*)
112+
CLIENT_ARCH="arm"
113+
;;
114+
i?86*)
115+
CLIENT_ARCH="386"
116+
;;
117+
s390x*)
118+
CLIENT_ARCH="s390x"
119+
;;
120+
*)
121+
echo "Unknown, unsupported architecture (${machine})." >&2
122+
echo "Supported architectures x86_64, i686, arm, arm64, s390x." >&2
123+
echo "Bailing out." >&2
124+
exit 3
125+
;;
126+
esac
127+
fi
104128
}
105129

106130
function md5sum_file() {
@@ -171,7 +195,11 @@ CLIENT_TAR="kubernetes-client-${CLIENT_PLATFORM}-${CLIENT_ARCH}.tar.gz"
171195

172196
echo "Kubernetes release: ${KUBE_VERSION}"
173197
echo "Server: ${SERVER_PLATFORM}/${SERVER_ARCH} (to override, set KUBERNETES_SERVER_ARCH)"
174-
echo "Client: ${CLIENT_PLATFORM}/${CLIENT_ARCH} (autodetected)"
198+
printf "Client: %s/%s" "${CLIENT_PLATFORM}" "${CLIENT_ARCH}"
199+
if [ -z "${KUBERNETES_CLIENT_OS-}" ] && [ -z "${KUBERNETES_CLIENT_ARCH-}" ]; then
200+
printf " (autodetected)"
201+
fi
202+
echo " (to override, set KUBERNETES_CLIENT_OS and/or KUBERNETES_CLIENT_ARCH)"
175203
echo
176204

177205
echo "Will download ${SERVER_TAR} from ${DOWNLOAD_URL_PREFIX}"

0 commit comments

Comments
 (0)