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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 # Helm chart 1.6.0 correspondes to Airflow 2.3.0
19 AIRFLOW_HELM_VERSION
=1.6.0
20 PROMPUSHGW_HELM_VERSION
=1.18.2
21 ALERTMANAGER_HELM_VERSION
=0.22.0
23 # Install Airflow helm chart
24 function install_airflow
() {
25 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of
function
26 # copy airflow-values.yaml to the destination folder
27 sudo mkdir
-p ${OSM_HELM_WORK_DIR}
28 sudo
cp ${OSM_DEVOPS}/installers
/helm
/values
/airflow-values.yaml
${OSM_HELM_WORK_DIR}
29 # update airflow-values.yaml to use the right tag
30 echo "Updating Helm values file helm/values/airflow-values.yaml to use defaultAirflowTag: ${OSM_DOCKER_TAG}"
31 sudo
sed -i "s#defaultAirflowTag:.*#defaultAirflowTag: ${OSM_DOCKER_TAG}#g" ${OSM_HELM_WORK_DIR}/airflow-values.yaml
32 if ! helm
-n osm status airflow
2> /dev
/null
; then
33 # if it does not exist, create secrets and install
34 kubectl
-n osm create secret generic airflow-webserver-secret
--from-literal="webserver-secret-key=$(python3 -c 'import secrets; print(secrets.token_hex(16))')"
35 helm repo add apache-airflow https
://airflow.apache.org
37 helm
-n osm
install airflow apache-airflow
/airflow
-f ${OSM_HELM_WORK_DIR}/airflow-values.yaml
--version ${AIRFLOW_HELM_VERSION}
39 # if it exists, upgrade
41 helm
-n osm upgrade airflow apache-airflow
/airflow
-f ${OSM_HELM_WORK_DIR}/airflow-values.yaml
--version ${AIRFLOW_HELM_VERSION}
43 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of
function
46 # Install Prometheus Pushgateway helm chart
47 function install_prometheus_pushgateway
() {
48 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of
function
49 if ! helm
-n osm status pushgateway
2> /dev
/null
; then
50 # if it does not exist, install
51 helm repo add prometheus-community https
://prometheus-community.github.io
/helm-charts
53 helm
-n osm
install pushgateway prometheus-community
/prometheus-pushgateway
--version ${PROMPUSHGW_HELM_VERSION}
55 # if it exists, upgrade
57 helm
-n osm upgrade pushgateway prometheus-community
/prometheus-pushgateway
--version ${PROMPUSHGW_HELM_VERSION}
59 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of
function
62 # Install Prometheus AlertManager helm chart
63 function install_prometheus_alertmanager
() {
64 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of
function
65 if ! helm
-n osm status alertmanager
2> /dev
/null
; then
66 # if it does not exist, install
67 helm repo add prometheus-community https
://prometheus-community.github.io
/helm-charts
69 helm
-n osm
install alertmanager prometheus-community
/alertmanager
-f ${OSM_HELM_WORK_DIR}/alertmanager-values.yaml
--version ${ALERTMANAGER_HELM_VERSION}
71 # if it exists, upgrade
73 helm
-n osm upgrade alertmanager prometheus-community
/alertmanager
-f ${OSM_HELM_WORK_DIR}/alertmanager-values.yaml
--version ${ALERTMANAGER_HELM_VERSION}
75 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of
function
80 OSM_DEVOPS
="/usr/share/osm-devops"
81 OSM_HELM_WORK_DIR
="/etc/osm/helm"
84 while getopts ":D:d:t:-: " o
; do
87 OSM_DEVOPS
="${OPTARG}"
90 OSM_HELM_WORK_DIR
="${OPTARG}"
93 OSM_DOCKER_TAG
="${OPTARG}"
96 [ "${OPTARG}" == "debug" ] && DEBUG_INSTALL
="y" && continue
97 echo -e "Invalid option: '--$OPTARG'\n" >&2
101 echo "Option -$OPTARG requires an argument" >&2
105 echo -e "Invalid option: '-$OPTARG'\n" >&2
114 source $OSM_DEVOPS/common
/logging
115 source $OSM_DEVOPS/common
/track
117 echo "DEBUG_INSTALL=$DEBUG_INSTALL"
118 echo "OSM_DEVOPS=$OSM_DEVOPS"
119 echo "OSM_DOCKER_TAG=$OSM_DOCKER_TAG"
120 echo "OSM_HELM_WORK_DIR=$OSM_HELM_WORK_DIR"
123 track deploy_osm airflow_ok
124 install_prometheus_pushgateway
125 track deploy_osm pushgateway_ok
126 install_prometheus_alertmanager
127 track deploy_osm alertmanager_ok