Create more configMaps via Go templating
Create more configMaps via Go templating
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{{ range $path, $_ := .Files.Glob "dashboards/*.json" }}
{{- $dashboardName := trimSuffix ".json" $path | base | replace "_" "-" | lower -}}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: "{{ template "grafana.fullname" $ }}-{{ $dashboardName }}"
namespace: {{ template "grafana.namespace" $ }}
labels:
{{- include "grafana.labels" $ | nindent 4 }}
grafana_dashboard: "1"
data:
{{ $dashboardName }}.json: |-
{{ $.Files.Get $path | indent 4}}
{{ end }}
This post is licensed under CC BY 4.0 by the author.
