@@ -25,7 +25,13 @@ dnsConfig:
2525{ {- with .Values.priorityClassName } }
2626priorityClassName: { { . } }
2727{ {- end } }
28- { {- if ( or (and .Values.persistence.enabled .Values.initChownData.enabled) .Values.dashboards .Values.extraInitContainers (and .Values.sidecar.alerts.enabled .Values.sidecar.alerts.initAlerts) (and .Values.sidecar.datasources.enabled .Values.sidecar.datasources.initDatasources) (and .Values.sidecar.notifiers.enabled .Values.sidecar.notifiers.initNotifiers)) } }
28+ { {- if ( or (and .Values.persistence.enabled .Values.initChownData.enabled)
29+ .Values.dashboards
30+ .Values.extraInitContainers
31+ (and .Values.sidecar.alerts.enabled .Values.sidecar.alerts.initAlerts)
32+ (and .Values.sidecar.datasources.enabled .Values.sidecar.datasources.initDatasources)
33+ (and .Values.sidecar.notifiers.enabled .Values.sidecar.notifiers.initNotifiers)
34+ (and .Values.sidecar.dashboards.enabled .Values.sidecar.dashboards.initDashboards)) } }
2935initContainers:
3036{ {- end } }
3137{ {- if ( and .Values.persistence.enabled .Values.initChownData.enabled ) } }
@@ -208,7 +214,7 @@ initContainers:
208214 value: "true"
209215 { {- end } }
210216 - name: METHOD
211- value: "LIST"
217+ value: { { .Values.sidecar.datasources.watchMethod } }
212218 - name: LABEL
213219 value: "{ { tpl .Values.sidecar.datasources.label $root } }"
214220 { {- with .Values.sidecar.datasources.labelValue } }
@@ -223,22 +229,80 @@ initContainers:
223229 value: "/etc/grafana/provisioning/datasources"
224230 - name: RESOURCE
225231 value: { { quote .Values.sidecar.datasources.resource } }
232+ { {- if .Values.sidecar.datasources.resourceName } }
233+ - name: RESOURCE_NAME
234+ value: { { quote .Values.sidecar.datasources.resourceName } }
235+ { {- end } }
226236 { {- with .Values.sidecar.enableUniqueFilenames } }
227237 - name: UNIQUE_FILENAMES
228238 value: "{ { . } }"
229239 { {- end } }
230- { {- if .Values.sidecar.datasources.searchNamespace } }
240+ { {- with .Values.sidecar.datasources.searchNamespace } }
231241 - name: NAMESPACE
232- value: "{ { tpl (.Values.sidecar.datasources.searchNamespace | join " ," ) . } }"
242+ value: "{ { tpl (. | join " ," ) $ root } }"
233243 { {- end } }
234- { {- with .Values.sidecar.skipTlsVerify } }
244+ { {- if .Values.sidecar.skipTlsVerify } }
235245 - name: SKIP_TLS_VERIFY
236- value: "{ { . } }"
246+ value: "{ { .Values.sidecar.skipTlsVerify } }"
237247 { {- end } }
238248 { {- with .Values.sidecar.datasources.script } }
239249 - name: SCRIPT
240250 value: { { quote . } }
241251 { {- end } }
252+ { {- if and (not .Values.env.GF_SECURITY_ADMIN_USER) (not .Values.env.GF_SECURITY_DISABLE_INITIAL_ADMIN_CREATION) } }
253+ - name: REQ_USERNAME
254+ valueFrom:
255+ secretKeyRef:
256+ name: { { (tpl .Values.admin.existingSecret .) | default (include " grafana.fullname" .) } }
257+ key: { { .Values.admin.userKey | default " admin-user" } }
258+ { {- end } }
259+ { {- if and (not .Values.env.GF_SECURITY_ADMIN_PASSWORD) (not .Values.env.GF_SECURITY_ADMIN_PASSWORD__FILE) (not .Values.env.GF_SECURITY_DISABLE_INITIAL_ADMIN_CREATION) } }
260+ - name: REQ_PASSWORD
261+ valueFrom:
262+ secretKeyRef:
263+ name: { { (tpl .Values.admin.existingSecret .) | default (include " grafana.fullname" .) } }
264+ key: { { .Values.admin.passwordKey | default " admin-password" } }
265+ { {- end } }
266+ { {- if not .Values.sidecar.datasources.skipReload } }
267+ - name: REQ_URL
268+ value: { { .Values.sidecar.datasources.reloadURL } }
269+ - name: REQ_METHOD
270+ value: POST
271+ { {- end } }
272+ { {- if .Values.sidecar.datasources.watchServerTimeout } }
273+ { {- if ne .Values.sidecar.datasources.watchMethod " WATCH" } }
274+ { {- fail (printf " Cannot use .Values.sidecar.datasources.watchServerTimeout with .Values.sidecar.datasources.watchMethod %s" .Values.sidecar.datasources.watchMethod) } }
275+ { {- end } }
276+ - name: WATCH_SERVER_TIMEOUT
277+ value: "{ { .Values.sidecar.datasources.watchServerTimeout } }"
278+ { {- end } }
279+ { {- if .Values.sidecar.datasources.watchClientTimeout } }
280+ { {- if ne .Values.sidecar.datasources.watchMethod " WATCH" } }
281+ { {- fail (printf " Cannot use .Values.sidecar.datasources.watchClientTimeout with .Values.sidecar.datasources.watchMethod %s" .Values.sidecar.datasources.watchMethod) } }
282+ { {- end } }
283+ - name: WATCH_CLIENT_TIMEOUT
284+ value: "{ { .Values.sidecar.datasources.watchClientTimeout } }"
285+ { {- end } }
286+ { {- if .Values.sidecar.datasources.maxTotalRetries } }
287+ - name: REQ_RETRY_TOTAL
288+ value: "{ { .Values.sidecar.datasources.maxTotalRetries } }"
289+ { {- end } }
290+ { {- if .Values.sidecar.datasources.maxConnectRetries } }
291+ - name: REQ_RETRY_CONNECT
292+ value: "{ { .Values.sidecar.datasources.maxConnectRetries } }"
293+ { {- end } }
294+ { {- if .Values.sidecar.datasources.maxReadRetries } }
295+ - name: REQ_RETRY_READ
296+ value: "{ { .Values.sidecar.datasources.maxReadRetries } }"
297+ { {- end } }
298+ { {- with .Values.sidecar.livenessProbe } }
299+ livenessProbe:
300+ { {- toYaml . | nindent 6 } }
301+ { {- end } }
302+ { {- with .Values.sidecar.readinessProbe } }
303+ readinessProbe:
304+ { {- toYaml . | nindent 6 } }
305+ { {- end } }
242306 { {- with .Values.sidecar.resources } }
243307 resources:
244308 { {- toYaml . | nindent 6 } }
@@ -327,6 +391,138 @@ initContainers:
327391 { {- toYaml . | trim | nindent 6 } }
328392 { {- end } }
329393{ {- end} }
394+ { {- if and .Values.sidecar.dashboards.enabled .Values.sidecar.dashboards.initDashboards } }
395+ - name: { { include " grafana.name" . } }-init-sc-dashboard
396+ { {- $registry := .Values.global.imageRegistry | default .Values.sidecar.image.registry -} }
397+ { {- if .Values.sidecar.image.sha } }
398+ image: "{ { $registry } }/{ { .Values.sidecar.image.repository } }:{ { .Values.sidecar.image.tag } }@sha256:{ { .Values.sidecar.image.sha } }"
399+ { {- else } }
400+ image: "{ { $registry } }/{ { .Values.sidecar.image.repository } }:{ { .Values.sidecar.image.tag } }"
401+ { {- end } }
402+ imagePullPolicy: { { .Values.sidecar.imagePullPolicy } }
403+ env:
404+ { {- range $key , $value := .Values.sidecar.dashboards.env } }
405+ - name: "{ { $key } }"
406+ value: "{ { $value } }"
407+ { {- end } }
408+ { {- range $key , $value := .Values.sidecar.dashboards.envValueFrom } }
409+ - name: { { $key | quote } }
410+ valueFrom:
411+ { {- tpl (toYaml $value ) $ | nindent 10 } }
412+ { {- end } }
413+ { {- if .Values.sidecar.dashboards.ignoreAlreadyProcessed } }
414+ - name: IGNORE_ALREADY_PROCESSED
415+ value: "true"
416+ { {- end } }
417+ - name: METHOD
418+ value: { { .Values.sidecar.dashboards.watchMethod } }
419+ - name: LABEL
420+ value: "{ { tpl .Values.sidecar.dashboards.label $root } }"
421+ { {- with .Values.sidecar.dashboards.labelValue } }
422+ - name: LABEL_VALUE
423+ value: { { quote (tpl . $root ) } }
424+ { {- end } }
425+ { {- if or .Values.sidecar.logLevel .Values.sidecar.dashboards.logLevel } }
426+ - name: LOG_LEVEL
427+ value: { { default .Values.sidecar.logLevel .Values.sidecar.dashboards.logLevel } }
428+ { {- end } }
429+ - name: FOLDER
430+ value: "{ { .Values.sidecar.dashboards.folder } }{ {- with .Values.sidecar.dashboards.defaultFolderName } }/{ { . } }{ {- end } }"
431+ - name: RESOURCE
432+ value: { { quote .Values.sidecar.dashboards.resource } }
433+ { {- if .Values.sidecar.dashboards.resourceName } }
434+ - name: RESOURCE_NAME
435+ value: { { quote .Values.sidecar.dashboards.resourceName } }
436+ { {- end } }
437+ { {- with .Values.sidecar.enableUniqueFilenames } }
438+ - name: UNIQUE_FILENAMES
439+ value: "{ { . } }"
440+ { {- end } }
441+ { {- with .Values.sidecar.dashboards.searchNamespace } }
442+ - name: NAMESPACE
443+ value: "{ { tpl (. | join " ," ) $root } }"
444+ { {- end } }
445+ { {- with .Values.sidecar.skipTlsVerify } }
446+ - name: SKIP_TLS_VERIFY
447+ value: "{ { . } }"
448+ { {- end } }
449+ { {- with .Values.sidecar.dashboards.folderAnnotation } }
450+ - name: FOLDER_ANNOTATION
451+ value: "{ { . } }"
452+ { {- end } }
453+ { {- with .Values.sidecar.dashboards.script } }
454+ - name: SCRIPT
455+ value: { { quote . } }
456+ { {- end } }
457+ { {- if not .Values.sidecar.dashboards.skipReload } }
458+ { {- if and (not .Values.env.GF_SECURITY_ADMIN_USER) (not .Values.env.GF_SECURITY_DISABLE_INITIAL_ADMIN_CREATION) } }
459+ - name: REQ_USERNAME
460+ valueFrom:
461+ secretKeyRef:
462+ name: { { (tpl .Values.admin.existingSecret .) | default (include " grafana.fullname" .) } }
463+ key: { { .Values.admin.userKey | default " admin-user" } }
464+ { {- end } }
465+ { {- if and (not .Values.env.GF_SECURITY_ADMIN_PASSWORD) (not .Values.env.GF_SECURITY_ADMIN_PASSWORD__FILE) (not .Values.env.GF_SECURITY_DISABLE_INITIAL_ADMIN_CREATION) } }
466+ - name: REQ_PASSWORD
467+ valueFrom:
468+ secretKeyRef:
469+ name: { { (tpl .Values.admin.existingSecret .) | default (include " grafana.fullname" .) } }
470+ key: { { .Values.admin.passwordKey | default " admin-password" } }
471+ { {- end } }
472+ - name: REQ_URL
473+ value: { { .Values.sidecar.dashboards.reloadURL } }
474+ - name: REQ_METHOD
475+ value: POST
476+ { {- end } }
477+ { {- if .Values.sidecar.dashboards.watchServerTimeout } }
478+ { {- if ne .Values.sidecar.dashboards.watchMethod " WATCH" } }
479+ { {- fail (printf " Cannot use .Values.sidecar.dashboards.watchServerTimeout with .Values.sidecar.dashboards.watchMethod %s" .Values.sidecar.dashboards.watchMethod) } }
480+ { {- end } }
481+ - name: WATCH_SERVER_TIMEOUT
482+ value: "{ { .Values.sidecar.dashboards.watchServerTimeout } }"
483+ { {- end } }
484+ { {- if .Values.sidecar.dashboards.watchClientTimeout } }
485+ { {- if ne .Values.sidecar.dashboards.watchMethod " WATCH" } }
486+ { {- fail (printf " Cannot use .Values.sidecar.dashboards.watchClientTimeout with .Values.sidecar.dashboards.watchMethod %s" .Values.sidecar.dashboards.watchMethod) } }
487+ { {- end } }
488+ - name: WATCH_CLIENT_TIMEOUT
489+ value: { { .Values.sidecar.dashboards.watchClientTimeout | quote } }
490+ { {- end } }
491+ { {- if .Values.sidecar.dashboards.maxTotalRetries } }
492+ - name: REQ_RETRY_TOTAL
493+ value: "{ { .Values.sidecar.dashboards.maxTotalRetries } }"
494+ { {- end } }
495+ { {- if .Values.sidecar.dashboards.maxConnectRetries } }
496+ - name: REQ_RETRY_CONNECT
497+ value: "{ { .Values.sidecar.dashboards.maxConnectRetries } }"
498+ { {- end } }
499+ { {- if .Values.sidecar.dashboards.maxReadRetries } }
500+ - name: REQ_RETRY_READ
501+ value: "{ { .Values.sidecar.dashboards.maxReadRetries } }"
502+ { {- end } }
503+ { {- with .Values.sidecar.livenessProbe } }
504+ livenessProbe:
505+ { {- toYaml . | nindent 6 } }
506+ { {- end } }
507+ { {- with .Values.sidecar.readinessProbe } }
508+ readinessProbe:
509+ { {- toYaml . | nindent 6 } }
510+ { {- end } }
511+ { {- with .Values.sidecar.resources } }
512+ resources:
513+ { {- toYaml . | nindent 6 } }
514+ { {- end } }
515+ { {- with .Values.sidecar.securityContext } }
516+ securityContext:
517+ { {- toYaml . | nindent 6 } }
518+ { {- end } }
519+ volumeMounts:
520+ - name: sc-dashboard-volume
521+ mountPath: { { .Values.sidecar.dashboards.folder | quote } }
522+ { {- with .Values.sidecar.dashboards.extraMounts } }
523+ { {- toYaml . | trim | nindent 6 } }
524+ { {- end } }
525+ { {- end} }
330526{ {- with .Values.extraInitContainers } }
331527 { {- tpl (toYaml .) $root | nindent 2 } }
332528{ {- end } }
@@ -466,7 +662,7 @@ containers:
466662 { {- toYaml . | trim | nindent 6 } }
467663 { {- end } }
468664{ {- end} }
469- { {- if .Values.sidecar.dashboards.enabled } }
665+ { {- if and .Values.sidecar.dashboards.enabled ( not .Values.sidecar.dashboards.initDashboards) } }
470666 - name: { { include " grafana.name" . } }-sc-dashboard
471667 { {- $registry := .Values.global.imageRegistry | default .Values.sidecar.image.registry -} }
472668 { {- if .Values.sidecar.image.sha } }
@@ -726,7 +922,7 @@ containers:
726922 { {- toYaml . | trim | nindent 6 } }
727923 { {- end } }
728924{ {- end} }
729- { {- if .Values.sidecar.notifiers.enabled } }
925+ { {- if and .Values.sidecar.notifiers.enabled ( not .Values.sidecar.notifiers.initNotifiers) } }
730926 - name: { { include " grafana.name" . } }-sc-notifiers
731927 { {- $registry := .Values.global.imageRegistry | default .Values.sidecar.image.registry -} }
732928 { {- if .Values.sidecar.image.sha } }
0 commit comments