From 0077ae7f2680a69faf77496e40ce3cfca5cc0f7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Alba=20Lozano?= Date: Wed, 23 Jan 2019 10:55:35 +0100 Subject: [PATCH] [stable/grafana] Add gerrit server as dashboard origin (#10711) * [stable/grafana] Add gerrit server as dashboard origin Signed-off-by: cesaralbloz * [stable/grafana] Add gerrit server as dashboard origin Signed-off-by: Cesar Alba Lozano --- stable/grafana/Chart.yaml | 2 +- stable/grafana/README.md | 11 +++++++++++ stable/grafana/templates/configmap.yaml | 6 ++++-- stable/grafana/values.yaml | 3 +++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/stable/grafana/Chart.yaml b/stable/grafana/Chart.yaml index b3378e7115..ca0d07ca61 100755 --- a/stable/grafana/Chart.yaml +++ b/stable/grafana/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: grafana -version: 1.25.2 +version: 1.25.3 appVersion: 5.4.3 kubeVersion: "^1.8.0-0" description: The leading tool for querying and visualizing time series and metrics. diff --git a/stable/grafana/README.md b/stable/grafana/README.md index 97be4b8482..657ef8467c 100644 --- a/stable/grafana/README.md +++ b/stable/grafana/README.md @@ -91,6 +91,17 @@ The command removes all the Kubernetes components associated with the chart and | `rbac.pspEnabled` | Create PodSecurityPolicy (with `rbac.create`, grant roles permissions as well) | `true` | | `rbac.pspUseAppArmor` | Enforce AppArmor in created PodSecurityPolicy (requires `rbac.pspEnabled`) | `true` | +## BASE64 dashboards + +Dashboards could be storaged in a server that does not return JSON directly and instead of it returns a Base64 encoded file (e.g. Gerrit) +A new parameter has been added to the url use case so if you specify a b64content value equals to true after the url entry a Base64 decoding is applied before save the file to disk. +If this entry is not set or is equals to false not decoding is applied to the file before saving it to disk. + +### Gerrit use case: +Gerrit API for download files has the following schema: https://yourgerritserver/a/{project-name}/branches/{branch-id}/files/{file-id}/content where {project-name} and +{file-id} usualy has '/' in their values and so they MUST be replaced by %2F so if project-name is user/repo, branch-id is master and file-id is equals to dir1/dir2/dashboard +the url value is https://yourgerritserver/a/user%2Frepo/branches/master/files/dir1%2Fdir2%2Fdashboard/content + ## Sidecar for dashboards If the parameter `sidecar.dashboards.enabled` is set, a sidecar container is deployed in the grafana pod. This container watches all config maps in the cluster and filters out the ones with a label as defined in `sidecar.dashboards.label`. The files defined in those configmaps are written to a folder and accessed by grafana. Changes to the configmaps are monitored and the imported dashboards are deleted/updated. A recommendation is to use one configmap per dashboard, as an reduction of multiple dashboards inside one configmap is currently not properly mirrored in grafana. diff --git a/stable/grafana/templates/configmap.yaml b/stable/grafana/templates/configmap.yaml index 5fc14c53fc..022b4df139 100644 --- a/stable/grafana/templates/configmap.yaml +++ b/stable/grafana/templates/configmap.yaml @@ -52,11 +52,13 @@ data: curl -sk \ --connect-timeout 60 \ --max-time 60 \ + {{- if not $value.b64content }} -H "Accept: application/json" \ -H "Content-Type: application/json;charset=UTF-8" \ - {{- if $value.url -}}{{ $value.url }}{{- else -}} https://grafana.com/api/dashboards/{{ $value.gnetId }}/revisions/{{- if $value.revision -}}{{ $value.revision }}{{- else -}}1{{- end -}}/download{{- end -}}{{ if $value.datasource }}| sed 's|\"datasource\":[^,]*|\"datasource\": \"{{ $value.datasource }}\"|g'{{ end }} \ - > /var/lib/grafana/dashboards/{{ $provider }}/{{ $key }}.json {{- end }} + {{- if $value.url -}}{{ $value.url }}{{- else -}} https://grafana.com/api/dashboards/{{ $value.gnetId }}/revisions/{{- if $value.revision -}}{{ $value.revision }}{{- else -}}1{{- end -}}/download{{- end -}}{{ if $value.datasource }}| sed 's|\"datasource\":[^,]*|\"datasource\": \"{{ $value.datasource }}\"|g'{{ end }}{{- if $value.b64content -}} | base64 -d {{- end -}} \ + > /var/lib/grafana/dashboards/{{ $provider }}/{{ $key }}.json + {{- end -}} {{- end }} {{- end }} {{- end }} diff --git a/stable/grafana/values.yaml b/stable/grafana/values.yaml index 68ca5f0ca3..eb338816b4 100644 --- a/stable/grafana/values.yaml +++ b/stable/grafana/values.yaml @@ -217,6 +217,9 @@ dashboards: {} # datasource: Prometheus # local-dashboard: # url: https://example.com/repository/test.json +# local-dashboard-base64: +# url: https://example.com/repository/test-b64.json +# b64content: true ## Reference to external ConfigMap per provider. Use provider name as key and ConfiMap name as value. ## A provider dashboards must be defined either by external ConfigMaps or in values.yaml, not in both.