mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-25 12:17:52 +00:00
Create a get-kube-binaries script to download client/server tarballs
Also fix some errors in get-kube.sh, and remove client architectures we don't officially support.
This commit is contained in:
@@ -43,14 +43,43 @@
|
||||
# OpenStack-Heat
|
||||
# * export KUBERNETES_PROVIDER=openstack-heat; wget -q -O - https://get.k8s.io | bash
|
||||
#
|
||||
# Set KUBERNETES_SKIP_DOWNLOAD to non-empty to skip downloading a release.
|
||||
# Set KUBERNETES_RELEASE to choose a specific release instead of the current
|
||||
# stable release, (e.g. 'v1.3.7').
|
||||
# See https://github.com/kubernetes/kubernetes/releases for release options.
|
||||
# Set KUBERNETES_RELEASE_URL to choose where to download binaries from.
|
||||
# (Defaults to https://storage.googleapis.com/kubernetes-release/release).
|
||||
#
|
||||
# Set KUBERNETES_SERVER_ARCH to choose the server (Kubernetes cluster)
|
||||
# architecture to download:
|
||||
# * amd64 [default]
|
||||
# * arm
|
||||
# * arm64
|
||||
#
|
||||
# Set KUBERNETES_SKIP_DOWNLOAD to skip downloading a release.
|
||||
# Set KUBERNETES_SKIP_CONFIRM to skip the installation confirmation prompt.
|
||||
# Set KUBERNETES_RELEASE to the release you want to use (e.g. 'v1.2.0'). See https://github.com/kubernetes/kubernetes/releases for release options
|
||||
# Set KUBERNETES_SKIP_CREATE_CLUSTER to skip starting a cluster.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
KUBERNETES_RELEASE_URL="${KUBERNETES_RELEASE_URL:-https://storage.googleapis.com/kubernetes-release/release}"
|
||||
|
||||
# Use the script from inside the Kubernetes tarball to fetch the client and
|
||||
# server binaries (if not included in kubernetes.tar.gz).
|
||||
function download_kube_binaries {
|
||||
(
|
||||
cd kubernetes
|
||||
if [[ -x ./cluster/get-kube-binaries.sh ]]; then
|
||||
./cluster/get-kube-binaries.sh
|
||||
fi
|
||||
)
|
||||
}
|
||||
|
||||
function create_cluster {
|
||||
if [[ -n "${KUBERNETES_SKIP_CREATE_CLUSTER}" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
echo "Creating a kubernetes on ${KUBERNETES_PROVIDER:-gce}..."
|
||||
(
|
||||
cd kubernetes
|
||||
@@ -64,16 +93,16 @@ function create_cluster {
|
||||
)
|
||||
}
|
||||
|
||||
if [[ "${KUBERNETES_SKIP_DOWNLOAD-}" ]]; then
|
||||
if [[ -n "${KUBERNETES_SKIP_DOWNLOAD-}" ]]; then
|
||||
create_cluster
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ -d "./kubernetes" ]]; then
|
||||
if [[ -n "${KUBERNETES_SKIP_CONFIRM-}" ]]; then
|
||||
if [[ -z "${KUBERNETES_SKIP_CONFIRM-}" ]]; then
|
||||
echo "'kubernetes' directory already exist. Should we skip download step and start to create cluster based on it? [Y]/n"
|
||||
read confirm
|
||||
if [[ "$confirm" == "y" ]]; then
|
||||
if [[ ! "${confirm}" =~ ^[nN]$ ]]; then
|
||||
echo "Skipping download step."
|
||||
create_cluster
|
||||
exit 0
|
||||
@@ -94,54 +123,65 @@ function get_latest_version_number {
|
||||
}
|
||||
|
||||
release=${KUBERNETES_RELEASE:-$(get_latest_version_number)}
|
||||
release_url=https://storage.googleapis.com/kubernetes-release/release/${release}/kubernetes.tar.gz
|
||||
release_url="${KUBERNETES_RELEASE_URL}/${release}/kubernetes.tar.gz"
|
||||
|
||||
uname=$(uname)
|
||||
if [[ "${uname}" == "Darwin" ]]; then
|
||||
platform="darwin"
|
||||
elif [[ "${uname}" == "Linux" ]]; then
|
||||
platform="linux"
|
||||
else
|
||||
echo "Unknown, unsupported platform: (${uname})."
|
||||
echo "Supported platforms: Linux, Darwin."
|
||||
echo "Bailing out."
|
||||
exit 2
|
||||
fi
|
||||
# TODO: remove client checks once kubernetes.tar.gz no longer includes client
|
||||
# binaries by default.
|
||||
kernel=$(uname -s)
|
||||
case "${kernel}" in
|
||||
Darwin)
|
||||
platform="darwin"
|
||||
;;
|
||||
Linux)
|
||||
platform="linux"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown, unsupported platform: ${kernel}." >&2
|
||||
echo "Supported platforms: Linux, Darwin." >&2
|
||||
echo "Bailing out." >&2
|
||||
exit 2
|
||||
esac
|
||||
|
||||
machine=$(uname -m)
|
||||
if [[ "${machine}" == "x86_64" ]]; then
|
||||
arch="amd64"
|
||||
elif [[ "${machine}" == "i686" ]]; then
|
||||
arch="386"
|
||||
elif [[ "${machine}" == "arm*" ]]; then
|
||||
arch="arm"
|
||||
elif [[ "${machine}" == "s390x*" ]]; then
|
||||
arch="s390x"
|
||||
elif [[ "${machine}" == "ppc64le" ]]; then
|
||||
arch="ppc64le"
|
||||
else
|
||||
echo "Unknown, unsupported architecture (${machine})."
|
||||
echo "Supported architectures x86_64, i686, arm, s390x, ppc64le."
|
||||
echo "Bailing out."
|
||||
exit 3
|
||||
fi
|
||||
case "${machine}" in
|
||||
x86_64*|i?86_64*|amd64*)
|
||||
arch="amd64"
|
||||
;;
|
||||
aarch64*|arm64*)
|
||||
arch="arm64"
|
||||
;;
|
||||
arm*)
|
||||
arch="arm"
|
||||
;;
|
||||
i?86*)
|
||||
arch="386"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown, unsupported architecture (${machine})." >&2
|
||||
echo "Supported architectures x86_64, i686, arm, arm64." >&2
|
||||
echo "Bailing out." >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
|
||||
file=kubernetes.tar.gz
|
||||
|
||||
echo "Downloading kubernetes release ${release} to ${PWD}/kubernetes.tar.gz"
|
||||
if [[ -n "${KUBERNETES_SKIP_CONFIRM-}" ]]; then
|
||||
echo "Downloading kubernetes release ${release}"
|
||||
echo " from ${release_url}"
|
||||
echo " to ${PWD}/kubernetes.tar.gz"
|
||||
if [[ -z "${KUBERNETES_SKIP_CONFIRM-}" ]]; then
|
||||
echo "Is this ok? [Y]/n"
|
||||
read confirm
|
||||
if [[ "$confirm" == "n" ]]; then
|
||||
if [[ "${confirm}" =~ ^[nN]$ ]]; then
|
||||
echo "Aborting."
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $(which wget) ]]; then
|
||||
wget -N ${release_url}
|
||||
elif [[ $(which curl) ]]; then
|
||||
if [[ $(which curl) ]]; then
|
||||
curl -L -z ${file} ${release_url} -o ${file}
|
||||
elif [[ $(which wget) ]]; then
|
||||
wget -N ${release_url}
|
||||
else
|
||||
echo "Couldn't find curl or wget. Bailing out."
|
||||
exit 1
|
||||
@@ -150,4 +190,5 @@ fi
|
||||
echo "Unpacking kubernetes release ${release}"
|
||||
tar -xzf ${file}
|
||||
|
||||
download_kube_binaries
|
||||
create_cluster
|
||||
|
Reference in New Issue
Block a user