1 apiVersion: apps/v1beta2
4 name: {{ template "grafana.fullname" . }}
6 app: {{ template "grafana.name" . }}
7 chart: {{ template "grafana.chart" . }}
8 release: {{ .Release.Name }}
9 heritage: {{ .Release.Service }}
10 {{- with .Values.annotations }}
12 {{ toYaml . | indent 4 }}
15 replicas: {{ .Values.replicas }}
18 app: {{ template "grafana.name" . }}
19 release: {{ .Release.Name }}
21 type: {{ .Values.deploymentStrategy }}
22 {{- if ne .Values.deploymentStrategy "RollingUpdate" }}
28 app: {{ template "grafana.name" . }}
29 release: {{ .Release.Name }}
30 {{- with .Values.podAnnotations }}
32 {{ toYaml . | indent 8 }}
35 serviceAccountName: {{ template "grafana.serviceAccountName" . }}
36 {{- if .Values.schedulerName }}
37 schedulerName: "{{ .Values.schedulerName }}"
39 {{- if .Values.securityContext }}
41 {{ toYaml .Values.securityContext | indent 8 }}
43 {{- if .Values.priorityClassName }}
44 priorityClassName: {{ .Values.priorityClassName }}
46 {{- if ( or .Values.persistence.enabled .Values.dashboards .Values.sidecar.datasources.enabled .Values.extraInitContainers) }}
49 {{- if ( and .Values.persistence.enabled .Values.persistence.initChownData ) }}
50 - name: init-chown-data
51 image: "{{ .Values.chownDataImage.repository }}:{{ .Values.chownDataImage.tag }}"
52 imagePullPolicy: {{ .Values.chownDataImage.pullPolicy }}
55 command: ["chown", "-R", "{{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.runAsUser }}", "/var/lib/grafana"]
58 mountPath: "/var/lib/grafana"
59 {{- if .Values.persistence.subPath }}
60 subPath: {{ .Values.persistence.subPath }}
63 {{- if .Values.dashboards }}
64 - name: download-dashboards
65 image: "{{ .Values.downloadDashboardsImage.repository }}:{{ .Values.downloadDashboardsImage.tag }}"
66 imagePullPolicy: {{ .Values.downloadDashboardsImage.pullPolicy }}
67 command: ["sh", "/etc/grafana/download_dashboards.sh"]
70 mountPath: "/etc/grafana/download_dashboards.sh"
71 subPath: download_dashboards.sh
73 mountPath: "/var/lib/grafana"
74 {{- if .Values.persistence.subPath }}
75 subPath: {{ .Values.persistence.subPath }}
77 {{- range .Values.extraSecretMounts }}
79 mountPath: {{ .mountPath }}
80 readOnly: {{ .readOnly }}
83 {{- if .Values.sidecar.datasources.enabled }}
84 - name: {{ template "grafana.name" . }}-sc-datasources
85 image: "{{ .Values.sidecar.image }}"
86 imagePullPolicy: {{ .Values.sidecar.imagePullPolicy }}
91 value: "{{ .Values.sidecar.datasources.label }}"
93 value: "/etc/grafana/provisioning/datasources"
94 {{- if .Values.sidecar.datasources.searchNamespace }}
96 value: "{{ .Values.sidecar.datasources.searchNamespace }}"
99 {{ toYaml .Values.sidecar.resources | indent 12 }}
101 - name: sc-datasources-volume
102 mountPath: "/etc/grafana/provisioning/datasources"
104 {{- if .Values.extraInitContainers }}
105 {{ toYaml .Values.extraInitContainers | indent 8 }}
107 {{- if .Values.image.pullSecrets }}
109 {{- range .Values.image.pullSecrets }}
114 {{- if .Values.sidecar.dashboards.enabled }}
115 - name: {{ template "grafana.name" . }}-sc-dashboard
116 image: "{{ .Values.sidecar.image }}"
117 imagePullPolicy: {{ .Values.sidecar.imagePullPolicy }}
120 value: "{{ .Values.sidecar.dashboards.label }}"
122 value: "{{ .Values.sidecar.dashboards.folder }}"
123 {{- if .Values.sidecar.dashboards.searchNamespace }}
125 value: "{{ .Values.sidecar.dashboards.searchNamespace }}"
128 {{ toYaml .Values.sidecar.resources | indent 12 }}
130 - name: sc-dashboard-volume
131 mountPath: {{ .Values.sidecar.dashboards.folder | quote }}
133 - name: {{ .Chart.Name }}
134 image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
135 imagePullPolicy: {{ .Values.image.pullPolicy }}
136 {{- if .Values.command }}
138 {{- range .Values.command }}
144 mountPath: "/etc/grafana/grafana.ini"
146 {{- if not .Values.admin.existingSecret }}
148 mountPath: "/etc/grafana/ldap.toml"
151 {{- range .Values.extraConfigmapMounts }}
153 mountPath: {{ .mountPath }}
154 readOnly: {{ .readOnly }}
157 mountPath: "/var/lib/grafana"
158 {{- if .Values.persistence.subPath }}
159 subPath: {{ .Values.persistence.subPath }}
161 {{- if .Values.dashboards }}
162 {{- range $provider, $dashboards := .Values.dashboards }}
163 {{- range $key, $value := $dashboards }}
164 {{- if (or (hasKey $value "json") (hasKey $value "file")) }}
165 - name: dashboards-{{ $provider }}
166 mountPath: "/var/lib/grafana/dashboards/{{ $provider }}/{{ $key }}.json"
167 subPath: "{{ $key }}.json"
172 {{- if .Values.dashboardsConfigMaps }}
173 {{- range keys .Values.dashboardsConfigMaps }}
174 - name: dashboards-{{ . }}
175 mountPath: "/var/lib/grafana/dashboards/{{ . }}"
178 {{- if .Values.datasources }}
180 mountPath: "/etc/grafana/provisioning/datasources/datasources.yaml"
181 subPath: datasources.yaml
183 {{- if .Values.notifiers }}
185 mountPath: "/etc/grafana/provisioning/notifiers/notifiers.yaml"
186 subPath: notifiers.yaml
188 {{- if .Values.dashboardProviders }}
190 mountPath: "/etc/grafana/provisioning/dashboards/dashboardproviders.yaml"
191 subPath: dashboardproviders.yaml
193 {{- if .Values.sidecar.dashboards.enabled }}
194 - name: sc-dashboard-volume
195 mountPath: {{ .Values.sidecar.dashboards.folder | quote }}
196 - name: sc-dashboard-provider
197 mountPath: "/etc/grafana/provisioning/dashboards/sc-dashboardproviders.yaml"
198 subPath: provider.yaml
200 {{- if .Values.sidecar.datasources.enabled }}
201 - name: sc-datasources-volume
202 mountPath: "/etc/grafana/provisioning/datasources"
204 {{- range .Values.extraSecretMounts }}
206 mountPath: {{ .mountPath }}
207 readOnly: {{ .readOnly }}
209 {{- range .Values.extraVolumeMounts }}
211 mountPath: {{ .mountPath }}
212 subPath: {{ .subPath | default "" }}
213 readOnly: {{ .readOnly }}
215 {{- range .Values.extraEmptyDirMounts }}
217 mountPath: {{ .mountPath }}
221 containerPort: {{ .Values.service.port }}
227 {{- if not .Values.env.GF_SECURITY_ADMIN_USER }}
228 - name: GF_SECURITY_ADMIN_USER
231 name: {{ .Values.admin.existingSecret | default (include "grafana.fullname" .) }}
232 key: {{ .Values.admin.userKey | default "admin-user" }}
234 {{- if not .Values.env.GF_SECURITY_ADMIN_PASSWORD }}
235 - name: GF_SECURITY_ADMIN_PASSWORD
238 name: {{ .Values.admin.existingSecret | default (include "grafana.fullname" .) }}
239 key: {{ .Values.admin.passwordKey | default "admin-password" }}
241 {{- if .Values.plugins }}
242 - name: GF_INSTALL_PLUGINS
245 name: {{ template "grafana.fullname" . }}
248 {{- if .Values.smtp.existingSecret }}
252 name: {{ .Values.smtp.existingSecret }}
253 key: {{ .Values.smtp.userKey | default "user" }}
254 - name: GF_SMTP_PASSWORD
257 name: {{ .Values.smtp.existingSecret }}
258 key: {{ .Values.smtp.passwordKey | default "password" }}
260 {{- range $key, $value := .Values.env }}
262 value: "{{ $value }}"
264 {{- if .Values.envFromSecret }}
267 name: {{ .Values.envFromSecret }}
270 {{ toYaml .Values.livenessProbe | indent 12 }}
272 {{ toYaml .Values.readinessProbe | indent 12 }}
274 {{ toYaml .Values.resources | indent 12 }}
275 {{- if .Values.extraContainers }}
276 {{ toYaml .Values.extraContainers | indent 8}}
278 {{- with .Values.nodeSelector }}
280 {{ toYaml . | indent 8 }}
282 {{- with .Values.affinity }}
284 {{ toYaml . | indent 8 }}
286 {{- with .Values.tolerations }}
288 {{ toYaml . | indent 8 }}
293 name: {{ template "grafana.fullname" . }}
294 {{- range .Values.extraConfigmapMounts }}
297 name: {{ .configMap }}
299 {{- if .Values.dashboards }}
300 {{- range keys .Values.dashboards }}
301 - name: dashboards-{{ . }}
303 name: {{ template "grafana.fullname" $ }}-dashboards-{{ . }}
306 {{- if .Values.dashboardsConfigMaps }}
308 {{- range $provider, $name := .Values.dashboardsConfigMaps }}
309 - name: dashboards-{{ $provider }}
311 name: {{ tpl $name $root }}
314 {{- if not .Values.admin.existingSecret }}
317 {{- if .Values.ldap.existingSecret }}
318 secretName: {{ .Values.ldap.existingSecret }}
320 secretName: {{ template "grafana.fullname" . }}
327 {{- if .Values.persistence.enabled }}
328 persistentVolumeClaim:
329 claimName: {{ .Values.persistence.existingClaim | default (include "grafana.fullname" .) }}
333 {{- if .Values.sidecar.dashboards.enabled }}
334 - name: sc-dashboard-volume
336 - name: sc-dashboard-provider
338 name: {{ template "grafana.fullname" . }}-config-dashboards
340 {{- if .Values.sidecar.datasources.enabled }}
341 - name: sc-datasources-volume
344 {{- range .Values.extraSecretMounts }}
347 secretName: {{ .secretName }}
348 defaultMode: {{ .defaultMode }}
350 {{- range .Values.extraVolumeMounts }}
352 persistentVolumeClaim:
353 claimName: {{ .existingClaim }}
355 {{- range .Values.extraEmptyDirMounts }}