From 81678fd2864998552a9986ed1516a565dfe12de7 Mon Sep 17 00:00:00 2001 From: beierlm Date: Fri, 25 Aug 2023 23:01:44 +0200 Subject: [PATCH] Revert "Integrate grafana-k8s and prometheus-k8s" This reverts commit d8b4673088b0a120e3e6a2dcdafd40aee8799662. Reason for revert: Grafana-k8s requires Juju 3.1 and we are not ready to change Juju versions at this time Change-Id: Ieb3d7d3713a180ab5cc45cd01cec31d4110512a0 Signed-off-by: Mark Beierl --- installers/charm/bundles/osm-ha/bundle.yaml | 24 +++++-- installers/charm/bundles/osm/bundle.yaml | 25 ++++--- installers/charmed_install.sh | 76 +++++---------------- 3 files changed, 50 insertions(+), 75 deletions(-) diff --git a/installers/charm/bundles/osm-ha/bundle.yaml b/installers/charm/bundles/osm-ha/bundle.yaml index 6ae48e1e..a4e84d31 100644 --- a/installers/charm/bundles/osm-ha/bundle.yaml +++ b/installers/charm/bundles/osm-ha/bundle.yaml @@ -124,15 +124,19 @@ applications: channel: latest/stable scale: 3 prometheus: - charm: prometheus-k8s - channel: latest/edge + charm: osm-prometheus + channel: latest/stable scale: 1 + series: kubernetes storage: - database: 50M + data: 50M + options: + default-target: "mon:8000" grafana: - charm: grafana-k8s - channel: latest/edge + charm: osm-grafana + channel: latest/stable scale: 3 + series: kubernetes keystone: charm: osm-keystone channel: latest/beta @@ -140,6 +144,8 @@ applications: resources: keystone-image: opensourcemano/keystone:testing-daily relations: + - - grafana:prometheus + - prometheus:prometheus - - kafka:zookeeper - zookeeper:zookeeper - - keystone:db @@ -172,10 +178,12 @@ relations: - kafka:kafka - - nbi:ingress - ingress:ingress + - - nbi:prometheus + - prometheus:prometheus - - nbi:keystone - keystone:keystone - - - mon:metrics-endpoint - - prometheus:metrics-endpoint + - - mon:prometheus + - prometheus:prometheus - - ng-ui:nbi - nbi:nbi - - ng-ui:ingress @@ -184,3 +192,5 @@ relations: - keystone:keystone - - mariadb:mysql - pol:mysql + - - grafana:db + - mariadb:mysql diff --git a/installers/charm/bundles/osm/bundle.yaml b/installers/charm/bundles/osm/bundle.yaml index 9f6023c4..b2db446c 100644 --- a/installers/charm/bundles/osm/bundle.yaml +++ b/installers/charm/bundles/osm/bundle.yaml @@ -123,15 +123,19 @@ applications: channel: latest/stable scale: 1 prometheus: - charm: prometheus-k8s - channel: latest/edge + charm: osm-prometheus + channel: latest/stable scale: 1 + series: kubernetes storage: - database: 50M + data: 50M + options: + default-target: "mon:8000" grafana: - charm: grafana-k8s - channel: latest/edge + charm: osm-grafana + channel: latest/stable scale: 1 + series: kubernetes keystone: charm: osm-keystone channel: latest/beta @@ -139,6 +143,8 @@ applications: resources: keystone-image: opensourcemano/keystone:testing-daily relations: + - - grafana:prometheus + - prometheus:prometheus - - kafka:zookeeper - zookeeper:zookeeper - - keystone:db @@ -171,10 +177,12 @@ relations: - kafka:kafka - - nbi:ingress - ingress:ingress + - - nbi:prometheus + - prometheus:prometheus - - nbi:keystone - keystone:keystone - - - mon:metrics-endpoint - - prometheus:metrics-endpoint + - - mon:prometheus + - prometheus:prometheus - - ng-ui:nbi - nbi:nbi - - ng-ui:ingress @@ -183,4 +191,5 @@ relations: - keystone:keystone - - mariadb:mysql - pol:mysql - + - - grafana:db + - mariadb:mysql diff --git a/installers/charmed_install.sh b/installers/charmed_install.sh index 2ddc797c..1e406ddb 100755 --- a/installers/charmed_install.sh +++ b/installers/charmed_install.sh @@ -283,17 +283,7 @@ function deploy_charmed_osm(){ hostport="$(echo ${url/$user@/} | cut -d/ -f1)" API_SERVER="$(echo $hostport | sed -e 's,:.*,,g')" fi - - configure_vca_integrator - expose_osm_services - echo "Waiting for deployment to finish..." - check_osm_deployed_before_config - config_grafana_and_prometheus - check_osm_deployed_after_config - echo "OSM with charms deployed" -} - -function configure_vca_integrator(){ + # Configure VCA Integrator if [ ! -v INSTALL_NOLXD ]; then juju config vca \ k8s-cloud=microk8s \ @@ -308,61 +298,22 @@ function configure_vca_integrator(){ accounts="`cat ~/.local/share/juju/accounts.yaml`" \ public-key="`cat ~/.local/share/juju/ssh/juju_id_rsa.pub`" fi -} - -function expose_osm_services(){ + # Expose OSM services juju config -m $MODEL_NAME nbi external-hostname=nbi.${API_SERVER}.nip.io juju config -m $MODEL_NAME ng-ui external-hostname=ui.${API_SERVER}.nip.io - juju config -m $MODEL_NAME grafana web_external_url=https://grafana.${API_SERVER}.nip.io -} + juju config -m $MODEL_NAME grafana site_url=https://grafana.${API_SERVER}.nip.io + juju config -m $MODEL_NAME prometheus site_url=https://prometheus.${API_SERVER}.nip.io -function config_grafana_and_prometheus() { - echo "Setting Grafana and Prometheus configuration" + echo "Waiting for deployment to finish..." + check_osm_deployed grafana_leader=`juju status -m $MODEL_NAME grafana | grep "*" | cut -d "*" -f 1` - grafana_admin_password=`juju run-action -m $MODEL_NAME $grafana_leader get-admin-password --wait | grep "admin-password" | cut -d ":" -f 2` - juju config -m $MODEL_NAME mon grafana-password="$grafana_admin_password" - juju config -m $MODEL_NAME mon grafana-user=admin - juju config -m $MODEL_NAME mon grafana-url=http://grafana:3000 - prometheus_url="http://prometheus:9090" - juju config -m $MODEL_NAME mon prometheus-url=$prometheus_url - juju config -m $MODEL_NAME nbi prometheus-url=$prometheus_url - mon_leader=`juju status -m $MODEL_NAME mon | grep "*" | cut -d "*" -f 1` - juju run-action --m $MODEL_NAME $mon_leader create-datasource name=osm_prometheus url=$prometheus_url --wait -} - -function check_osm_deployed_before_config() { - TIME_TO_WAIT=600 - start_time="$(date -u +%s)" - total_active_services=13 - [ -n "$INSTALL_PLA" ] && total_active_services=$((total_active_services + 1)) - previous_count=0 - while true - do - juju_status=$(juju status --format json -m $MODEL_NAME) - active_service_count=$(echo $juju_status | jq '.applications[]."application-status".current'| grep active | wc -l) - echo "$active_service_count / $total_active_services services active" - if [ $active_service_count -eq $total_active_services ]; then - mon_is_blocked=$(echo $juju_status | jq '.applications["mon"].units[]."workload-status".current' | grep blocked | wc -l) - nbi_is_blocked=$(echo $juju_status | jq '.applications["nbi"].units[]."workload-status".current' | grep blocked | wc -l) - if [ $mon_is_blocked -a $nbi_is_blocked ]; then - echo "MON and NBI are blocked" - break - fi - fi - if [ $active_service_count -ne $previous_count ]; then - previous_count=$active_service_count - start_time="$(date -u +%s)" - fi - now="$(date -u +%s)" - if [[ $(( now - start_time )) -gt $TIME_TO_WAIT ]];then - echo "Timed out waiting for OSM services to become ready" - FATAL_TRACK deploy_osm "Timed out waiting for services to become ready" - fi - sleep 10 - done + grafana_admin_password=`juju run -m $MODEL_NAME --unit $grafana_leader "echo \\$GF_SECURITY_ADMIN_PASSWORD"` + juju config -m $MODEL_NAME mon grafana-password=$grafana_admin_password + check_osm_deployed + echo "OSM with charms deployed" } -function check_osm_deployed_after_config() { +function check_osm_deployed() { TIME_TO_WAIT=600 start_time="$(date -u +%s)" total_service_count=15 @@ -389,6 +340,8 @@ function check_osm_deployed_after_config() { } function generate_password_overlay() { + # prometheus + web_config_password=`openssl rand -hex 16` # keystone keystone_db_password=`openssl rand -hex 16` keystone_admin_password=`openssl rand -hex 16` @@ -398,6 +351,9 @@ function generate_password_overlay() { mariadb_root_password=`openssl rand -hex 16` cat << EOF > /tmp/password-overlay.yaml applications: + prometheus: + options: + web_config_password: $web_config_password keystone: options: keystone-db-password: $keystone_db_password -- 2.17.1