chore(helm): dynamic dashboard creation

Ref: https://github.com/helm/helm/issues/4157#issuecomment-490748085

Signed-off-by: rjshrjndrn <rjshrjndrn@gmail.com>
This commit is contained in:
rjshrjndrn 2022-06-30 14:03:10 +02:00
parent c971c0ff05
commit fd8a770789
4 changed files with 13 additions and 8 deletions

View file

@ -1,15 +1,20 @@
---
# Ref: https://github.com/helm/helm/issues/4157#issuecomment-490748085
{{- $processedDict := dict -}}
{{- range $path, $bytes := .Files.Glob "dashboards/**" }}
{{- $name := base (dir $path) }}
{{- if not (hasKey $processedDict $name) -}}
{{ $_ := set $processedDict $name "true" }}
apiVersion: v1
data:
{{- (.Files.Glob "dashboards/nginx*").AsConfig | nindent 2 }}
kind: ConfigMap
metadata:
annotations:
meta.helm.sh/release-name: observability
meta.helm.sh/release-namespace: observability
name: dashboard-{{ $name }}
namespace: observability
labels:
app: kube-prometheus-stack-grafana
grafana_dashboard: "1"
release: observability
name: nginx-metrics
namespace: observability
data:
{{ ($.Files.Glob (printf "dashboards/%s/*" $name)).AsConfig | indent 2 }}
---
{{- end }}
{{- end }}