diff --git a/deploy/tfs.sh b/deploy/tfs.sh index 905cce80e7b0db107b486dc8065adaf7710c1e75..be83d7f5b2669abe8330adefa8a8feac27a1dab8 100755 --- a/deploy/tfs.sh +++ b/deploy/tfs.sh @@ -338,17 +338,12 @@ if [[ "$TFS_COMPONENTS" == *"webui"* ]]; then echo "Configuring WebUI DataStores and Dashboards..." sleep 5 - # INGRESS_CTRL_NAME=$(echo "${TFS_K8S_NAMESPACE}" | sed "s/tfs/nginx-ingress-microk8s-controller/g") - # EXT_HTTP_PORT=$(kubectl get daemonsets.apps --namespace ingress ${INGRESS_CTRL_NAME} \ - # -o 'jsonpath={.spec.template.spec.containers[?(@.name=="nginx-ingress-microk8s")].ports[?(@.name=="http")].hostPort}') - - # get IP and port of grafana in the `monitoring` namespace - GRAFANA_IP=$(kubectl get service/grafana -n monitoring -o jsonpath='{.spec.clusterIP}') - #GRAFANA_PORT=3000 #$(kubectl get service webuiservice --namespace $TFS_K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==3000)].nodePort}') + INGRESS_CTRL_NAME=$(echo "${TFS_K8S_NAMESPACE}" | sed "s/tfs/nginx-ingress-microk8s-controller/g") + EXT_HTTP_PORT=$(kubectl get daemonsets.apps --namespace ingress ${INGRESS_CTRL_NAME} \ + -o 'jsonpath={.spec.template.spec.containers[?(@.name=="nginx-ingress-microk8s")].ports[?(@.name=="http")].hostPort}') # Exposed through the ingress controller "tfs-ingress" - # GRAFANA_URL="127.0.0.1:${EXT_HTTP_PORT}/grafana" - GRAFANA_URL="${GRAFANA_IP}:${GRAF_EXT_PORT_HTTP}" + GRAFANA_URL="127.0.0.1:${EXT_HTTP_PORT}/grafana" # Default Grafana credentials when installed with the `monitoring` addon GRAFANA_USERNAME="admin" @@ -429,6 +424,20 @@ if [[ "$TFS_COMPONENTS" == *"webui"* ]]; then }' ${GRAFANA_URL_UPDATED}/api/datasources printf "\n\n" + # adding the datasource of the metrics collection framework + curl -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d '{ + "access" : "proxy", + "type" : "prometheus", + "name" : "Prometheus", + "url" : "http://prometheus-k8s.monitoring.svc:9090", + "basicAuth": false, + "isDefault": false, + "jsonData" : { + "httpMethod" : "POST" + } + }' ${GRAFANA_URL_UPDATED}/api/datasources + printf "\n\n" + echo ">> Creating dashboards..." # Ref: https://grafana.com/docs/grafana/latest/http_api/dashboard/ curl -X POST -H "Content-Type: application/json" -d '@src/webui/grafana_db_mon_kpis_psql.json' \ diff --git a/manifests/webuiservice.yaml b/manifests/webuiservice.yaml index 255ee68a21a492b3d9ee1cb8f998ce4c2f0986ee..b6ddfc0a91ae5316969079c517e148f63fb18b61 100644 --- a/manifests/webuiservice.yaml +++ b/manifests/webuiservice.yaml @@ -61,6 +61,43 @@ spec: limits: cpu: 500m memory: 512Mi + - name: grafana + image: grafana/grafana:8.5.22 + imagePullPolicy: IfNotPresent + ports: + - containerPort: 3000 + name: http-grafana + protocol: TCP + env: + - name: GF_SERVER_ROOT_URL + value: "http://0.0.0.0:3000/grafana/" + - name: GF_SERVER_SERVE_FROM_SUB_PATH + value: "true" + readinessProbe: + failureThreshold: 3 + httpGet: + path: /robots.txt + port: 3000 + scheme: HTTP + initialDelaySeconds: 10 + periodSeconds: 30 + successThreshold: 1 + timeoutSeconds: 2 + livenessProbe: + failureThreshold: 3 + initialDelaySeconds: 30 + periodSeconds: 10 + successThreshold: 1 + tcpSocket: + port: 3000 + timeoutSeconds: 1 + resources: + requests: + cpu: 150m + memory: 512Mi + limits: + cpu: 500m + memory: 1024Mi --- apiVersion: v1 kind: Service