Feature 11037 Installation of ingress controller in OSM community installer
[osm/devops.git] / installers / install_helm_client.sh
1 #!/bin/bash
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 #
15
16 set +eux
17
18 HELM_VERSION="v3.14.3"
19
20 #Install Helm v3
21 #Helm releases can be found here: https://github.com/helm/helm/releases
22 function install_helm_client() {
23 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
24 if ! [[ "$(helm version --short 2>/dev/null)" =~ ^v3.* ]]; then
25 # Helm is not installed. Install helm
26 echo "Helm3 is not installed, installing ..."
27 curl https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz --output helm-${HELM_VERSION}.tar.gz
28 tar -zxvf helm-${HELM_VERSION}.tar.gz
29 sudo mv linux-amd64/helm /usr/local/bin/helm
30 rm -r linux-amd64
31 rm helm-${HELM_VERSION}.tar.gz
32 else
33 echo "Helm3 is already installed. Skipping installation..."
34 fi
35 helm version || FATAL_TRACK k8scluster "Could not obtain helm version. Maybe helm client was not installed"
36 helm repo add stable https://charts.helm.sh/stable || FATAL_TRACK k8scluster "Helm repo stable could not be added"
37 helm repo update || FATAL_TRACK k8scluster "Helm repo stable could not be updated"
38 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
39 }
40
41 # main
42 while getopts ":D:-: " o; do
43 case "${o}" in
44 D)
45 OSM_DEVOPS="${OPTARG}"
46 ;;
47 -)
48 [ "${OPTARG}" == "debug" ] && DEBUG_INSTALL="y" && continue
49 echo -e "Invalid option: '--$OPTARG'\n" >&2
50 exit 1
51 ;;
52 :)
53 echo "Option -$OPTARG requires an argument" >&2
54 exit 1
55 ;;
56 \?)
57 echo -e "Invalid option: '-$OPTARG'\n" >&2
58 exit 1
59 ;;
60 *)
61 exit 1
62 ;;
63 esac
64 done
65
66 source $OSM_DEVOPS/common/logging
67 source $OSM_DEVOPS/common/track
68
69 echo "DEBUG_INSTALL=$DEBUG_INSTALL"
70 echo "DEFAULT_IP=$DEFAULT_IP"
71 echo "OSM_DEVOPS=$OSM_DEVOPS"
72
73 install_helm_client