From: garciadeblas Date: Fri, 31 May 2024 13:06:40 +0000 (+0200) Subject: Add namespace option for mongodb, ngsa and cluster monitoring installation X-Git-Tag: release-v16.0-start~28 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=b9a84e4d91b8e21a1e81e735f69d78c2dedf5f0d;p=osm%2Fdevops.git Add namespace option for mongodb, ngsa and cluster monitoring installation Change-Id: Iabbf70fd036adf8c4a2846e845e17e3dae22a6f0 Signed-off-by: garciadeblas --- diff --git a/installers/full_install_osm.sh b/installers/full_install_osm.sh index 472c70b8..349566de 100755 --- a/installers/full_install_osm.sh +++ b/installers/full_install_osm.sh @@ -255,8 +255,6 @@ function cmp_overwrite() { #deploys osm pods and services function deploy_osm_services() { [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function - # helm is already installed as part of install_kubeadm_cluster.sh - # Generate helm values to be passed with -f osm-values.yaml sudo mkdir -p ${OSM_HELM_WORK_DIR} if [ -n "${INSTALL_JUJU}" ]; then @@ -325,7 +323,7 @@ function deploy_charmed_services() { #deploy mongodb function deploy_mongodb() { [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function - MONGO_OPTS="-d ${OSM_HELM_WORK_DIR} -D ${OSM_DEVOPS} -t ${OSM_DOCKER_TAG} -U ${DOCKER_USER} ${DEBUG_INSTALL}" + MONGO_OPTS="-d ${OSM_HELM_WORK_DIR} -D ${OSM_DEVOPS} -s ${OSM_NAMESPACE} -t ${OSM_DOCKER_TAG} -U ${DOCKER_USER} ${DEBUG_INSTALL}" [ -n "${DOCKER_REGISTRY_URL}" ] && MONGO_OPTS="${MONGO_OPTS} -r ${DOCKER_REGISTRY_URL}" $OSM_DEVOPS/installers/install_mongodb.sh ${MONGO_OPTS} || \ FATAL_TRACK install_osm_mongodb_service "install_mongodb.sh failed" @@ -334,7 +332,7 @@ function deploy_mongodb() { function install_osm_ngsa_service() { [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function - NGSA_OPTS="-i ${OSM_DEFAULT_IP} -d ${OSM_HELM_WORK_DIR} -D ${OSM_DEVOPS} -t ${OSM_DOCKER_TAG} -U ${DOCKER_USER} ${DEBUG_INSTALL}" + NGSA_OPTS="-i ${OSM_DEFAULT_IP} -d ${OSM_HELM_WORK_DIR} -D ${OSM_DEVOPS} -s ${OSM_NAMESPACE} -t ${OSM_DOCKER_TAG} -U ${DOCKER_USER} ${DEBUG_INSTALL}" [ -n "${DOCKER_REGISTRY_URL}" ] && NGSA_OPTS="${NGSA_OPTS} -r ${DOCKER_REGISTRY_URL}" $OSM_DEVOPS/installers/install_ngsa.sh ${NGSA_OPTS} || \ FATAL_TRACK install_osm_ngsa_service "install_ngsa.sh failed" @@ -640,8 +638,7 @@ function arrange_docker_default_network_policy() { function install_k8s_monitoring() { [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function # install OSM monitoring - sudo chmod +x $OSM_DEVOPS/installers/k8s/*.sh - sudo $OSM_DEVOPS/installers/k8s/install_osm_k8s_monitoring.sh || FATAL_TRACK install_k8s_monitoring "k8s/install_osm_k8s_monitoring.sh failed" + sudo $OSM_DEVOPS/installers/k8s/install_osm_k8s_monitoring.sh -o ${OSM_NAMESPACE} || FATAL_TRACK install_k8s_monitoring "k8s/install_osm_k8s_monitoring.sh failed" [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } diff --git a/installers/install_mongodb.sh b/installers/install_mongodb.sh index d13fc1e2..984eda14 100755 --- a/installers/install_mongodb.sh +++ b/installers/install_mongodb.sh @@ -29,7 +29,7 @@ function install_mongodb() { helm repo add bitnami https://charts.bitnami.com/bitnami helm repo update - helm upgrade mongodb-k8s bitnami/mongodb -n osm --create-namespace --install -f ${OSM_HELM_WORK_DIR}/mongodb-values.yaml --version ${MONGODB_HELM_VERSION} --timeout 10m || FATAL_TRACK mongodb "Failed installing mongodb helm chart" + helm upgrade mongodb-k8s bitnami/mongodb -n ${OSM_NAMESPACE} --create-namespace --install -f ${OSM_HELM_WORK_DIR}/mongodb-values.yaml --version ${MONGODB_HELM_VERSION} --timeout 10m || FATAL_TRACK mongodb "Failed installing mongodb helm chart" [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } @@ -40,8 +40,9 @@ DOCKER_USER="opensourcemano" OSM_DEVOPS="/usr/share/osm-devops" OSM_DOCKER_TAG="testing-daily" OSM_HELM_WORK_DIR="/etc/osm/helm" +OSM_NAMESPACE="osm" -while getopts ":D:d:t:r:U:-: " o; do +while getopts ":D:d:s:t:r:U:-: " o; do case "${o}" in D) OSM_DEVOPS="${OPTARG}" @@ -49,6 +50,9 @@ while getopts ":D:d:t:r:U:-: " o; do d) OSM_HELM_WORK_DIR="${OPTARG}" ;; + s) + OSM_NAMESPACE="${OPTARG}" + ;; t) OSM_DOCKER_TAG="${OPTARG}" ;; @@ -84,5 +88,6 @@ echo "DEBUG_INSTALL=$DEBUG_INSTALL" echo "OSM_DEVOPS=$OSM_DEVOPS" echo "OSM_DOCKER_TAG=$OSM_DOCKER_TAG" echo "OSM_HELM_WORK_DIR=$OSM_HELM_WORK_DIR" +echo "OSM_NAMESPACE=$OSM_NAMESPACE" install_mongodb diff --git a/installers/install_ngsa.sh b/installers/install_ngsa.sh index 0a4f03ab..347ab489 100755 --- a/installers/install_ngsa.sh +++ b/installers/install_ngsa.sh @@ -34,7 +34,7 @@ function install_airflow() { 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" + 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" [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } @@ -45,9 +45,10 @@ DOCKER_USER="opensourcemano" OSM_DEVOPS="/usr/share/osm-devops" OSM_DOCKER_TAG="testing-daily" OSM_HELM_WORK_DIR="/etc/osm/helm" +OSM_NAMESPACE="osm" DEFAULT_IP="127.0.0.1" -while getopts ":D:d:i:t:r:U:-: " o; do +while getopts ":D:d:i:s:t:r:U:-: " o; do case "${o}" in i) DEFAULT_IP="${OPTARG}" @@ -58,6 +59,9 @@ while getopts ":D:d:i:t:r:U:-: " o; do d) OSM_HELM_WORK_DIR="${OPTARG}" ;; + s) + OSM_NAMESPACE="${OPTARG}" + ;; t) OSM_DOCKER_TAG="${OPTARG}" ;; @@ -94,6 +98,7 @@ echo "DEBUG_INSTALL=$DEBUG_INSTALL" echo "OSM_DEVOPS=$OSM_DEVOPS" echo "OSM_DOCKER_TAG=$OSM_DOCKER_TAG" echo "OSM_HELM_WORK_DIR=$OSM_HELM_WORK_DIR" +echo "OSM_NAMESPACE=$OSM_NAMESPACE" install_airflow track deploy_osm airflow_ok diff --git a/installers/k8s/install_osm_k8s_monitoring.sh b/installers/k8s/install_osm_k8s_monitoring.sh index dc23fa94..57af8ced 100755 --- a/installers/k8s/install_osm_k8s_monitoring.sh +++ b/installers/k8s/install_osm_k8s_monitoring.sh @@ -37,7 +37,8 @@ function usage(){ echo -e "usage: $0 [OPTIONS]" echo -e "Install OSM Monitoring" echo -e " OPTIONS" - echo -e " -n : use specified kubernetes namespace - default: monitoring" + echo -e " -n : namespace to deploy k8s cluster monitoring - default: monitoring" + echo -e " -o : namespace where OSM is installed - default: osm" echo -e " -s : service type (ClusterIP|NodePort|LoadBalancer) - default: NodePort" echo -e " --debug : debug script" echo -e " --dump : dump arguments and versions" @@ -45,11 +46,12 @@ function usage(){ } NAMESPACE=monitoring +OSM_NAMESPACE=osm HELM="" DEBUG="" DUMP_VARS="" SERVICE_TYPE="" -while getopts ":h-:n:s:" o; do +while getopts ":h-:n:o:s:" o; do case "${o}" in h) usage && exit 0 @@ -57,11 +59,12 @@ while getopts ":h-:n:s:" o; do n) NAMESPACE="${OPTARG}" ;; - + o) + OSM_NAMESPACE="${OPTARG}" + ;; s) SERVICE_TYPE="${OPTARG}" ;; - -) [ "${OPTARG}" == "help" ] && usage && exit 0 [ "${OPTARG}" == "debug" ] && DEBUG="y" && continue @@ -83,6 +86,7 @@ done function dump_vars(){ echo "Args...." echo "NAMESPACE=$NAMESPACE" + echo "OSM_NAMESPACE=$OSM_NAMESPACE" echo "SERVICE_TYPE=$SERVICE_TYPE" echo "DEBUG=$DEBUG" echo "Versions...." @@ -202,7 +206,7 @@ kubectl -n $NAMESPACE apply -f $HERE/mongodb-exporter-dashboard.yaml # Mysql # exporter echo "Creating prometheus-community/prometheus-mysql-exporter" -helm install osm-mysql-exporter --namespace $NAMESPACE --version=$V_MYSQL_EXPORTER --set serviceMonitor.enabled=true,serviceMonitor.additionalLabels.release=osm-monitoring,mysql.user="root",mysql.pass=`kubectl -n osm get secret ro-db-secret -o yaml | grep -i -A1 '^data:$' | grep MYSQL_ROOT_PASSWORD | awk '{print $2}' | base64 -d`,mysql.host="mysql.osm",mysql.port="3306",'collectors.info_schema\.tables=true' prometheus-community/prometheus-mysql-exporter +helm install osm-mysql-exporter --namespace $NAMESPACE --version=$V_MYSQL_EXPORTER --set serviceMonitor.enabled=true,serviceMonitor.additionalLabels.release=osm-monitoring,mysql.user="root",mysql.pass=`kubectl -n ${OSM_NAMESPACE} get secret ro-db-secret -o yaml | grep -i -A1 '^data:$' | grep MYSQL_ROOT_PASSWORD | awk '{print $2}' | base64 -d`,mysql.host="mysql.osm",mysql.port="3306",'collectors.info_schema\.tables=true' prometheus-community/prometheus-mysql-exporter #dashboard: kubectl -n $NAMESPACE apply -f $HERE/mysql-exporter-dashboard.yaml # Kafka