Commit bc3dfd4b authored by Carlos Natalino's avatar Carlos Natalino
Browse files

Updates to the database connection of grafana.

parent d646caf9
Loading
Loading
Loading
Loading
+15 −15
Original line number Diff line number Diff line
@@ -202,12 +202,12 @@ if [[ "$TFS_COMPONENTS" == *"webui"* ]] && [[ "$TFS_COMPONENTS" == *"monitoring"
    echo "Configuring WebUI DataStores and Dashboards..."
    sleep 3

    INFLUXDB_HOST="monitoringservice"
    INFLUXDB_PORT=$(kubectl --namespace $TFS_K8S_NAMESPACE get service/monitoringservice -o jsonpath='{.spec.ports[?(@.name=="influxdb")].port}')
    INFLUXDB_URL="http://${INFLUXDB_HOST}:${INFLUXDB_PORT}"
    INFLUXDB_USER=$(kubectl --namespace $TFS_K8S_NAMESPACE get secrets influxdb-secrets -o jsonpath='{.data.INFLUXDB_ADMIN_USER}' | base64 --decode)
    INFLUXDB_PASSWORD=$(kubectl --namespace $TFS_K8S_NAMESPACE get secrets influxdb-secrets -o jsonpath='{.data.INFLUXDB_ADMIN_PASSWORD}' | base64 --decode)
    INFLUXDB_DATABASE=$(kubectl --namespace $TFS_K8S_NAMESPACE get secrets influxdb-secrets -o jsonpath='{.data.INFLUXDB_DB}' | base64 --decode)
    # INFLUXDB_HOST="monitoringservice"
    # INFLUXDB_PORT=$(kubectl --namespace $TFS_K8S_NAMESPACE get service/monitoringservice -o jsonpath='{.spec.ports[?(@.name=="influxdb")].port}')
    # INFLUXDB_URL="http://${INFLUXDB_HOST}:${INFLUXDB_PORT}"
    # INFLUXDB_USER=$(kubectl --namespace $TFS_K8S_NAMESPACE get secrets influxdb-secrets -o jsonpath='{.data.INFLUXDB_ADMIN_USER}' | base64 --decode)
    # INFLUXDB_PASSWORD=$(kubectl --namespace $TFS_K8S_NAMESPACE get secrets influxdb-secrets -o jsonpath='{.data.INFLUXDB_ADMIN_PASSWORD}' | base64 --decode)
    # INFLUXDB_DATABASE=$(kubectl --namespace $TFS_K8S_NAMESPACE get secrets influxdb-secrets -o jsonpath='{.data.INFLUXDB_DB}' | base64 --decode)

    # Exposed through the ingress controller "tfs-ingress"
    GRAFANA_HOSTNAME="127.0.0.1"
@@ -235,18 +235,18 @@ if [[ "$TFS_COMPONENTS" == *"webui"* ]] && [[ "$TFS_COMPONENTS" == *"monitoring"
    }' ${GRAFANA_URL_DEFAULT}/api/user/password
    echo

    # Create InfluxDB DataSource
    # Ref: https://grafana.com/docs/grafana/latest/http_api/data_source/
    curl -X POST -H "Content-Type: application/json" -d '{
        "type"     : "influxdb",
        "name"     : "InfluxDB",
        "url"      : "'"$INFLUXDB_URL"'",
    # TODO: replace user, password and database by variables to be saved
    echo "Creating a datasource..."
    curl -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d '{
        "type"     : "postgres",
        "name"     : "monitoringdb",
        "access"   : "proxy",
        "basicAuth": false,
        "user"     : "'"$INFLUXDB_USER"'",
        "password" : "'"$INFLUXDB_PASSWORD"'",
        "user"     : "admin",
        "password" : "quest",
        "isDefault": true,
        "database" : "'"$INFLUXDB_DATABASE"'"
        "database" : "qdb",
        "sslmode"  :"disable"
    }' ${GRAFANA_URL_UPDATED}/api/datasources
    echo

+2 −2
Original line number Diff line number Diff line
# Set the URL of your local Docker registry where the images will be uploaded to.
export TFS_REGISTRY_IMAGE="" # http://localhost:32000/tfs/
export TFS_REGISTRY_IMAGE="http://localhost:32000/tfs/"

# Set the list of components, separated by comas, you want to build images for, and deploy.
# Supported components are:
@@ -16,7 +16,7 @@ export TFS_IMAGE_TAG="dev"
export TFS_K8S_NAMESPACE="tfs"

# Set additional manifest files to be applied after the deployment
export TFS_EXTRA_MANIFESTS="" # manifests/nginx_ingress_http.yaml
export TFS_EXTRA_MANIFESTS="manifests/nginx_ingress_http.yaml"

# Set the neew Grafana admin password
export TFS_GRAFANA_PASSWORD="admin123+"