2

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
  • 4,379
  • 8
  • 44
  • 77

1 Answers1

2

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
  • 11,832
  • 5
  • 38
  • 61
  • Thanks for your reply. But that gives me unmarshaling errors. And also, datasources works. – user672009 Jan 14 '19 at 20:53
  • What I did was run 'helm install' with '--dry-run --debug' to see what the stable/grafana chart would accept. So I wasn't using helmfile - I took my values file and matched it to yours. I used the second link to check against an example helmfile. I see the second link is already broken as that repo has changed - https://github.com/cloudposse/helmfiles was what I was linking to and might be useful as it has example helmfiles – Ryan Dawson Jan 15 '19 at 07:51