-
Notifications
You must be signed in to change notification settings - Fork 333
/
Copy pathinstall_helm.sh
executable file
·53 lines (46 loc) · 1.63 KB
/
install_helm.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
set -x
# Source common libraries and env variables
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT_DIR="${SCRIPT_DIR}/../.."
source ${ROOT_DIR}/scripts/common.sh
HELM_INSTALL_DIR=/usr/local/bin
HELM_INSTALL_SCRIPT_URL="${HELM_INSTALL_SCRIPT_URL:-https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3}"
HELM_MINIMUM_VERSION=v3.4.1+gc4e7485
if ! kubectl version ; then
echo "Unable to talk to Kubernetes API"
exit 1
fi
# Install dependencies
. /etc/os-release
case "$ID" in
rhel*|centos*)
if ! type curl >/dev/null 2>&1 ; then
sudo yum -y install curl
fi
;;
ubuntu*)
if ! type curl >/dev/null 2>&1 ; then
sudo apt-get -y install curl
fi
;;
*)
echo "Unsupported Operating System $ID_LIKE"
exit 1
;;
esac
helm_version=$(helm version --short)
helm_min_installed=$(echo -e "${HELM_MINIMUM_VERSION}\n${helm_version}"| sort -V | head -n 1)
if [ "${HELM_MINIMUM_VERSION}" != "${helm_min_installed}" ]; then
if [ "${helm_version}" != "" ]; then
sudo mv $(which helm) "$(which helm).bak"
echo "Helm ${helm_version} currently installed, upgrading to ${HELM_MINIMUM_VERSION}"
fi
curl -fsSL -o /var/tmp/get_helm.sh "${HELM_INSTALL_SCRIPT_URL}"
chmod +x /var/tmp/get_helm.sh
#sed -i 's/sudo//g' /var/tmp/get_helm.sh
mkdir -p ${HELM_INSTALL_DIR}
HELM_INSTALL_DIR=${HELM_INSTALL_DIR} DESIRED_VERSION=v3.7.1 /var/tmp/get_helm.sh # Should match: config/group_vars/k8s-cluster.yml:helm_version:
fi
# Display the helm version for better debug
helm version