Feature 11037 Installation of ingress controller in OSM community installer
[osm/devops.git] / installers / install_ngsa.sh
1 #!/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
16 set +eux
17
18 # Helm chart 1.6.0 correspondes to Airflow 2.3.0
19 AIRFLOW_HELM_VERSION=1.9.0
20
21 # Install Airflow helm chart
22 function 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}
27 # 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}"
29 sudo sed -i "s#defaultAirflowTag:.*#defaultAirflowTag: \"${OSM_DOCKER_TAG}\"#g" ${OSM_HELM_WORK_DIR}/airflow-values.yaml
30 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
32 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
34
35 helm repo add apache-airflow https://airflow.apache.org
36 helm repo update
37 helm upgrade airflow apache-airflow/airflow -n osm --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"
38 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
39 }
40
41 # main
42
43 DOCKER_REGISTRY_URL=
44 DOCKER_USER="opensourcemano"
45 OSM_DEVOPS="/usr/share/osm-devops"
46 OSM_DOCKER_TAG="testing-daily"
47 OSM_HELM_WORK_DIR="/etc/osm/helm"
48 DEFAULT_IP="127.0.0.1"
49
50 while getopts ":D:d:i:t:r:U:-: " o; do
51 case "${o}" in
52 i)
53 DEFAULT_IP="${OPTARG}"
54 ;;
55 D)
56 OSM_DEVOPS="${OPTARG}"
57 ;;
58 d)
59 OSM_HELM_WORK_DIR="${OPTARG}"
60 ;;
61 t)
62 OSM_DOCKER_TAG="${OPTARG}"
63 ;;
64 r)
65 DOCKER_REGISTRY_URL="${OPTARG}"
66 ;;
67 U)
68 DOCKER_USER="${OPTARG}"
69 ;;
70 -)
71 [ "${OPTARG}" == "debug" ] && DEBUG_INSTALL="y" && continue
72 echo -e "Invalid option: '--$OPTARG'\n" >&2
73 exit 1
74 ;;
75 :)
76 echo "Option -$OPTARG requires an argument" >&2
77 exit 1
78 ;;
79 \?)
80 echo -e "Invalid option: '-$OPTARG'\n" >&2
81 exit 1
82 ;;
83 *)
84 exit 1
85 ;;
86 esac
87 done
88
89 source $OSM_DEVOPS/common/logging
90 source $OSM_DEVOPS/common/track
91
92 echo "DEFAULT_IP=$DEFAULT_IP"
93 echo "DEBUG_INSTALL=$DEBUG_INSTALL"
94 echo "OSM_DEVOPS=$OSM_DEVOPS"
95 echo "OSM_DOCKER_TAG=$OSM_DOCKER_TAG"
96 echo "OSM_HELM_WORK_DIR=$OSM_HELM_WORK_DIR"
97
98 install_airflow
99 track deploy_osm airflow_ok