| 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 | PROMPUSHGW_HELM_VERSION=1.18.2 |
| garciadeblas | bae51f6 | 2023-03-28 18:27:20 +0200 | [diff] [blame] | 21 | ALERTMANAGER_HELM_VERSION=0.22.0 |
| garciadeblas | 7b53d26 | 2022-11-04 23:18:48 +0100 | [diff] [blame] | 22 | |
| 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} |
| garciadeblas | d2d00c7 | 2022-11-25 17:21:46 +0100 | [diff] [blame] | 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}" |
| garciadeblas | 37d5a5f | 2023-07-20 17:02:19 +0200 | [diff] [blame] | 31 | 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] | 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 |
| 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 |
| 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" |
| garciadeblas | 7b53d26 | 2022-11-04 23:18:48 +0100 | [diff] [blame] | 38 | [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function |
| 39 | } |
| 40 | |
| 41 | # Install Prometheus Pushgateway helm chart |
| 42 | function install_prometheus_pushgateway() { |
| garciadeblas | 34824fc | 2023-10-10 15:32:36 +0200 | [diff] [blame] | 43 | [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function |
| 44 | helm repo add prometheus-community https://prometheus-community.github.io/helm-charts |
| 45 | helm repo update |
| 46 | helm upgrade pushgateway prometheus-community/prometheus-pushgateway -n osm --create-namespace --install --version ${PROMPUSHGW_HELM_VERSION} || FATAL_TRACK ngsa "Failed installing pushgateway helm chart" |
| garciadeblas | 7b53d26 | 2022-11-04 23:18:48 +0100 | [diff] [blame] | 47 | [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function |
| 48 | } |
| 49 | |
| garciadeblas | bae51f6 | 2023-03-28 18:27:20 +0200 | [diff] [blame] | 50 | # Install Prometheus AlertManager helm chart |
| 51 | function install_prometheus_alertmanager() { |
| garciadeblas | 34824fc | 2023-10-10 15:32:36 +0200 | [diff] [blame] | 52 | [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function |
| aguilard | 02609d9 | 2023-04-27 09:47:27 +0000 | [diff] [blame] | 53 | # copy alertmanager-values.yaml to the destination folder |
| 54 | sudo mkdir -p ${OSM_HELM_WORK_DIR} |
| 55 | sudo cp ${OSM_DEVOPS}/installers/helm/values/alertmanager-values.yaml ${OSM_HELM_WORK_DIR} |
| garciadeblas | 34824fc | 2023-10-10 15:32:36 +0200 | [diff] [blame] | 56 | helm repo add prometheus-community https://prometheus-community.github.io/helm-charts |
| 57 | helm repo update |
| 58 | helm upgrade alertmanager prometheus-community/alertmanager -n osm --create-namespace --install -f ${OSM_HELM_WORK_DIR}/alertmanager-values.yaml --version ${ALERTMANAGER_HELM_VERSION} || FATAL_TRACK ngsa "Failed installing alertmanager helm chart" |
| garciadeblas | bae51f6 | 2023-03-28 18:27:20 +0200 | [diff] [blame] | 59 | [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function |
| 60 | } |
| 61 | |
| garciadeblas | 7b53d26 | 2022-11-04 23:18:48 +0100 | [diff] [blame] | 62 | # main |
| garciadeblas | d2d00c7 | 2022-11-25 17:21:46 +0100 | [diff] [blame] | 63 | |
| garciadeblas | 3763099 | 2023-05-09 13:33:22 +0200 | [diff] [blame] | 64 | DOCKER_REGISTRY_URL= |
| 65 | DOCKER_USER="opensourcemano" |
| garciadeblas | d2d00c7 | 2022-11-25 17:21:46 +0100 | [diff] [blame] | 66 | OSM_DEVOPS="/usr/share/osm-devops" |
| garciadeblas | 931a512 | 2023-10-03 17:52:02 +0200 | [diff] [blame] | 67 | OSM_DOCKER_TAG="testing-daily" |
| garciadeblas | 3763099 | 2023-05-09 13:33:22 +0200 | [diff] [blame] | 68 | OSM_HELM_WORK_DIR="/etc/osm/helm" |
| garciadeblas | d2d00c7 | 2022-11-25 17:21:46 +0100 | [diff] [blame] | 69 | |
| garciadeblas | 3763099 | 2023-05-09 13:33:22 +0200 | [diff] [blame] | 70 | while getopts ":D:d:t:r:U:-: " o; do |
| garciadeblas | 7b53d26 | 2022-11-04 23:18:48 +0100 | [diff] [blame] | 71 | case "${o}" in |
| 72 | D) |
| 73 | OSM_DEVOPS="${OPTARG}" |
| 74 | ;; |
| 75 | d) |
| 76 | OSM_HELM_WORK_DIR="${OPTARG}" |
| 77 | ;; |
| garciadeblas | d2d00c7 | 2022-11-25 17:21:46 +0100 | [diff] [blame] | 78 | t) |
| 79 | OSM_DOCKER_TAG="${OPTARG}" |
| 80 | ;; |
| garciadeblas | 3763099 | 2023-05-09 13:33:22 +0200 | [diff] [blame] | 81 | r) |
| 82 | DOCKER_REGISTRY_URL="${OPTARG}" |
| 83 | ;; |
| 84 | U) |
| 85 | DOCKER_USER="${OPTARG}" |
| 86 | ;; |
| garciadeblas | 7b53d26 | 2022-11-04 23:18:48 +0100 | [diff] [blame] | 87 | -) |
| 88 | [ "${OPTARG}" == "debug" ] && DEBUG_INSTALL="y" && continue |
| 89 | echo -e "Invalid option: '--$OPTARG'\n" >&2 |
| 90 | exit 1 |
| 91 | ;; |
| 92 | :) |
| 93 | echo "Option -$OPTARG requires an argument" >&2 |
| 94 | exit 1 |
| 95 | ;; |
| 96 | \?) |
| 97 | echo -e "Invalid option: '-$OPTARG'\n" >&2 |
| 98 | exit 1 |
| 99 | ;; |
| 100 | *) |
| 101 | exit 1 |
| 102 | ;; |
| 103 | esac |
| 104 | done |
| 105 | |
| 106 | source $OSM_DEVOPS/common/logging |
| 107 | source $OSM_DEVOPS/common/track |
| 108 | |
| 109 | echo "DEBUG_INSTALL=$DEBUG_INSTALL" |
| 110 | echo "OSM_DEVOPS=$OSM_DEVOPS" |
| garciadeblas | d2d00c7 | 2022-11-25 17:21:46 +0100 | [diff] [blame] | 111 | echo "OSM_DOCKER_TAG=$OSM_DOCKER_TAG" |
| garciadeblas | 7b53d26 | 2022-11-04 23:18:48 +0100 | [diff] [blame] | 112 | echo "OSM_HELM_WORK_DIR=$OSM_HELM_WORK_DIR" |
| 113 | |
| 114 | install_airflow |
| 115 | track deploy_osm airflow_ok |
| 116 | install_prometheus_pushgateway |
| 117 | track deploy_osm pushgateway_ok |
| garciadeblas | bae51f6 | 2023-03-28 18:27:20 +0200 | [diff] [blame] | 118 | install_prometheus_alertmanager |
| 119 | track deploy_osm alertmanager_ok |
| garciadeblas | 7b53d26 | 2022-11-04 23:18:48 +0100 | [diff] [blame] | 120 | |