<p>As the title indicates I'm trying to setup grafana using helmfile with a datasource via values.</p>

<p>I can find the docs <a href="https://github.com/helm/charts/tree/master/stable/grafana" rel="noreferrer">here</a> but sadly my knowledge is too limited to make it work.</p>

<p>The relevant part of my helmfile is here</p>

<pre><code>releases:
...
  - name: grafana
    namespace: grafana
    chart: stable/grafana
    values:
      - datasources:
        - name: Prometheus
          type: prometheus
          url: http://prometheus-server.prometheus.svc.cluster.local
</code></pre>

<p>I stumbled upon <a href="https://github.com/cloudposse/helmfiles/pull/4#pullrequestreview-142973932" rel="noreferrer">this</a> and it seems I can also do it via an environment variable but I can't seem to find an easy way to set such in my helmfile.</p>

<p>It would be greatly appreciated if someone with a better understanding of helmfile, json and whatnot could either show me or guide me in the right direction.</p>

<p><strong>Update</strong>: Thanks to @WindyFields my final solution is as follows</p>

<pre><code>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
</code></pre>

user672009
<p><strong>Answer</strong></p>

<p>Just add the following snipped straight into <code>values.yaml</code>:</p>

<pre><code>datasources:
  datasources.yaml:
    apiVersion: 1
    datasources:
    - name: Prometheus
      type: prometheus
      url: http://prometheus-server.prometheus.svc.cluster.local
</code></pre>

<p><strong>Details</strong></p>

<p>After Helm renders the template there will be the following configmap generated:</p>

<pre><code># Source: grafana/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: RELEASE-NAME-grafana
  labels:
    app: grafana
    chart: grafana-1.20.0
    release: RELEASE-NAME
    heritage: Tiller
data:
  grafana.ini: |
    ...
  datasources.yaml: |
    apiVersion: 1
    datasources:
    - name: Prometheus
      type: prometheus
      url: http://prometheus-server.prometheus.svc.cluster.local 
</code></pre>

<p>After Helms installs the chart, k8s will take datasources configuration <code>datatsources.yaml</code> from <code>config.yaml</code> and mount it by the following path <code>/etc/grafana/provisioning/datasources/datasources.yaml</code>, where it will be picked up by Grafana app. </p>

<p>See Grafana <a href="http://docs.grafana.org/administration/provisioning/" rel="noreferrer">datasources provisioning doc</a>.</p>

<p><strong>Tip:</strong> to see rendered Helm template use <code>helm template &lt;path_to_chart&gt;</code></p>
