grafana / helm-charts

Apache License 2.0
1.61k stars 2.24k forks source link

does not add a label for dashboards to configmap #44

Open AndriiKhodyriev opened 3 years ago

AndriiKhodyriev commented 3 years ago

I saw this problem. When I load the dashboard (below values.yaml file)

persistence:
  enable: true
  type: pvc
  existingClaim: grafana-pvc

ingress:
  enabled: true
  tls:
    - hosts:
      - my.hostname
  hosts:
    - my.hostname
rbac:
  create: true
  pspEnabled: false
  namespaced: true
testFramework:
  enabled: false

dashboards:
  dashboard1:
    dashboard1:
      file: dashboards/dashboard1.json
  dashboard2:
    dashboard2:
      file: dashboards/dashboard2.json
  dashboard3:
    dashboard3:
      file: dashboards/dashboard3.json
  dashboard4:
    dashboard4:
      file: dashboards/dashboard4.json
  dashboard5:
    dashboard5:
      file: dashboards/dashboard5.json

admin:
  existingSecret: grafana-admin-creds
  userKey: admin-user
  passwordKey: admin-password
  dashboards:
    enabled: true
  datasources:
    enabled: true

sidecar:
  dashboards:
    enabled: true
  datasources:
    enabled: true

I use sidecar to connect dashboards and sidecar looks for configmap with label "grafana_dashboard"

But after the deployment, I see that the config maps are being created, but the required label is not in them.

I'll take a look at the template. And I see that all the labels there are taken from a certain variable grafana.labels

It doesn't have it.

How to be in such a situation?

AndriiKhodyriev commented 3 years ago

Template:

...
metadata:
  name: {{ template "grafana.fullname" $ }}-dashboards-{{ $provider }}
  namespace: {{ template "grafana.namespace" $ }}
  labels:
    {{- include "grafana.labels" $ | nindent 4 }}
    dashboard-provider: {{ $provider }}
...
AndriiKhodyriev commented 3 years ago

Grafana labels :

{{/*
Common labels
*/}}
{{- define "grafana.labels" -}}
helm.sh/chart: {{ include "grafana.chart" . }}
{{ include "grafana.selectorLabels" . }}
{{- if or .Chart.AppVersion .Values.image.tag }}
app.kubernetes.io/version: {{ .Values.image.tag | default .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}