<p>I want to deploy Grafana using Kubernetes, but I don't know how to attach provisioned dashboards to the Pod. Storing them as key-value data in a configMap seems to me like a nightmare - example here <a href="https://github.com/do-community/doks-monitoring/blob/master/manifest/dashboards-configmap.yaml" rel="nofollow noreferrer">https://github.com/do-community/doks-monitoring/blob/master/manifest/dashboards-configmap.yaml</a> - in my case it would me much more JSON dashboards - thus the harsh opinion.</p>

<p>I didn't had an issue with configuring the Grafana settings, datasources and dashboard providers as configMaps since they are defined in single files, but the dashboards situation is a little bit more tricky for me. </p>

<p>All of my dashboards are stored in the repo under "/files/dashboards/", and I wondered how to make them available to the Pod, besides the way described earlier. Wondered about using the hostPath object for a sec, but didn't make sense for multi-node deployment on different hosts.</p>

<p>Maybe its easy - but I'm fairly new to Kubernetes and can't figure it out - so any help would be much appreciated. Thank you!</p>

<p>You can automatically generate a ConfigMap from a set fo files in a directory. Each file will be a key-value pair in the ConfigMap with the file name being the key and the file content being the value (like in your linked example but done automatically instead of manually).</p>

<p>Assuming that your dashboard files are stored as, for example:</p>

<pre><code>files/dashboards/
├── k8s-cluster-rsrc-use.json
├── k8s-node-rsrc-use.json
└── k8s-resources-cluster.json
</code></pre>

<p>You can run the following command to directly create the ConfigMap in the cluster:</p>

<pre class="lang-sh prettyprint-override"><code>kubectl create configmap my-config --from-file=files/dashboards
</code></pre>

<p>If you prefer to only generate the YAML manifest for the ConfigMap, you can do:</p>

<pre class="lang-sh prettyprint-override"><code>kubectl create configmap my-config --from-file=files/dashboards --dry-run -o yaml &gt;my-config.yaml
</code></pre>
