Configure dashboard via values

1/13/2019

As the title indicates I'm trying to setup grafana using helmfile with a default dashboard via values.

The relevant part of my helmfile is here

releases:
...
  - name: grafana
    namespace: grafana
    chart: stable/grafana
    values:
      - datasources:
          datasources.yaml:
            apiVersion: 1
            datasources:
              - name: Prometheus
                type: prometheus
                access: proxy
                url: http://prometheus-server.prometheus.svc.cluster.local
                isDefault: true
      - dashboardProviders:
          dashboardproviders.yaml:
            apiVersion: 1
            providers:
            - name: 'default'
              orgId: 1
              folder: ''
              type: file
              disableDeletion: false
              editable: true
              options:
                path: /var/lib/grafana/dashboards
      - dashboards:
            default:
              k8s:
                url: https://grafana.com/api/dashboards/8588/revisions/1/download

As far as I can understand by reading here I need a provider and then I can refer to a dashboard by url. However when I do as shown above no dashboard is installed and when I do as below (which as )

      - dashboards:
          default:
            url: https://grafana.com/api/dashboards/8588/revisions/1/download

I get the following error message

Error: render error in "grafana/templates/deployment.yaml": template: grafana/templates/deployment.yaml:148:20: executing "grafana/templates/deployment.yaml" at <$value>: wrong type for value; expected map[string]interface {}; got string

Any clues about what I'm doing wrong?

-- user672009
grafana
helmfile
kubernetes

1 Answer

1/14/2019

I think the problem is that you're defining the datasources, dashboardProviders and dashboards as lists rather than maps so you need to remove the hyphens, meaning that the values section becomes:

values:
  datasources:
    datasources.yaml:
      apiVersion: 1
      datasources:
      - name: Prometheus
        type: prometheus
        url: http://prometheus-prometheus-server
        access: proxy
        isDefault: true
  dashboardProviders:
    dashboardproviders.yaml:
      apiVersion: 1
      providers:
      - name: 'default'
        orgId: 1
        folder: ''
        type: file
        disableDeletion: false
        editable: true
        options:
          path: /var/lib/grafana/dashboards
  dashboards:
    default:
      k8s:
        url: https://grafana.com/api/dashboards/8588/revisions/1/download

The grafana chart has them as maps and using helmfile doesn't change that

-- Ryan Dawson
Source: StackOverflow