blob: 6ddf29861ba6ff5c343258af1c3efc37b92bf0c0 [file] [log] [blame]
garciadeblas7b53d262022-11-04 23:18:48 +01001#!/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
18# Helm chart 1.6.0 correspondes to Airflow 2.3.0
19AIRFLOW_HELM_VERSION=1.6.0
20PROMPUSHGW_HELM_VERSION=1.18.2
21
22# Install Airflow helm chart
23function install_airflow() {
24 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
25 # copy airflow-values.yaml to the destination folder
26 sudo mkdir -p ${OSM_HELM_WORK_DIR}
27 sudo cp ${OSM_DEVOPS}/installers/helm/values/airflow-values.yaml ${OSM_HELM_WORK_DIR}
28 if ! helm -n osm status airflow 2> /dev/null ; then
29 # if it does not exist, create secrets and install
30 kubectl -n osm create secret generic airflow-webserver-secret --from-literal="webserver-secret-key=$(python3 -c 'import secrets; print(secrets.token_hex(16))')"
31 helm repo add apache-airflow https://airflow.apache.org
32 helm repo update
33 helm -n osm install airflow apache-airflow/airflow -f ${OSM_HELM_WORK_DIR}/airflow-values.yaml --version ${AIRFLOW_HELM_VERSION}
34 else
35 # if it exists, upgrade
36 helm repo update
37 helm -n osm upgrade airflow apache-airflow/airflow -f ${OSM_HELM_WORK_DIR}/airflow-values.yaml --version ${AIRFLOW_HELM_VERSION}
38 fi
39 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
40}
41
42# Install Prometheus Pushgateway helm chart
43function install_prometheus_pushgateway() {
44 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
45 if ! helm -n osm status pushgateway 2> /dev/null ; then
46 # if it does not exist, install
47 helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
48 helm repo update
49 helm -n osm install pushgateway prometheus-community/prometheus-pushgateway --version ${PROMPUSHGW_HELM_VERSION}
50 else
51 # if it exists, upgrade
52 helm repo update
53 helm -n osm upgrade pushgateway prometheus-community/prometheus-pushgateway --version ${PROMPUSHGW_HELM_VERSION}
54 fi
55 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
56}
57
58# main
59while getopts ":D:d:-: " o; do
60 case "${o}" in
61 D)
62 OSM_DEVOPS="${OPTARG}"
63 ;;
64 d)
65 OSM_HELM_WORK_DIR="${OPTARG}"
66 ;;
67 -)
68 [ "${OPTARG}" == "debug" ] && DEBUG_INSTALL="y" && continue
69 echo -e "Invalid option: '--$OPTARG'\n" >&2
70 exit 1
71 ;;
72 :)
73 echo "Option -$OPTARG requires an argument" >&2
74 exit 1
75 ;;
76 \?)
77 echo -e "Invalid option: '-$OPTARG'\n" >&2
78 exit 1
79 ;;
80 *)
81 exit 1
82 ;;
83 esac
84done
85
86source $OSM_DEVOPS/common/logging
87source $OSM_DEVOPS/common/track
88
89echo "DEBUG_INSTALL=$DEBUG_INSTALL"
90echo "OSM_DEVOPS=$OSM_DEVOPS"
91echo "OSM_HELM_WORK_DIR=$OSM_HELM_WORK_DIR"
92
93install_airflow
94track deploy_osm airflow_ok
95install_prometheus_pushgateway
96track deploy_osm pushgateway_ok
97