Unverified Commit c14dac9a authored by Erik Wilson's avatar Erik Wilson Committed by GitHub

Merge pull request #1580 from erikwilson/use-channel-server-install-script

Use channel server for install script
parents 5c3d7508 dddbd163
...@@ -33,8 +33,8 @@ set -e ...@@ -33,8 +33,8 @@ set -e
# If set to true will not start k3s service. # If set to true will not start k3s service.
# #
# - INSTALL_K3S_VERSION # - INSTALL_K3S_VERSION
# Version of k3s to download from github. Will attempt to download the # Version of k3s to download from github. Will attempt to download from the
# latest version if not specified. # stable channel if not specified.
# #
# - INSTALL_K3S_COMMIT # - INSTALL_K3S_COMMIT
# Commit of k3s to download from temporary cloud storage. # Commit of k3s to download from temporary cloud storage.
...@@ -75,6 +75,14 @@ set -e ...@@ -75,6 +75,14 @@ set -e
# #
# - INSTALL_K3S_SELINUX_WARN # - INSTALL_K3S_SELINUX_WARN
# If set to true will continue if k3s-selinux policy is not found. # If set to true will continue if k3s-selinux policy is not found.
#
# - INSTALL_K3S_CHANNEL_URL
# Channel URL for fetching k3s download URL.
# Defaults to 'https://update.k3s.io/v1-release/channels'.
#
# - INSTALL_K3S_CHANNEL
# Channel to use for fetching k3s download URL.
# Defaults to 'stable'.
GITHUB_URL=https://github.com/rancher/k3s/releases GITHUB_URL=https://github.com/rancher/k3s/releases
STORAGE_URL=https://storage.googleapis.com/k3s-ci-builds STORAGE_URL=https://storage.googleapis.com/k3s-ci-builds
...@@ -229,6 +237,10 @@ setup_env() { ...@@ -229,6 +237,10 @@ setup_env() {
if [ "${INSTALL_K3S_BIN_DIR_READ_ONLY}" = true ]; then if [ "${INSTALL_K3S_BIN_DIR_READ_ONLY}" = true ]; then
INSTALL_K3S_SKIP_DOWNLOAD=true INSTALL_K3S_SKIP_DOWNLOAD=true
fi fi
# --- setup channel values
INSTALL_K3S_CHANNEL_URL=${INSTALL_K3S_CHANNEL_URL:-'https://update.k3s.io/v1-release/channels'}
INSTALL_K3S_CHANNEL=${INSTALL_K3S_CHANNEL:-'stable'}
} }
# --- check if skip download environment variable set --- # --- check if skip download environment variable set ---
...@@ -301,20 +313,21 @@ setup_tmp() { ...@@ -301,20 +313,21 @@ setup_tmp() {
trap cleanup INT EXIT trap cleanup INT EXIT
} }
# --- use desired k3s version if defined or find latest --- # --- use desired k3s version if defined or find version from channel ---
get_release_version() { get_release_version() {
if [ -n "${INSTALL_K3S_COMMIT}" ]; then if [ -n "${INSTALL_K3S_COMMIT}" ]; then
VERSION_K3S="commit ${INSTALL_K3S_COMMIT}" VERSION_K3S="commit ${INSTALL_K3S_COMMIT}"
elif [ -n "${INSTALL_K3S_VERSION}" ]; then elif [ -n "${INSTALL_K3S_VERSION}" ]; then
VERSION_K3S=${INSTALL_K3S_VERSION} VERSION_K3S=${INSTALL_K3S_VERSION}
else else
info "Finding latest release" info "Finding release for channel ${INSTALL_K3S_CHANNEL}"
version_url="${INSTALL_K3S_CHANNEL_URL}/${INSTALL_K3S_CHANNEL}"
case $DOWNLOADER in case $DOWNLOADER in
curl) curl)
VERSION_K3S=$(curl -w '%{url_effective}' -I -L -s -S ${GITHUB_URL}/latest -o /dev/null | sed -e 's|.*/||') VERSION_K3S=$(curl -w '%{url_effective}' -L -s -S ${version_url} -o /dev/null | sed -e 's|.*/||')
;; ;;
wget) wget)
VERSION_K3S=$(wget -SqO /dev/null ${GITHUB_URL}/latest 2>&1 | grep -i Location | sed -e 's|.*/||') VERSION_K3S=$(wget -SqO /dev/null ${version_url} 2>&1 | grep -i Location | sed -e 's|.*/||')
;; ;;
*) *)
fatal "Incorrect downloader executable '$DOWNLOADER'" fatal "Incorrect downloader executable '$DOWNLOADER'"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment