| garciadeblas | 7b53d26 | 2022-11-04 23:18:48 +0100 | [diff] [blame] | 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 |
| garciadeblas | 0b7ef27 | 2023-05-10 10:50:34 +0200 | [diff] [blame] | 19 | AIRFLOW_HELM_VERSION=1.9.0 |
| garciadeblas | 7b53d26 | 2022-11-04 23:18:48 +0100 | [diff] [blame] | 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} |
| garciadeblas | d2d00c7 | 2022-11-25 17:21:46 +0100 | [diff] [blame] | 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}" |
| garciadeblas | 37d5a5f | 2023-07-20 17:02:19 +0200 | [diff] [blame] | 29 | sudo sed -i "s#defaultAirflowTag:.*#defaultAirflowTag: \"${OSM_DOCKER_TAG}\"#g" ${OSM_HELM_WORK_DIR}/airflow-values.yaml |
| garciadeblas | 836354f | 2023-05-10 18:12:00 +0200 | [diff] [blame] | 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 |
| garciadeblas | 18582e9 | 2024-05-21 12:13:50 +0200 | [diff] [blame] | 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 |
| garciadeblas | 8080e4b | 2023-04-14 09:57:17 +0200 | [diff] [blame] | 34 | |
| garciadeblas | 34824fc | 2023-10-10 15:32:36 +0200 | [diff] [blame] | 35 | helm repo add apache-airflow https://airflow.apache.org |
| 36 | helm repo update |
| garciadeblas | b9a84e4 | 2024-05-31 15:06:40 +0200 | [diff] [blame] | 37 | 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" |
| garciadeblas | 7b53d26 | 2022-11-04 23:18:48 +0100 | [diff] [blame] | 38 | [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function |
| 39 | } |
| 40 | |
| garciadeblas | 7b53d26 | 2022-11-04 23:18:48 +0100 | [diff] [blame] | 41 | # main |
| garciadeblas | d2d00c7 | 2022-11-25 17:21:46 +0100 | [diff] [blame] | 42 | |
| garciadeblas | 3763099 | 2023-05-09 13:33:22 +0200 | [diff] [blame] | 43 | DOCKER_REGISTRY_URL= |
| 44 | DOCKER_USER="opensourcemano" |
| garciadeblas | d2d00c7 | 2022-11-25 17:21:46 +0100 | [diff] [blame] | 45 | OSM_DEVOPS="/usr/share/osm-devops" |
| garciadeblas | 931a512 | 2023-10-03 17:52:02 +0200 | [diff] [blame] | 46 | OSM_DOCKER_TAG="testing-daily" |
| garciadeblas | 3763099 | 2023-05-09 13:33:22 +0200 | [diff] [blame] | 47 | OSM_HELM_WORK_DIR="/etc/osm/helm" |
| garciadeblas | b9a84e4 | 2024-05-31 15:06:40 +0200 | [diff] [blame] | 48 | OSM_NAMESPACE="osm" |
| garciadeblas | 18582e9 | 2024-05-21 12:13:50 +0200 | [diff] [blame] | 49 | DEFAULT_IP="127.0.0.1" |
| garciadeblas | d2d00c7 | 2022-11-25 17:21:46 +0100 | [diff] [blame] | 50 | |
| garciadeblas | b9a84e4 | 2024-05-31 15:06:40 +0200 | [diff] [blame] | 51 | while getopts ":D:d:i:s:t:r:U:-: " o; do |
| garciadeblas | 7b53d26 | 2022-11-04 23:18:48 +0100 | [diff] [blame] | 52 | case "${o}" in |
| garciadeblas | 18582e9 | 2024-05-21 12:13:50 +0200 | [diff] [blame] | 53 | i) |
| 54 | DEFAULT_IP="${OPTARG}" |
| 55 | ;; |
| garciadeblas | 7b53d26 | 2022-11-04 23:18:48 +0100 | [diff] [blame] | 56 | D) |
| 57 | OSM_DEVOPS="${OPTARG}" |
| 58 | ;; |
| 59 | d) |
| 60 | OSM_HELM_WORK_DIR="${OPTARG}" |
| 61 | ;; |
| garciadeblas | b9a84e4 | 2024-05-31 15:06:40 +0200 | [diff] [blame] | 62 | s) |
| 63 | OSM_NAMESPACE="${OPTARG}" |
| 64 | ;; |
| garciadeblas | d2d00c7 | 2022-11-25 17:21:46 +0100 | [diff] [blame] | 65 | t) |
| 66 | OSM_DOCKER_TAG="${OPTARG}" |
| 67 | ;; |
| garciadeblas | 3763099 | 2023-05-09 13:33:22 +0200 | [diff] [blame] | 68 | r) |
| 69 | DOCKER_REGISTRY_URL="${OPTARG}" |
| 70 | ;; |
| 71 | U) |
| 72 | DOCKER_USER="${OPTARG}" |
| 73 | ;; |
| garciadeblas | 7b53d26 | 2022-11-04 23:18:48 +0100 | [diff] [blame] | 74 | -) |
| 75 | [ "${OPTARG}" == "debug" ] && DEBUG_INSTALL="y" && continue |
| 76 | echo -e "Invalid option: '--$OPTARG'\n" >&2 |
| 77 | exit 1 |
| 78 | ;; |
| 79 | :) |
| 80 | echo "Option -$OPTARG requires an argument" >&2 |
| 81 | exit 1 |
| 82 | ;; |
| 83 | \?) |
| 84 | echo -e "Invalid option: '-$OPTARG'\n" >&2 |
| 85 | exit 1 |
| 86 | ;; |
| 87 | *) |
| 88 | exit 1 |
| 89 | ;; |
| 90 | esac |
| 91 | done |
| 92 | |
| 93 | source $OSM_DEVOPS/common/logging |
| 94 | source $OSM_DEVOPS/common/track |
| 95 | |
| garciadeblas | 18582e9 | 2024-05-21 12:13:50 +0200 | [diff] [blame] | 96 | echo "DEFAULT_IP=$DEFAULT_IP" |
| garciadeblas | 7b53d26 | 2022-11-04 23:18:48 +0100 | [diff] [blame] | 97 | echo "DEBUG_INSTALL=$DEBUG_INSTALL" |
| 98 | echo "OSM_DEVOPS=$OSM_DEVOPS" |
| garciadeblas | d2d00c7 | 2022-11-25 17:21:46 +0100 | [diff] [blame] | 99 | echo "OSM_DOCKER_TAG=$OSM_DOCKER_TAG" |
| garciadeblas | 7b53d26 | 2022-11-04 23:18:48 +0100 | [diff] [blame] | 100 | echo "OSM_HELM_WORK_DIR=$OSM_HELM_WORK_DIR" |
| garciadeblas | b9a84e4 | 2024-05-31 15:06:40 +0200 | [diff] [blame] | 101 | echo "OSM_NAMESPACE=$OSM_NAMESPACE" |
| garciadeblas | 7b53d26 | 2022-11-04 23:18:48 +0100 | [diff] [blame] | 102 | |
| 103 | install_airflow |
| 104 | track deploy_osm airflow_ok |