blob: 6931432788505c157bd2ed8393d79a39b4e35b96 [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
garciadeblas0b7ef272023-05-10 10:50:34 +020019AIRFLOW_HELM_VERSION=1.9.0
garciadeblas7b53d262022-11-04 23:18:48 +010020
21# Install Airflow helm chart
22function install_airflow() {
23 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
24 # copy airflow-values.yaml to the destination folder
25 sudo mkdir -p ${OSM_HELM_WORK_DIR}
26 sudo cp ${OSM_DEVOPS}/installers/helm/values/airflow-values.yaml ${OSM_HELM_WORK_DIR}
garciadeblasd2d00c72022-11-25 17:21:46 +010027 # update airflow-values.yaml to use the right tag
28 echo "Updating Helm values file helm/values/airflow-values.yaml to use defaultAirflowTag: ${OSM_DOCKER_TAG}"
garciadeblas37d5a5f2023-07-20 17:02:19 +020029 sudo sed -i "s#defaultAirflowTag:.*#defaultAirflowTag: \"${OSM_DOCKER_TAG}\"#g" ${OSM_HELM_WORK_DIR}/airflow-values.yaml
garciadeblas836354f2023-05-10 18:12:00 +020030 echo "Updating Helm values file helm/values/airflow-values.yaml to use defaultAirflowRepository: ${DOCKER_REGISTRY_URL}${DOCKER_USER}/airflow"
31 sudo sed -i "s#defaultAirflowRepository:.*#defaultAirflowRepository: ${DOCKER_REGISTRY_URL}${DOCKER_USER}/airflow#g" ${OSM_HELM_WORK_DIR}/airflow-values.yaml
garciadeblas18582e92024-05-21 12:13:50 +020032 echo "Updating Helm values file helm/values/airflow-values.yaml to set ingress.web.hosts with host \"airflow.${DEFAULT_IP}.nip.io\""
33 sudo sed -i "s#name: \"localhost\"#name: \"airflow.${DEFAULT_IP}.nip.io\"#g" ${OSM_HELM_WORK_DIR}/airflow-values.yaml
garciadeblas8080e4b2023-04-14 09:57:17 +020034
garciadeblas34824fc2023-10-10 15:32:36 +020035 helm repo add apache-airflow https://airflow.apache.org
36 helm repo update
garciadeblasb9a84e42024-05-31 15:06:40 +020037 helm upgrade airflow apache-airflow/airflow -n ${OSM_NAMESPACE} --create-namespace --install -f ${OSM_HELM_WORK_DIR}/airflow-values.yaml --version ${AIRFLOW_HELM_VERSION} --timeout 10m || FATAL_TRACK ngsa "Failed installing airflow helm chart"
garciadeblas7b53d262022-11-04 23:18:48 +010038 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
39}
40
garciadeblas7b53d262022-11-04 23:18:48 +010041# main
garciadeblasb9a84e42024-05-31 15:06:40 +020042while getopts ":D:d:i:s:t:r:U:-: " o; do
garciadeblas7b53d262022-11-04 23:18:48 +010043 case "${o}" in
garciadeblas18582e92024-05-21 12:13:50 +020044 i)
45 DEFAULT_IP="${OPTARG}"
46 ;;
garciadeblas7b53d262022-11-04 23:18:48 +010047 D)
48 OSM_DEVOPS="${OPTARG}"
49 ;;
50 d)
51 OSM_HELM_WORK_DIR="${OPTARG}"
52 ;;
garciadeblasb9a84e42024-05-31 15:06:40 +020053 s)
54 OSM_NAMESPACE="${OPTARG}"
55 ;;
garciadeblasd2d00c72022-11-25 17:21:46 +010056 t)
57 OSM_DOCKER_TAG="${OPTARG}"
58 ;;
garciadeblas37630992023-05-09 13:33:22 +020059 r)
60 DOCKER_REGISTRY_URL="${OPTARG}"
61 ;;
62 U)
63 DOCKER_USER="${OPTARG}"
64 ;;
garciadeblas7b53d262022-11-04 23:18:48 +010065 -)
66 [ "${OPTARG}" == "debug" ] && DEBUG_INSTALL="y" && continue
67 echo -e "Invalid option: '--$OPTARG'\n" >&2
68 exit 1
69 ;;
70 :)
71 echo "Option -$OPTARG requires an argument" >&2
72 exit 1
73 ;;
74 \?)
75 echo -e "Invalid option: '-$OPTARG'\n" >&2
76 exit 1
77 ;;
78 *)
79 exit 1
80 ;;
81 esac
82done
83
garciadeblas82981162024-07-23 15:24:00 +020084DEBUG_INSTALL=${DEBUG_INSTALL:-}
85DEFAULT_IP=${DEFAULT_IP:-"127.0.0.1"}
86OSM_DEVOPS=${OSM_DEVOPS:-"/usr/share/osm-devops"}
87OSM_DOCKER_TAG=${OSM_DOCKER_TAG:-"testing-daily"}
88OSM_HELM_WORK_DIR=${OSM_HELM_WORK_DIR:-"/etc/osm/helm"}
89OSM_NAMESPACE=${OSM_NAMESPACE:-"osm"}
90DOCKER_REGISTRY_URL=${DOCKER_REGISTRY_URL:-}
91DOCKER_USER=${DOCKER_USER:-"opensourcemano"}
garciadeblas7b53d262022-11-04 23:18:48 +010092echo "DEBUG_INSTALL=$DEBUG_INSTALL"
garciadeblas82981162024-07-23 15:24:00 +020093echo "DEFAULT_IP=$DEFAULT_IP"
garciadeblas7b53d262022-11-04 23:18:48 +010094echo "OSM_DEVOPS=$OSM_DEVOPS"
garciadeblasd2d00c72022-11-25 17:21:46 +010095echo "OSM_DOCKER_TAG=$OSM_DOCKER_TAG"
garciadeblas7b53d262022-11-04 23:18:48 +010096echo "OSM_HELM_WORK_DIR=$OSM_HELM_WORK_DIR"
garciadeblasb9a84e42024-05-31 15:06:40 +020097echo "OSM_NAMESPACE=$OSM_NAMESPACE"
garciadeblas82981162024-07-23 15:24:00 +020098echo "DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL"
99echo "DOCKER_USER=$DOCKER_USER"
100
101source $OSM_DEVOPS/common/logging
102source $OSM_DEVOPS/common/track
garciadeblas7b53d262022-11-04 23:18:48 +0100103
104install_airflow
105track deploy_osm airflow_ok