Simplify install_ngsa to use same code for helm install and upgrade 47/13947/3
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Tue, 10 Oct 2023 13:32:36 +0000 (15:32 +0200)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Wed, 11 Oct 2023 09:22:28 +0000 (11:22 +0200)
Change-Id: Ibd4fed0216b45a60f383b12c9ab3c1117688bf73
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
installers/install_ngsa.sh

index c320856..65c9f89 100755 (executable)
@@ -32,51 +32,30 @@ function install_airflow() {
     echo "Updating Helm values file helm/values/airflow-values.yaml to use defaultAirflowRepository: ${DOCKER_REGISTRY_URL}${DOCKER_USER}/airflow"
     sudo sed -i "s#defaultAirflowRepository:.*#defaultAirflowRepository: ${DOCKER_REGISTRY_URL}${DOCKER_USER}/airflow#g" ${OSM_HELM_WORK_DIR}/airflow-values.yaml
 
-    if ! helm -n osm status airflow 2> /dev/null ; then
-        # if it does not exist, create secrets and install
-        helm repo add apache-airflow https://airflow.apache.org
-        helm repo update
-        helm -n osm install airflow apache-airflow/airflow -f ${OSM_HELM_WORK_DIR}/airflow-values.yaml --version ${AIRFLOW_HELM_VERSION} --timeout 10m || FATAL_TRACK ngsa "Failed installing airflow helm chart"
-    else
-        # if it exists, upgrade
-        helm repo update
-        helm -n osm upgrade airflow apache-airflow/airflow -f ${OSM_HELM_WORK_DIR}/airflow-values.yaml --version ${AIRFLOW_HELM_VERSION} || FATAL_TRACK ngsa "Failed installing airflow helm chart"
-    fi
+    helm repo add apache-airflow https://airflow.apache.org
+    helm repo update
+    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"
     [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
 }
 
 # Install Prometheus Pushgateway helm chart
 function install_prometheus_pushgateway() {
-    [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
-    if ! helm -n osm status pushgateway 2> /dev/null ; then
-        # if it does not exist, install
-        helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
-        helm repo update
-        helm -n osm install pushgateway prometheus-community/prometheus-pushgateway --version ${PROMPUSHGW_HELM_VERSION} || FATAL_TRACK ngsa "Failed installing pushgateway helm chart"
-    else
-        # if it exists, upgrade
-        helm repo update
-        helm -n osm upgrade pushgateway prometheus-community/prometheus-pushgateway --version ${PROMPUSHGW_HELM_VERSION} || FATAL_TRACK ngsa "Failed installing pushgateway helm chart"
-    fi
+    [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
+    helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
+    helm repo update
+    helm upgrade pushgateway prometheus-community/prometheus-pushgateway -n osm --create-namespace --install --version ${PROMPUSHGW_HELM_VERSION} || FATAL_TRACK ngsa "Failed installing pushgateway helm chart"
     [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
 }
 
 # Install Prometheus AlertManager helm chart
 function install_prometheus_alertmanager() {
-    [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
+    [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
     # copy alertmanager-values.yaml to the destination folder
     sudo mkdir -p ${OSM_HELM_WORK_DIR}
     sudo cp ${OSM_DEVOPS}/installers/helm/values/alertmanager-values.yaml ${OSM_HELM_WORK_DIR}
-    if ! helm -n osm status alertmanager 2> /dev/null ; then
-        # if it does not exist, install
-        helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
-        helm repo update
-        helm -n osm install alertmanager prometheus-community/alertmanager -f ${OSM_HELM_WORK_DIR}/alertmanager-values.yaml --version ${ALERTMANAGER_HELM_VERSION} || FATAL_TRACK ngsa "Failed installing alertmanager helm chart"
-    else
-        # if it exists, upgrade
-        helm repo update
-        helm -n osm upgrade alertmanager prometheus-community/alertmanager -f ${OSM_HELM_WORK_DIR}/alertmanager-values.yaml --version ${ALERTMANAGER_HELM_VERSION} || FATAL_TRACK ngsa "Failed installing alertmanager helm chart"
-    fi
+    helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
+    helm repo update
+    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"
     [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
 }