post image :date_long | 1 min Read

Create more configMaps via Go templating

{{ 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 }}

author image

Jan Toth

I have been in DevOps related jobs for past 6 years dealing mainly with Kubernetes in AWS and on-premise as well. I spent quite a lot …

comments powered by Disqus