Skip to content

Commit 78f8d0e

Browse files
Merge pull request #3669 from refucktor/chore/grafana-init-cont-datasources
[grafana] Add support for custom script and extra mounts in Grafana sidecar
2 parents 589a92f + 4a06e6f commit 78f8d0e

File tree

3 files changed

+36
-12
lines changed

3 files changed

+36
-12
lines changed

charts/grafana/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v2
22
name: grafana
3-
version: 8.13.1
3+
version: 8.13.2
44
appVersion: 11.6.1
55
kubeVersion: "^1.8.0-0"
66
description: The leading tool for querying and visualizing time series and metrics.

charts/grafana/templates/_pod.tpl

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ initContainers:
230230
- name: SKIP_TLS_VERIFY
231231
value: "{{ . }}"
232232
{{- end }}
233+
{{- with .Values.sidecar.datasources.script }}
234+
- name: SCRIPT
235+
value: {{ quote . }}
236+
{{- end }}
233237
{{- with .Values.sidecar.resources }}
234238
resources:
235239
{{- toYaml . | nindent 6 }}
@@ -241,6 +245,9 @@ initContainers:
241245
volumeMounts:
242246
- name: sc-datasources-volume
243247
mountPath: "/etc/grafana/provisioning/datasources"
248+
{{- with .Values.sidecar.datasources.extraMounts }}
249+
{{- toYaml . | trim | nindent 6 }}
250+
{{- end }}
244251
{{- end }}
245252
{{- if and .Values.sidecar.notifiers.enabled .Values.sidecar.notifiers.initNotifiers }}
246253
- name: {{ include "grafana.name" . }}-init-sc-notifiers
@@ -288,6 +295,10 @@ initContainers:
288295
- name: SKIP_TLS_VERIFY
289296
value: "{{ . }}"
290297
{{- end }}
298+
{{- with .Values.sidecar.notifiers.script }}
299+
- name: SCRIPT
300+
value: {{ quote . }}
301+
{{- end }}
291302
{{- with .Values.sidecar.livenessProbe }}
292303
livenessProbe:
293304
{{- toYaml . | nindent 6 }}
@@ -307,6 +318,9 @@ initContainers:
307318
volumeMounts:
308319
- name: sc-notifiers-volume
309320
mountPath: "/etc/grafana/provisioning/notifiers"
321+
{{- with .Values.sidecar.notifiers.extraMounts }}
322+
{{- toYaml . | trim | nindent 6 }}
323+
{{- end }}
310324
{{- end}}
311325
{{- with .Values.extraInitContainers }}
312326
{{- tpl (toYaml .) $root | nindent 2 }}
@@ -503,7 +517,7 @@ containers:
503517
{{- end }}
504518
{{- with .Values.sidecar.dashboards.script }}
505519
- name: SCRIPT
506-
value: "{{ . }}"
520+
value: {{ quote . }}
507521
{{- end }}
508522
{{- if not .Values.sidecar.dashboards.skipReload }}
509523
{{- if and (not .Values.env.GF_SECURITY_ADMIN_USER) (not .Values.env.GF_SECURITY_DISABLE_INITIAL_ADMIN_CREATION) }}
@@ -629,9 +643,9 @@ containers:
629643
- name: SKIP_TLS_VERIFY
630644
value: "{{ .Values.sidecar.skipTlsVerify }}"
631645
{{- end }}
632-
{{- if .Values.sidecar.datasources.script }}
646+
{{- with .Values.sidecar.datasources.script }}
633647
- name: SCRIPT
634-
value: "{{ .Values.sidecar.datasources.script }}"
648+
value: {{ quote . }}
635649
{{- end }}
636650
{{- if and (not .Values.env.GF_SECURITY_ADMIN_USER) (not .Values.env.GF_SECURITY_DISABLE_INITIAL_ADMIN_CREATION) }}
637651
- name: REQ_USERNAME
@@ -752,9 +766,9 @@ containers:
752766
- name: SKIP_TLS_VERIFY
753767
value: "{{ . }}"
754768
{{- end }}
755-
{{- if .Values.sidecar.notifiers.script }}
769+
{{- with .Values.sidecar.notifiers.script }}
756770
- name: SCRIPT
757-
value: "{{ .Values.sidecar.notifiers.script }}"
771+
value: {{ quote . }}
758772
{{- end }}
759773
{{- if and (not .Values.env.GF_SECURITY_ADMIN_USER) (not .Values.env.GF_SECURITY_DISABLE_INITIAL_ADMIN_CREATION) }}
760774
- name: REQ_USERNAME
@@ -873,7 +887,7 @@ containers:
873887
{{- end }}
874888
{{- with .Values.sidecar.plugins.script }}
875889
- name: SCRIPT
876-
value: "{{ . }}"
890+
value: {{ quote . }}
877891
{{- end }}
878892
{{- with .Values.sidecar.skipTlsVerify }}
879893
- name: SKIP_TLS_VERIFY

