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.9.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 echo "Updating Helm values file helm/values/airflow-values.yaml to use defaultAirflowRepository: ${DOCKER_REGISTRY_URL}${DOCKER_USER}/airflow"
33 sudo
sed -i "s#defaultAirflowRepository:.*#defaultAirflowRepository: ${DOCKER_REGISTRY_URL}${DOCKER_USER}/airflow#g" ${OSM_HELM_WORK_DIR}/airflow-values.yaml
35 if ! helm -n osm status airflow 2> /dev/null ; then
36 # if it does not exist, create secrets and install
37 helm repo add apache-airflow https://airflow.apache.org
39 helm -n osm install airflow apache-airflow/airflow -f ${OSM_HELM_WORK_DIR}/airflow-values.yaml --version ${AIRFLOW_HELM_VERSION}
41 # if it exists, upgrade
43 helm -n osm upgrade airflow apache-airflow/airflow -f ${OSM_HELM_WORK_DIR}/airflow-values.yaml --version ${AIRFLOW_HELM_VERSION}
45 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
48 # Install Prometheus Pushgateway helm chart
49 function install_prometheus_pushgateway() {
50 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
51 if ! helm -n osm status pushgateway 2> /dev/null ; then
52 # if it does not exist, install
53 helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
55 helm -n osm install pushgateway prometheus-community/prometheus-pushgateway --version ${PROMPUSHGW_HELM_VERSION}
57 # if it exists, upgrade
59 helm -n osm upgrade pushgateway prometheus-community/prometheus-pushgateway --version ${PROMPUSHGW_HELM_VERSION}
61 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
64 # Install Prometheus AlertManager helm chart
65 function install_prometheus_alertmanager() {
66 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
67 # copy alertmanager-values.yaml to the destination folder
68 sudo mkdir -p ${OSM_HELM_WORK_DIR}
69 sudo cp ${OSM_DEVOPS}/installers/helm/values/alertmanager-values.yaml ${OSM_HELM_WORK_DIR}
70 if ! helm -n osm status alertmanager 2> /dev/null ; then
71 # if it does not exist, install
72 helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
74 helm -n osm install alertmanager prometheus-community/alertmanager -f ${OSM_HELM_WORK_DIR}/alertmanager-values.yaml --version ${ALERTMANAGER_HELM_VERSION}
76 # if it exists, upgrade
78 helm -n osm upgrade alertmanager prometheus-community/alertmanager -f ${OSM_HELM_WORK_DIR}/alertmanager-values.yaml --version ${ALERTMANAGER_HELM_VERSION}
80 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
86 DOCKER_USER="opensourcemano
"
87 OSM_DEVOPS="/usr
/share
/osm-devops
"
89 OSM_HELM_WORK_DIR="/etc
/osm
/helm
"
91 while getopts ":D
:d
:t
:r
:U
:-: " o; do
94 OSM_DEVOPS="${OPTARG}"
97 OSM_HELM_WORK_DIR="${OPTARG}"
100 OSM_DOCKER_TAG="${OPTARG}"
103 DOCKER_REGISTRY_URL="${OPTARG}"
106 DOCKER_USER="${OPTARG}"
109 [ "${OPTARG}" == "debug
" ] && DEBUG_INSTALL="y
" && continue
110 echo -e "Invalid option
: '--$OPTARG'\n" >&2
114 echo "Option
-$OPTARG requires an argument
" >&2
118 echo -e "Invalid option
: '-$OPTARG'\n" >&2
127 source $OSM_DEVOPS/common/logging
128 source $OSM_DEVOPS/common/track
130 echo "DEBUG_INSTALL
=$DEBUG_INSTALL"
131 echo "OSM_DEVOPS
=$OSM_DEVOPS"
132 echo "OSM_DOCKER_TAG
=$OSM_DOCKER_TAG"
133 echo "OSM_HELM_WORK_DIR
=$OSM_HELM_WORK_DIR"
136 track deploy_osm airflow_ok
137 install_prometheus_pushgateway
138 track deploy_osm pushgateway_ok
139 install_prometheus_alertmanager
140 track deploy_osm alertmanager_ok