blob: 427a2e124763258a3b237dacfd2827ef3591f029 [file] [log] [blame]
garciadeblas9c624882024-04-01 15:01:27 +02001#!/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
16set +eux
17
garciadeblas4c3b3fb2024-05-30 14:49:01 +020018HELM_VERSION="v3.15.1"
garciadeblas9c624882024-04-01 15:01:27 +020019
20#Install Helm v3
21#Helm releases can be found here: https://github.com/helm/helm/releases
22function 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
42while 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
64done
65
garciadeblas82981162024-07-23 15:24:00 +020066DEBUG_INSTALL=${DEBUG_INSTALL:-}
67OSM_DEVOPS=${OSM_DEVOPS:-}
68echo "DEBUG_INSTALL=$DEBUG_INSTALL"
69echo "OSM_DEVOPS=$OSM_DEVOPS"
70
garciadeblas9c624882024-04-01 15:01:27 +020071source $OSM_DEVOPS/common/logging
72source $OSM_DEVOPS/common/track
73
garciadeblas9c624882024-04-01 15:01:27 +020074install_helm_client