charts/grafana/values.yaml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,9 @@ sidecar:
10201020
#
10211021
# Endpoint to send request to reload alerts
10221022
reloadURL: "http://localhost:3000/api/admin/provisioning/alerting/reload"
1023-
# Absolute path to shell script to execute after a alert got reloaded
1023+
# Absolute path to a script to execute after a configmap got reloaded.
1024+
# It runs before calls to REQ_URI. If the file is not executable it will be passed to sh.
1025+
# Otherwise, it's executed as is. Shebangs known to work are #!/bin/sh and #!/usr/bin/env python
10241026
script: null
10251027
skipReload: false
10261028
# This is needed if skipReload is true, to load any alerts defined at startup time.
@@ -1097,7 +1099,9 @@ sidecar:
10971099
#
10981100
# Endpoint to send request to reload alerts
10991101
reloadURL: "http://localhost:3000/api/admin/provisioning/dashboards/reload"
1100-
# Absolute path to shell script to execute after a configmap got reloaded
1102+
# Absolute path to a script to execute after a configmap got reloaded.
1103+
# It runs before calls to REQ_URI. If the file is not executable it will be passed to sh.
1104+
# Otherwise, it's executed as is. Shebangs known to work are #!/bin/sh and #!/usr/bin/env python
11011105
script: null
11021106
skipReload: false
11031107
# watchServerTimeout: request to the server, asking it to cleanly close the connection after that.
@@ -1201,7 +1205,9 @@ sidecar:
12011205
#
12021206
# Endpoint to send request to reload datasources
12031207
reloadURL: "http://localhost:3000/api/admin/provisioning/datasources/reload"
1204-
# Absolute path to shell script to execute after a datasource got reloaded
1208+
# Absolute path to a script to execute after a configmap got reloaded.
1209+
# It runs before calls to REQ_URI. If the file is not executable it will be passed to sh.
1210+
# Otherwise, it's executed as is. Shebangs known to work are #!/bin/sh and #!/usr/bin/env python
12051211
script: null
12061212
skipReload: false
12071213
# This is needed if skipReload is true, to load any datasources defined at startup time.
@@ -1267,7 +1273,9 @@ sidecar:
12671273
#
12681274
# Endpoint to send request to reload plugins
12691275
reloadURL: "http://localhost:3000/api/admin/provisioning/plugins/reload"
1270-
# Absolute path to shell script to execute after a plugin got reloaded
1276+
# Absolute path to a script to execute after a configmap got reloaded.
1277+
# It runs before calls to REQ_URI. If the file is not executable it will be passed to sh.
1278+
# Otherwise, it's executed as is. Shebangs known to work are #!/bin/sh and #!/usr/bin/env python
12711279
script: null
12721280
skipReload: false
12731281
# Deploy the datasource sidecar as an initContainer in addition to a container.
@@ -1333,7 +1341,9 @@ sidecar:
13331341
#
13341342
# Endpoint to send request to reload notifiers
13351343
reloadURL: "http://localhost:3000/api/admin/provisioning/notifications/reload"
1336-
# Absolute path to shell script to execute after a notifier got reloaded
1344+
# Absolute path to a script to execute after a configmap got reloaded.
1345+
# It runs before calls to REQ_URI. If the file is not executable it will be passed to sh.
1346+
# Otherwise, it's executed as is. Shebangs known to work are #!/bin/sh and #!/usr/bin/env python
13371347
script: null
13381348
skipReload: false
13391349
# Deploy the notifier sidecar as an initContainer in addition to a container.

0 commit comments

Comments
 (0)