Feature 7898: Helm chart and script for monitoring K8s based OSM system
[osm/devops.git] / installers / full_install_osm.sh
index 4725287..777c855 100755 (executable)
@@ -53,6 +53,7 @@ function usage(){
     echo -e "     --soui:         install classic build of OSM (Rel THREE v3.1, based on LXD containers, with SO and UI)"
     echo -e "     --lxdimages:    (only for Rel THREE with --soui) download lxd images from OSM repository instead of creating them from scratch"
     echo -e "     --pullimages:   pull/run osm images from docker.io/opensourcemano"
+    echo -e "     --k8s_monitor:  install the OSM kubernetes moitoring with prometheus and grafana"
     echo -e "     -l <lxd_repo>:  (only for Rel THREE with --soui) use specified repository url for lxd images"
     echo -e "     -p <path>:      (only for Rel THREE with --soui) use specified repository path for lxd images"
 #    echo -e "     --reconfigure:  reconfigure the modules (DO NOT change NAT rules)"
@@ -185,6 +186,10 @@ function uninstall_lightweight() {
     else
         echo -e "\nUninstalling OSM"
         if [ -n "$KUBERNETES" ]; then
+            if [ -n "$K8S_MONITOR" ]; then
+                # uninstall OSM MONITORING
+                uninstall_k8s_monitoring
+            fi
             remove_k8s_namespace $OSM_STACK_NAME
         else
             remove_stack $OSM_STACK_NAME
@@ -1237,6 +1242,10 @@ function install_lightweight() {
     generate_docker_env_files
 
     if [ -n "$KUBERNETES" ]; then
+        if [ -n "$K8S_MONITOR" ]; then
+            # uninstall OSM MONITORING
+            uninstall_k8s_monitoring
+        fi
         #remove old namespace
         remove_k8s_namespace $OSM_STACK_NAME
         deploy_cni_provider
@@ -1257,6 +1266,12 @@ function install_lightweight() {
         [ -n "$INSTALL_ELK" ] && deploy_elk && track elk
     fi
 
+    if [ -n "$KUBERNETES" ] && [ -n "$K8S_MONITOR" ]; then
+        # install OSM MONITORING
+        install_k8s_monitoring
+        track install_k8s_monitoring
+    fi
+
     [ -z "$INSTALL_NOHOSTCLIENT" ] && install_osmclient
     track osmclient
 
@@ -1296,6 +1311,18 @@ function install_vimemu() {
     echo "     osm vim-create --name emu-vim1 --user username --password password --auth_url http://${VIMEMU_HOSTNAME}:6001/v2.0 --tenant tenantName --account_type openstack"
 }
 
+function install_k8s_monitoring() {
+    # install OSM monitoring
+    chmod +x $WORKDIR_SUDO $OSM_DEVOPS/installers/k8s/*.sh
+    $WORKDIR_SUDO $OSM_DEVOPS/installers/k8s/install_osm_k8s_monitoring.sh
+}
+
+function uninstall_k8s_monitoring() {
+    # install OSM monitoring
+    chmod +x $WORKDIR_SUDO $OSM_DEVOPS/installers/k8s/*.sh
+    $WORKDIR_SUDO $OSM_DEVOPS/installers/k8s/uninstall_osm_k8s_monitoring.sh
+}
+
 function dump_vars(){
     echo "DEVELOP=$DEVELOP"
     echo "INSTALL_FROM_SOURCE=$INSTALL_FROM_SOURCE"
@@ -1379,6 +1406,7 @@ INSTALL_NOLXD=""
 INSTALL_NODOCKER=""
 INSTALL_NOJUJU=""
 KUBERNETES=""
+K8S_MONITOR=""
 INSTALL_NOHOSTCLIENT=""
 NOCONFIGURE=""
 RELEASE_DAILY=""
@@ -1526,6 +1554,7 @@ while getopts ":hy-:b:r:c:k:u:R:l:p:D:o:m:H:S:s:w:t:U:P:A:" o; do
             [ "${OPTARG}" == "nodockerbuild" ] && DOCKER_NOBUILD="y" && continue
             [ "${OPTARG}" == "nohostclient" ] && INSTALL_NOHOSTCLIENT="y" && continue
             [ "${OPTARG}" == "pullimages" ] && continue
+            [ "${OPTARG}" == "k8s_monitor" ] && K8S_MONITOR="y" && continue
             echo -e "Invalid option: '--$OPTARG'\n" >&2
             usage && exit 1
             ;;