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)"
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
remove_stack osm_elk
fi
}
function install_prometheus_nodeexporter(){
- sudo useradd --no-create-home --shell /bin/false node_exporter
- sudo wget -q https://github.com/prometheus/node_exporter/releases/download/v$PROMETHEUS_NODE_EXPORTER_TAG/node_exporter-$PROMETHEUS_NODE_EXPORTER_TAG.linux-amd64.tar.gz -P /tmp/
- sudo tar -C /tmp -xf /tmp/node_exporter-$PROMETHEUS_NODE_EXPORTER_TAG.linux-amd64.tar.gz
- sudo cp /tmp/node_exporter-$PROMETHEUS_NODE_EXPORTER_TAG.linux-amd64/node_exporter /usr/local/bin
- sudo chown node_exporter:node_exporter /usr/local/bin/node_exporter
- sudo rm -rf node_exporter-$PROMETHEUS_NODE_EXPORTER_TAG.linux-amd64*
- sudo cp ${OSM_DEVOPS}/installers/docker/files/node_exporter.service /etc/systemd/system/node_exporter.service
+ if (systemctl -q is-active node_exporter)
+ then
+ echo "Node Exporter is already running."
+ else
+ echo "Node Exporter is not active, installing..."
+ if getent passwd node_exporter > /dev/null 2>&1; then
+ echo "node_exporter user exists"
+ else
+ echo "Creating user node_exporter"
+ sudo useradd --no-create-home --shell /bin/false node_exporter
+ fi
+ sudo wget -q https://github.com/prometheus/node_exporter/releases/download/v$PROMETHEUS_NODE_EXPORTER_TAG/node_exporter-$PROMETHEUS_NODE_EXPORTER_TAG.linux-amd64.tar.gz -P /tmp/
+ sudo tar -C /tmp -xf /tmp/node_exporter-$PROMETHEUS_NODE_EXPORTER_TAG.linux-amd64.tar.gz
+ sudo cp /tmp/node_exporter-$PROMETHEUS_NODE_EXPORTER_TAG.linux-amd64/node_exporter /usr/local/bin
+ sudo chown node_exporter:node_exporter /usr/local/bin/node_exporter
+ sudo rm -rf node_exporter-$PROMETHEUS_NODE_EXPORTER_TAG.linux-amd64*
+ sudo cp ${OSM_DEVOPS}/installers/docker/files/node_exporter.service /etc/systemd/system/node_exporter.service
+ sudo systemctl daemon-reload
+ sudo systemctl restart node_exporter
+ sudo systemctl enable node_exporter
+ echo "Node Exporter has been activated in this host."
+ fi
+ return 0
+}
+
+function uninstall_prometheus_nodeexporter(){
+ sudo systemctl stop node_exporter
+ sudo systemctl disable node_exporter
+ sudo rm /etc/systemd/system/node_exporter.service
sudo systemctl daemon-reload
- sudo systemctl restart node_exporter
- sudo systemctl enable node_exporter
+ sudo userdel node_exporter
+ sudo rm /usr/local/bin/node_exporter
return 0
}
echo "Installing juju"
sudo snap install juju --classic
[ -z "$INSTALL_NOLXD" ] && sudo dpkg-reconfigure -p medium lxd
+ [[ ":$PATH": != *":/snap/bin:"* ]] && PATH="/snap/bin:${PATH}"
echo "Finished installation of juju"
return 0
}
$WORKDIR_SUDO sed -i "s|OSMMON_VCA_SECRET.*|OSMMON_VCA_SECRET=$OSM_VCA_SECRET|g" $OSM_DOCKER_WORK_DIR/mon.env
fi
+ if ! grep -Fq "OSMMON_VCA_CACERT" $OSM_DOCKER_WORK_DIR/mon.env; then
+ echo "OSMMON_VCA_CACERT=${OSM_VCA_CACERT}" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/mon.env
+ else
+ $WORKDIR_SUDO sed -i "s|OSMMON_VCA_CACERT.*|OSMMON_VCA_CACERT=${OSM_VCA_CACERT}|g" $OSM_DOCKER_WORK_DIR/mon.env
+ fi
+
+
# POL
if [ ! -f $OSM_DOCKER_WORK_DIR/pol.env ]; then
echo "OSMPOL_SQL_DATABASE_URI=mysql://root:${MYSQL_ROOT_PASSWORD}@mysql:3306/pol" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/pol.env
OSM_UI_PORT=80
OSM_MON_PORT=8662
OSM_PROM_PORT=9090
+ OSM_PROM_CADVISOR_PORT=8080
OSM_PROM_HOSTPORT=9091
OSM_GRAFANA_PORT=3000
[ -n "$INSTALL_ELK" ] && OSM_ELK_PORT=5601
OSM_PORTS+=(OSM_UI_PORTS=$OSM_UI_PORT)
OSM_PORTS+=(OSM_MON_PORTS=$OSM_MON_PORT)
OSM_PORTS+=(OSM_PROM_PORTS=$OSM_PROM_PORT)
+ OSM_PORTS+=(OSM_PROM_CADVISOR_PORTS=$OSM_PROM_CADVISOR_PORT)
OSM_PORTS+=(OSM_GRAFANA_PORTS=$OSM_GRAFANA_PORT)
#[ -n "$INSTALL_PERFMON" ] && OSM_PORTS+=(OSM_PM_PORTS=$OSM_PM_PORT)
[ -n "$INSTALL_ELK" ] && OSM_PORTS+=(OSM_ELK_PORTS=$OSM_ELK_PORT)
OSM_PORTS+=(OSM_UI_PORTS=$OSM_UI_PORT:$OSM_UI_PORT)
OSM_PORTS+=(OSM_MON_PORTS=$OSM_MON_PORT:$OSM_MON_PORT)
OSM_PORTS+=(OSM_PROM_PORTS=$OSM_PROM_HOSTPORT:$OSM_PROM_PORT)
+ OSM_PORTS+=(OSM_PROM_CADVISOR_PORTS=$OSM_PROM_CADVISOR_PORT:$OSM_PROM_CADVISOR_PORT)
OSM_PORTS+=(OSM_GRAFANA_PORTS=$OSM_GRAFANA_PORT:$OSM_GRAFANA_PORT)
#[ -n "$INSTALL_PERFMON" ] && OSM_PORTS+=(OSM_PM_PORTS=$OSM_PM_PORT:$OSM_PM_PORT)
[ -n "$INSTALL_ELK" ] && OSM_PORTS+=(OSM_ELK_PORTS=$OSM_ELK_PORT:$OSM_ELK_PORT)
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
[ -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
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"
INSTALL_NODOCKER=""
INSTALL_NOJUJU=""
KUBERNETES=""
+K8S_MONITOR=""
INSTALL_NOHOSTCLIENT=""
NOCONFIGURE=""
RELEASE_DAILY=""
[ "${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
;;