From bb9ed7816ced330f048db4b122bc4ea47cad113b Mon Sep 17 00:00:00 2001 From: ryandawsonuk Date: Mon, 29 Apr 2019 17:33:08 +0100 Subject: [PATCH 1/2] import jobs still not working --- .../files/grafana/configs/import-dashboards-job.sh | 11 ++++++++--- .../templates/grafana-prom-import-dashboards-job.json | 6 +++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/helm-charts/seldon-core-analytics/files/grafana/configs/import-dashboards-job.sh b/helm-charts/seldon-core-analytics/files/grafana/configs/import-dashboards-job.sh index 0019f0d58b..083e606e1c 100755 --- a/helm-charts/seldon-core-analytics/files/grafana/configs/import-dashboards-job.sh +++ b/helm-charts/seldon-core-analytics/files/grafana/configs/import-dashboards-job.sh @@ -4,6 +4,11 @@ GRAFANA_PASS=${GF_SECURITY_ADMIN_PASSWORD} HOST=grafana-prom PORT=80 +if [ -z "${GRAFANA_PASS}" ] +then + GRAFANA_AUTH="${GRAFANA_USER}:${GRAFANA_PASS}@" +fi + # For DEV outside of cluster if [ ! -e /var/run/secrets/kubernetes.io/serviceaccount ]; then HOST=localhost @@ -36,9 +41,9 @@ check_connection() { } recreate_datasource() { - curl --silent --fail --show-error --request DELETE http://${GRAFANA_USER}:${GRAFANA_PASS}@${HOST}:${PORT}/api/datasources/name/prometheus + curl --silent --fail --show-error --request DELETE http://${GRAFANA_AUTH}${HOST}:${PORT}/api/datasources/name/prometheus - curl --silent --fail --show-error --request POST http://${GRAFANA_USER}:${GRAFANA_PASS}@${HOST}:${PORT}/api/datasources --header "Content-Type: application/json" --data-binary "@prometheus-datasource.json" + curl --silent --fail --show-error --request POST http://${GRAFANA_AUTH}${HOST}:${PORT}/api/datasources --header "Content-Type: application/json" --data-binary "@prometheus-datasource.json" } add_dashboard() { @@ -50,7 +55,7 @@ add_dashboard() { ( echo '{"dashboard":'; cat "$file"; echo ',"overwrite":true,"inputs":[{"name":"'${SRC_NAME}'","type":"datasource","pluginId":"prometheus","value":"prometheus"}]}' - ) | jq -c '.' | curl --silent --fail --show-error --request POST http://${GRAFANA_USER}:${GRAFANA_PASS}@${HOST}:${PORT}/api/dashboards/import --header "Content-Type: application/json" --data-binary "@-" + ) | jq -c '.' | curl --silent --fail --show-error --request POST http://${GRAFANA_AUTH}${HOST}:${PORT}/api/dashboards/import --header "Content-Type: application/json" --data-binary "@-" } diff --git a/helm-charts/seldon-core-analytics/templates/grafana-prom-import-dashboards-job.json b/helm-charts/seldon-core-analytics/templates/grafana-prom-import-dashboards-job.json index 1ae2238839..5dbec5750d 100644 --- a/helm-charts/seldon-core-analytics/templates/grafana-prom-import-dashboards-job.json +++ b/helm-charts/seldon-core-analytics/templates/grafana-prom-import-dashboards-job.json @@ -18,6 +18,8 @@ "import-dashboards-job.sh" ], "env": [ + + {{ if not (.Values.grafana_anonymous_auth) }} { "name": "GF_SECURITY_ADMIN_PASSWORD", "valueFrom": { @@ -26,7 +28,9 @@ "name": "grafana-prom-secret" } } - } + }, + {{ end}} + ], "image": "giantswarm/tiny-tools:0.2.0", "name": "tools", From 9fea35a89eeb90105ecd4a1dd50dad8c2da29dc2 Mon Sep 17 00:00:00 2001 From: ryandawsonuk Date: Mon, 29 Apr 2019 18:08:45 +0100 Subject: [PATCH 2/2] allow anonymous access but authenticate for job imports --- .../grafana/configs/import-dashboards-job.sh | 11 +++-------- .../templates/grafana-prom-deployment.json | 15 +-------------- .../grafana-prom-import-dashboards-job.json | 2 -- 3 files changed, 4 insertions(+), 24 deletions(-) diff --git a/helm-charts/seldon-core-analytics/files/grafana/configs/import-dashboards-job.sh b/helm-charts/seldon-core-analytics/files/grafana/configs/import-dashboards-job.sh index 083e606e1c..0019f0d58b 100755 --- a/helm-charts/seldon-core-analytics/files/grafana/configs/import-dashboards-job.sh +++ b/helm-charts/seldon-core-analytics/files/grafana/configs/import-dashboards-job.sh @@ -4,11 +4,6 @@ GRAFANA_PASS=${GF_SECURITY_ADMIN_PASSWORD} HOST=grafana-prom PORT=80 -if [ -z "${GRAFANA_PASS}" ] -then - GRAFANA_AUTH="${GRAFANA_USER}:${GRAFANA_PASS}@" -fi - # For DEV outside of cluster if [ ! -e /var/run/secrets/kubernetes.io/serviceaccount ]; then HOST=localhost @@ -41,9 +36,9 @@ check_connection() { } recreate_datasource() { - curl --silent --fail --show-error --request DELETE http://${GRAFANA_AUTH}${HOST}:${PORT}/api/datasources/name/prometheus + curl --silent --fail --show-error --request DELETE http://${GRAFANA_USER}:${GRAFANA_PASS}@${HOST}:${PORT}/api/datasources/name/prometheus - curl --silent --fail --show-error --request POST http://${GRAFANA_AUTH}${HOST}:${PORT}/api/datasources --header "Content-Type: application/json" --data-binary "@prometheus-datasource.json" + curl --silent --fail --show-error --request POST http://${GRAFANA_USER}:${GRAFANA_PASS}@${HOST}:${PORT}/api/datasources --header "Content-Type: application/json" --data-binary "@prometheus-datasource.json" } add_dashboard() { @@ -55,7 +50,7 @@ add_dashboard() { ( echo '{"dashboard":'; cat "$file"; echo ',"overwrite":true,"inputs":[{"name":"'${SRC_NAME}'","type":"datasource","pluginId":"prometheus","value":"prometheus"}]}' - ) | jq -c '.' | curl --silent --fail --show-error --request POST http://${GRAFANA_AUTH}${HOST}:${PORT}/api/dashboards/import --header "Content-Type: application/json" --data-binary "@-" + ) | jq -c '.' | curl --silent --fail --show-error --request POST http://${GRAFANA_USER}:${GRAFANA_PASS}@${HOST}:${PORT}/api/dashboards/import --header "Content-Type: application/json" --data-binary "@-" } diff --git a/helm-charts/seldon-core-analytics/templates/grafana-prom-deployment.json b/helm-charts/seldon-core-analytics/templates/grafana-prom-deployment.json index 4fcf4041d9..ca51106ab9 100644 --- a/helm-charts/seldon-core-analytics/templates/grafana-prom-deployment.json +++ b/helm-charts/seldon-core-analytics/templates/grafana-prom-deployment.json @@ -25,19 +25,7 @@ "name": "GF_AUTH_ANONYMOUS_ENABLED", "value": "true" }, - { - "name": "GF_AUTH_BASIC_ENABLED", - "value": "false" - }, - { - "name": "GF_AUTH_PROXY_ENABLED", - "value": "false" - }, - { - "name": "GF_USERS_ALLOW_SIGN_UP", - "value": "false" - }, - {{ else }} + {{ end }} { "name": "GF_SECURITY_ADMIN_PASSWORD", "valueFrom": { @@ -47,7 +35,6 @@ } } }, - {{ end}} ], "image": "grafana/grafana:5.3.4", "name": "grafana", diff --git a/helm-charts/seldon-core-analytics/templates/grafana-prom-import-dashboards-job.json b/helm-charts/seldon-core-analytics/templates/grafana-prom-import-dashboards-job.json index 5dbec5750d..ef1524996a 100644 --- a/helm-charts/seldon-core-analytics/templates/grafana-prom-import-dashboards-job.json +++ b/helm-charts/seldon-core-analytics/templates/grafana-prom-import-dashboards-job.json @@ -19,7 +19,6 @@ ], "env": [ - {{ if not (.Values.grafana_anonymous_auth) }} { "name": "GF_SECURITY_ADMIN_PASSWORD", "valueFrom": { @@ -29,7 +28,6 @@ } } }, - {{ end}} ], "image": "giantswarm/tiny-tools:0.2.0",