_pod.tpl 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115
  1. {{- define "grafana.pod" -}}
  2. {{- if .Values.schedulerName }}
  3. schedulerName: "{{ .Values.schedulerName }}"
  4. {{- end }}
  5. serviceAccountName: {{ template "grafana.serviceAccountName" . }}
  6. automountServiceAccountToken: {{ .Values.serviceAccount.autoMount }}
  7. {{- with .Values.securityContext }}
  8. securityContext:
  9. {{- toYaml . | nindent 2 }}
  10. {{- end }}
  11. {{- with .Values.hostAliases }}
  12. hostAliases:
  13. {{- toYaml . | nindent 2 }}
  14. {{- end }}
  15. {{- if .Values.priorityClassName }}
  16. priorityClassName: {{ .Values.priorityClassName }}
  17. {{- end }}
  18. {{- if ( or .Values.persistence.enabled .Values.dashboards .Values.extraInitContainers (and .Values.sidecar.datasources.enabled .Values.sidecar.datasources.initDatasources) (and .Values.sidecar.notifiers.enabled .Values.sidecar.notifiers.initNotifiers)) }}
  19. initContainers:
  20. {{- end }}
  21. {{- if ( and .Values.persistence.enabled .Values.initChownData.enabled ) }}
  22. - name: init-chown-data
  23. {{- if .Values.initChownData.image.sha }}
  24. image: "{{ .Values.initChownData.image.repository }}:{{ .Values.initChownData.image.tag }}@sha256:{{ .Values.initChownData.image.sha }}"
  25. {{- else }}
  26. image: "{{ .Values.initChownData.image.repository }}:{{ .Values.initChownData.image.tag }}"
  27. {{- end }}
  28. imagePullPolicy: {{ .Values.initChownData.image.pullPolicy }}
  29. {{- with .Values.initChownData.securityContext }}
  30. securityContext:
  31. {{- toYaml . | nindent 6 }}
  32. {{- end }}
  33. command: ["chown", "-R", "{{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.runAsGroup }}", "/var/lib/grafana"]
  34. {{- with .Values.initChownData.resources }}
  35. resources:
  36. {{- toYaml . | nindent 6 }}
  37. {{- end }}
  38. volumeMounts:
  39. - name: storage
  40. mountPath: "/var/lib/grafana"
  41. {{- if .Values.persistence.subPath }}
  42. subPath: {{ tpl .Values.persistence.subPath . }}
  43. {{- end }}
  44. {{- end }}
  45. {{- if .Values.dashboards }}
  46. - name: download-dashboards
  47. {{- if .Values.downloadDashboardsImage.sha }}
  48. image: "{{ .Values.downloadDashboardsImage.repository }}:{{ .Values.downloadDashboardsImage.tag }}@sha256:{{ .Values.downloadDashboardsImage.sha }}"
  49. {{- else }}
  50. image: "{{ .Values.downloadDashboardsImage.repository }}:{{ .Values.downloadDashboardsImage.tag }}"
  51. {{- end }}
  52. imagePullPolicy: {{ .Values.downloadDashboardsImage.pullPolicy }}
  53. command: ["/bin/sh"]
  54. args: [ "-c", "mkdir -p /var/lib/grafana/dashboards/default && /bin/sh -x /etc/grafana/download_dashboards.sh" ]
  55. {{- with .Values.downloadDashboards.resources }}
  56. resources:
  57. {{- toYaml . | nindent 6 }}
  58. {{- end }}
  59. env:
  60. {{- range $key, $value := .Values.downloadDashboards.env }}
  61. - name: "{{ $key }}"
  62. value: "{{ $value }}"
  63. {{- end }}
  64. {{- with .Values.downloadDashboards.securityContext }}
  65. securityContext:
  66. {{- toYaml . | nindent 6 }}
  67. {{- end }}
  68. {{- if .Values.downloadDashboards.envFromSecret }}
  69. envFrom:
  70. - secretRef:
  71. name: {{ tpl .Values.downloadDashboards.envFromSecret . }}
  72. {{- end }}
  73. volumeMounts:
  74. - name: config
  75. mountPath: "/etc/grafana/download_dashboards.sh"
  76. subPath: download_dashboards.sh
  77. - name: storage
  78. mountPath: "/var/lib/grafana"
  79. {{- if .Values.persistence.subPath }}
  80. subPath: {{ tpl .Values.persistence.subPath . }}
  81. {{- end }}
  82. {{- range .Values.extraSecretMounts }}
  83. - name: {{ .name }}
  84. mountPath: {{ .mountPath }}
  85. readOnly: {{ .readOnly }}
  86. {{- end }}
  87. {{- end }}
  88. {{- if and .Values.sidecar.datasources.enabled .Values.sidecar.datasources.initDatasources }}
  89. - name: {{ template "grafana.name" . }}-init-sc-datasources
  90. {{- if .Values.sidecar.image.sha }}
  91. image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}@sha256:{{ .Values.sidecar.image.sha }}"
  92. {{- else }}
  93. image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}"
  94. {{- end }}
  95. imagePullPolicy: {{ .Values.sidecar.imagePullPolicy }}
  96. env:
  97. {{- range $key, $value := .Values.sidecar.datasources.env }}
  98. - name: "{{ $key }}"
  99. value: "{{ $value }}"
  100. {{- end }}
  101. {{- if .Values.sidecar.datasources.ignoreAlreadyProcessed }}
  102. - name: IGNORE_ALREADY_PROCESSED
  103. value: "true"
  104. {{- end }}
  105. - name: METHOD
  106. value: "LIST"
  107. - name: LABEL
  108. value: "{{ .Values.sidecar.datasources.label }}"
  109. {{- if .Values.sidecar.datasources.labelValue }}
  110. - name: LABEL_VALUE
  111. value: {{ quote .Values.sidecar.datasources.labelValue }}
  112. {{- end }}
  113. {{- if or .Values.sidecar.logLevel .Values.sidecar.datasources.logLevel }}
  114. - name: LOG_LEVEL
  115. value: {{ default .Values.sidecar.logLevel .Values.sidecar.datasources.logLevel }}
  116. {{- end }}
  117. - name: FOLDER
  118. value: "/etc/grafana/provisioning/datasources"
  119. - name: RESOURCE
  120. value: {{ quote .Values.sidecar.datasources.resource }}
  121. {{- if .Values.sidecar.enableUniqueFilenames }}
  122. - name: UNIQUE_FILENAMES
  123. value: "{{ .Values.sidecar.enableUniqueFilenames }}"
  124. {{- end }}
  125. {{- if .Values.sidecar.datasources.searchNamespace }}
  126. - name: NAMESPACE
  127. value: "{{ tpl (.Values.sidecar.datasources.searchNamespace | join ",") . }}"
  128. {{- end }}
  129. {{- if .Values.sidecar.skipTlsVerify }}
  130. - name: SKIP_TLS_VERIFY
  131. value: "{{ .Values.sidecar.skipTlsVerify }}"
  132. {{- end }}
  133. {{- with .Values.sidecar.resources }}
  134. resources:
  135. {{- toYaml . | nindent 6 }}
  136. {{- end }}
  137. {{- with .Values.sidecar.securityContext }}
  138. securityContext:
  139. {{- toYaml . | nindent 6 }}
  140. {{- end }}
  141. volumeMounts:
  142. - name: sc-datasources-volume
  143. mountPath: "/etc/grafana/provisioning/datasources"
  144. {{- end }}
  145. {{- if and .Values.sidecar.notifiers.enabled .Values.sidecar.notifiers.initNotifiers }}
  146. - name: {{ template "grafana.name" . }}-init-sc-notifiers
  147. {{- if .Values.sidecar.image.sha }}
  148. image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}@sha256:{{ .Values.sidecar.image.sha }}"
  149. {{- else }}
  150. image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}"
  151. {{- end }}
  152. imagePullPolicy: {{ .Values.sidecar.imagePullPolicy }}
  153. env:
  154. {{- range $key, $value := .Values.sidecar.notifiers.env }}
  155. - name: "{{ $key }}"
  156. value: "{{ $value }}"
  157. {{- end }}
  158. {{- if .Values.sidecar.notifiers.ignoreAlreadyProcessed }}
  159. - name: IGNORE_ALREADY_PROCESSED
  160. value: "true"
  161. {{- end }}
  162. - name: METHOD
  163. value: LIST
  164. - name: LABEL
  165. value: "{{ .Values.sidecar.notifiers.label }}"
  166. {{- if .Values.sidecar.notifiers.labelValue }}
  167. - name: LABEL_VALUE
  168. value: {{ quote .Values.sidecar.notifiers.labelValue }}
  169. {{- end }}
  170. {{- if or .Values.sidecar.logLevel .Values.sidecar.notifiers.logLevel }}
  171. - name: LOG_LEVEL
  172. value: {{ default .Values.sidecar.logLevel .Values.sidecar.notifiers.logLevel }}
  173. {{- end }}
  174. - name: FOLDER
  175. value: "/etc/grafana/provisioning/notifiers"
  176. - name: RESOURCE
  177. value: {{ quote .Values.sidecar.notifiers.resource }}
  178. {{- if .Values.sidecar.enableUniqueFilenames }}
  179. - name: UNIQUE_FILENAMES
  180. value: "{{ .Values.sidecar.enableUniqueFilenames }}"
  181. {{- end }}
  182. {{- if .Values.sidecar.notifiers.searchNamespace }}
  183. - name: NAMESPACE
  184. value: "{{ tpl (.Values.sidecar.notifiers.searchNamespace | join ",") . }}"
  185. {{- end }}
  186. {{- if .Values.sidecar.skipTlsVerify }}
  187. - name: SKIP_TLS_VERIFY
  188. value: "{{ .Values.sidecar.skipTlsVerify }}"
  189. {{- end }}
  190. {{- with .Values.sidecar.livenessProbe }}
  191. livenessProbe:
  192. {{- toYaml . | nindent 6 }}
  193. {{- end }}
  194. {{- with .Values.sidecar.readinessProbe }}
  195. readinessProbe:
  196. {{- toYaml . | nindent 6 }}
  197. {{- end }}
  198. {{- with .Values.sidecar.resources }}
  199. resources:
  200. {{- toYaml . | nindent 6 }}
  201. {{- end }}
  202. {{- with .Values.sidecar.securityContext }}
  203. securityContext:
  204. {{- toYaml . | nindent 6 }}
  205. {{- end }}
  206. volumeMounts:
  207. - name: sc-notifiers-volume
  208. mountPath: "/etc/grafana/provisioning/notifiers"
  209. {{- end}}
  210. {{- if .Values.extraInitContainers }}
  211. {{ tpl (toYaml .Values.extraInitContainers) . | indent 2 }}
  212. {{- end }}
  213. {{- if .Values.image.pullSecrets }}
  214. imagePullSecrets:
  215. {{- $root := . }}
  216. {{- range .Values.image.pullSecrets }}
  217. - name: {{ tpl . $root }}
  218. {{- end}}
  219. {{- end }}
  220. {{- if not .Values.enableKubeBackwardCompatibility }}
  221. enableServiceLinks: {{ .Values.enableServiceLinks }}
  222. {{- end }}
  223. containers:
  224. {{- if .Values.sidecar.alerts.enabled }}
  225. - name: {{ template "grafana.name" . }}-sc-alerts
  226. {{- if .Values.sidecar.image.sha }}
  227. image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}@sha256:{{ .Values.sidecar.image.sha }}"
  228. {{- else }}
  229. image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}"
  230. {{- end }}
  231. imagePullPolicy: {{ .Values.sidecar.imagePullPolicy }}
  232. env:
  233. {{- range $key, $value := .Values.sidecar.alerts.env }}
  234. - name: "{{ $key }}"
  235. value: "{{ $value }}"
  236. {{- end }}
  237. {{- if .Values.sidecar.alerts.ignoreAlreadyProcessed }}
  238. - name: IGNORE_ALREADY_PROCESSED
  239. value: "true"
  240. {{- end }}
  241. - name: METHOD
  242. value: {{ .Values.sidecar.alerts.watchMethod }}
  243. - name: LABEL
  244. value: "{{ .Values.sidecar.alerts.label }}"
  245. {{- with .Values.sidecar.alerts.labelValue }}
  246. - name: LABEL_VALUE
  247. value: {{ quote . }}
  248. {{- end }}
  249. {{- if or .Values.sidecar.logLevel .Values.sidecar.alerts.logLevel }}
  250. - name: LOG_LEVEL
  251. value: {{ default .Values.sidecar.logLevel .Values.sidecar.alerts.logLevel }}
  252. {{- end }}
  253. - name: FOLDER
  254. value: "/etc/grafana/provisioning/alerting"
  255. - name: RESOURCE
  256. value: {{ quote .Values.sidecar.alerts.resource }}
  257. {{- if .Values.sidecar.enableUniqueFilenames }}
  258. - name: UNIQUE_FILENAMES
  259. value: "{{ .Values.sidecar.enableUniqueFilenames }}"
  260. {{- end }}
  261. {{- with .Values.sidecar.alerts.searchNamespace }}
  262. - name: NAMESPACE
  263. value: {{ . | join "," | quote }}
  264. {{- end }}
  265. {{- with .Values.sidecar.alerts.skipTlsVerify }}
  266. - name: SKIP_TLS_VERIFY
  267. value: {{ quote . }}
  268. {{- end }}
  269. {{- with .Values.sidecar.alerts.script }}
  270. - name: SCRIPT
  271. value: {{ quote . }}
  272. {{- end }}
  273. {{- if and (not .Values.env.GF_SECURITY_ADMIN_USER) (not .Values.env.GF_SECURITY_DISABLE_INITIAL_ADMIN_CREATION) }}
  274. - name: REQ_USERNAME
  275. valueFrom:
  276. secretKeyRef:
  277. name: {{ (tpl .Values.admin.existingSecret .) | default (include "grafana.fullname" .) }}
  278. key: {{ .Values.admin.userKey | default "admin-user" }}
  279. {{- end }}
  280. {{- 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) }}
  281. - name: REQ_PASSWORD
  282. valueFrom:
  283. secretKeyRef:
  284. name: {{ (tpl .Values.admin.existingSecret .) | default (include "grafana.fullname" .) }}
  285. key: {{ .Values.admin.passwordKey | default "admin-password" }}
  286. {{- end }}
  287. {{- if not .Values.sidecar.alerts.skipReload }}
  288. - name: REQ_URL
  289. value: {{ .Values.sidecar.alerts.reloadURL }}
  290. - name: REQ_METHOD
  291. value: POST
  292. {{- end }}
  293. {{- if .Values.sidecar.alerts.watchServerTimeout }}
  294. {{- if ne .Values.sidecar.alerts.watchMethod "WATCH" }}
  295. {{- fail (printf "Cannot use .Values.sidecar.alerts.watchServerTimeout with .Values.sidecar.alerts.watchMethod %s" .Values.sidecar.alerts.watchMethod) }}
  296. {{- end }}
  297. - name: WATCH_SERVER_TIMEOUT
  298. value: "{{ .Values.sidecar.alerts.watchServerTimeout }}"
  299. {{- end }}
  300. {{- if .Values.sidecar.alerts.watchClientTimeout }}
  301. {{- if ne .Values.sidecar.alerts.watchMethod "WATCH" }}
  302. {{- fail (printf "Cannot use .Values.sidecar.alerts.watchClientTimeout with .Values.sidecar.alerts.watchMethod %s" .Values.sidecar.alerts.watchMethod) }}
  303. {{- end }}
  304. - name: WATCH_CLIENT_TIMEOUT
  305. value: "{{ .Values.sidecar.alerts.watchClientTimeout }}"
  306. {{- end }}
  307. {{- with .Values.sidecar.livenessProbe }}
  308. livenessProbe:
  309. {{- toYaml . | nindent 6 }}
  310. {{- end }}
  311. {{- with .Values.sidecar.readinessProbe }}
  312. readinessProbe:
  313. {{- toYaml . | nindent 6 }}
  314. {{- end }}
  315. {{- with .Values.sidecar.resources }}
  316. resources:
  317. {{- toYaml . | nindent 6 }}
  318. {{- end }}
  319. {{- with .Values.sidecar.securityContext }}
  320. securityContext:
  321. {{- toYaml . | nindent 6 }}
  322. {{- end }}
  323. volumeMounts:
  324. - name: sc-alerts-volume
  325. mountPath: "/etc/grafana/provisioning/alerting"
  326. {{- end}}
  327. {{- if .Values.sidecar.dashboards.enabled }}
  328. - name: {{ template "grafana.name" . }}-sc-dashboard
  329. {{- if .Values.sidecar.image.sha }}
  330. image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}@sha256:{{ .Values.sidecar.image.sha }}"
  331. {{- else }}
  332. image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}"
  333. {{- end }}
  334. imagePullPolicy: {{ .Values.sidecar.imagePullPolicy }}
  335. env:
  336. {{- range $key, $value := .Values.sidecar.dashboards.env }}
  337. - name: "{{ $key }}"
  338. value: "{{ $value }}"
  339. {{- end }}
  340. {{- if .Values.sidecar.dashboards.ignoreAlreadyProcessed }}
  341. - name: IGNORE_ALREADY_PROCESSED
  342. value: "true"
  343. {{- end }}
  344. - name: METHOD
  345. value: {{ .Values.sidecar.dashboards.watchMethod }}
  346. - name: LABEL
  347. value: "{{ .Values.sidecar.dashboards.label }}"
  348. {{- if .Values.sidecar.dashboards.labelValue }}
  349. - name: LABEL_VALUE
  350. value: {{ quote .Values.sidecar.dashboards.labelValue }}
  351. {{- end }}
  352. {{- if or .Values.sidecar.logLevel .Values.sidecar.dashboards.logLevel }}
  353. - name: LOG_LEVEL
  354. value: {{ default .Values.sidecar.logLevel .Values.sidecar.dashboards.logLevel }}
  355. {{- end }}
  356. - name: FOLDER
  357. value: "{{ .Values.sidecar.dashboards.folder }}{{- with .Values.sidecar.dashboards.defaultFolderName }}/{{ . }}{{- end }}"
  358. - name: RESOURCE
  359. value: {{ quote .Values.sidecar.dashboards.resource }}
  360. {{- if .Values.sidecar.enableUniqueFilenames }}
  361. - name: UNIQUE_FILENAMES
  362. value: "{{ .Values.sidecar.enableUniqueFilenames }}"
  363. {{- end }}
  364. {{- if .Values.sidecar.dashboards.searchNamespace }}
  365. - name: NAMESPACE
  366. value: "{{ tpl (.Values.sidecar.dashboards.searchNamespace | join ",") . }}"
  367. {{- end }}
  368. {{- if .Values.sidecar.skipTlsVerify }}
  369. - name: SKIP_TLS_VERIFY
  370. value: "{{ .Values.sidecar.skipTlsVerify }}"
  371. {{- end }}
  372. {{- if .Values.sidecar.dashboards.folderAnnotation }}
  373. - name: FOLDER_ANNOTATION
  374. value: "{{ .Values.sidecar.dashboards.folderAnnotation }}"
  375. {{- end }}
  376. {{- if .Values.sidecar.dashboards.script }}
  377. - name: SCRIPT
  378. value: "{{ .Values.sidecar.dashboards.script }}"
  379. {{- end }}
  380. {{- if .Values.sidecar.dashboards.watchServerTimeout }}
  381. {{- if ne .Values.sidecar.dashboards.watchMethod "WATCH" }}
  382. {{- fail (printf "Cannot use .Values.sidecar.dashboards.watchServerTimeout with .Values.sidecar.dashboards.watchMethod %s" .Values.sidecar.dashboards.watchMethod) }}
  383. {{- end }}
  384. - name: WATCH_SERVER_TIMEOUT
  385. value: "{{ .Values.sidecar.dashboards.watchServerTimeout }}"
  386. {{- end }}
  387. {{- if .Values.sidecar.dashboards.watchClientTimeout }}
  388. {{- if ne .Values.sidecar.dashboards.watchMethod "WATCH" }}
  389. {{- fail (printf "Cannot use .Values.sidecar.dashboards.watchClientTimeout with .Values.sidecar.dashboards.watchMethod %s" .Values.sidecar.dashboards.watchMethod) }}
  390. {{- end }}
  391. - name: WATCH_CLIENT_TIMEOUT
  392. value: "{{ .Values.sidecar.dashboards.watchClientTimeout }}"
  393. {{- end }}
  394. {{- with .Values.sidecar.livenessProbe }}
  395. livenessProbe:
  396. {{- toYaml . | nindent 6 }}
  397. {{- end }}
  398. {{- with .Values.sidecar.readinessProbe }}
  399. readinessProbe:
  400. {{- toYaml . | nindent 6 }}
  401. {{- end }}
  402. {{- with .Values.sidecar.resources }}
  403. resources:
  404. {{- toYaml . | nindent 6 }}
  405. {{- end }}
  406. {{- with .Values.sidecar.securityContext }}
  407. securityContext:
  408. {{- toYaml . | nindent 6 }}
  409. {{- end }}
  410. volumeMounts:
  411. - name: sc-dashboard-volume
  412. mountPath: {{ .Values.sidecar.dashboards.folder | quote }}
  413. {{- if .Values.sidecar.dashboards.extraMounts }}
  414. {{- toYaml .Values.sidecar.dashboards.extraMounts | trim | nindent 6}}
  415. {{- end }}
  416. {{- end}}
  417. {{- if .Values.sidecar.datasources.enabled }}
  418. - name: {{ template "grafana.name" . }}-sc-datasources
  419. {{- if .Values.sidecar.image.sha }}
  420. image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}@sha256:{{ .Values.sidecar.image.sha }}"
  421. {{- else }}
  422. image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}"
  423. {{- end }}
  424. imagePullPolicy: {{ .Values.sidecar.imagePullPolicy }}
  425. env:
  426. {{- range $key, $value := .Values.sidecar.datasources.env }}
  427. - name: "{{ $key }}"
  428. value: "{{ $value }}"
  429. {{- end }}
  430. {{- if .Values.sidecar.datasources.ignoreAlreadyProcessed }}
  431. - name: IGNORE_ALREADY_PROCESSED
  432. value: "true"
  433. {{- end }}
  434. - name: METHOD
  435. value: {{ .Values.sidecar.datasources.watchMethod }}
  436. - name: LABEL
  437. value: "{{ .Values.sidecar.datasources.label }}"
  438. {{- if .Values.sidecar.datasources.labelValue }}
  439. - name: LABEL_VALUE
  440. value: {{ quote .Values.sidecar.datasources.labelValue }}
  441. {{- end }}
  442. {{- if or .Values.sidecar.logLevel .Values.sidecar.datasources.logLevel }}
  443. - name: LOG_LEVEL
  444. value: {{ default .Values.sidecar.logLevel .Values.sidecar.datasources.logLevel }}
  445. {{- end }}
  446. - name: FOLDER
  447. value: "/etc/grafana/provisioning/datasources"
  448. - name: RESOURCE
  449. value: {{ quote .Values.sidecar.datasources.resource }}
  450. {{- if .Values.sidecar.enableUniqueFilenames }}
  451. - name: UNIQUE_FILENAMES
  452. value: "{{ .Values.sidecar.enableUniqueFilenames }}"
  453. {{- end }}
  454. {{- if .Values.sidecar.datasources.searchNamespace }}
  455. - name: NAMESPACE
  456. value: "{{ tpl (.Values.sidecar.datasources.searchNamespace | join ",") . }}"
  457. {{- end }}
  458. {{- if .Values.sidecar.skipTlsVerify }}
  459. - name: SKIP_TLS_VERIFY
  460. value: "{{ .Values.sidecar.skipTlsVerify }}"
  461. {{- end }}
  462. {{- if .Values.sidecar.datasources.script }}
  463. - name: SCRIPT
  464. value: "{{ .Values.sidecar.datasources.script }}"
  465. {{- end }}
  466. {{- if and (not .Values.env.GF_SECURITY_ADMIN_USER) (not .Values.env.GF_SECURITY_DISABLE_INITIAL_ADMIN_CREATION) }}
  467. - name: REQ_USERNAME
  468. valueFrom:
  469. secretKeyRef:
  470. name: {{ (tpl .Values.admin.existingSecret .) | default (include "grafana.fullname" .) }}
  471. key: {{ .Values.admin.userKey | default "admin-user" }}
  472. {{- end }}
  473. {{- 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) }}
  474. - name: REQ_PASSWORD
  475. valueFrom:
  476. secretKeyRef:
  477. name: {{ (tpl .Values.admin.existingSecret .) | default (include "grafana.fullname" .) }}
  478. key: {{ .Values.admin.passwordKey | default "admin-password" }}
  479. {{- end }}
  480. {{- if not .Values.sidecar.datasources.skipReload }}
  481. - name: REQ_URL
  482. value: {{ .Values.sidecar.datasources.reloadURL }}
  483. - name: REQ_METHOD
  484. value: POST
  485. {{- end }}
  486. {{- if .Values.sidecar.datasources.watchServerTimeout }}
  487. {{- if ne .Values.sidecar.datasources.watchMethod "WATCH" }}
  488. {{- fail (printf "Cannot use .Values.sidecar.datasources.watchServerTimeout with .Values.sidecar.datasources.watchMethod %s" .Values.sidecar.datasources.watchMethod) }}
  489. {{- end }}
  490. - name: WATCH_SERVER_TIMEOUT
  491. value: "{{ .Values.sidecar.datasources.watchServerTimeout }}"
  492. {{- end }}
  493. {{- if .Values.sidecar.datasources.watchClientTimeout }}
  494. {{- if ne .Values.sidecar.datasources.watchMethod "WATCH" }}
  495. {{- fail (printf "Cannot use .Values.sidecar.datasources.watchClientTimeout with .Values.sidecar.datasources.watchMethod %s" .Values.sidecar.datasources.watchMethod) }}
  496. {{- end }}
  497. - name: WATCH_CLIENT_TIMEOUT
  498. value: "{{ .Values.sidecar.datasources.watchClientTimeout }}"
  499. {{- end }}
  500. {{- with .Values.sidecar.livenessProbe }}
  501. livenessProbe:
  502. {{- toYaml . | nindent 6 }}
  503. {{- end }}
  504. {{- with .Values.sidecar.readinessProbe }}
  505. readinessProbe:
  506. {{- toYaml . | nindent 6 }}
  507. {{- end }}
  508. {{- with .Values.sidecar.resources }}
  509. resources:
  510. {{- toYaml . | nindent 6 }}
  511. {{- end }}
  512. {{- with .Values.sidecar.securityContext }}
  513. securityContext:
  514. {{- toYaml . | nindent 6 }}
  515. {{- end }}
  516. volumeMounts:
  517. - name: sc-datasources-volume
  518. mountPath: "/etc/grafana/provisioning/datasources"
  519. {{- end}}
  520. {{- if .Values.sidecar.notifiers.enabled }}
  521. - name: {{ template "grafana.name" . }}-sc-notifiers
  522. {{- if .Values.sidecar.image.sha }}
  523. image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}@sha256:{{ .Values.sidecar.image.sha }}"
  524. {{- else }}
  525. image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}"
  526. {{- end }}
  527. imagePullPolicy: {{ .Values.sidecar.imagePullPolicy }}
  528. env:
  529. {{- range $key, $value := .Values.sidecar.notifiers.env }}
  530. - name: "{{ $key }}"
  531. value: "{{ $value }}"
  532. {{- end }}
  533. {{- if .Values.sidecar.notifiers.ignoreAlreadyProcessed }}
  534. - name: IGNORE_ALREADY_PROCESSED
  535. value: "true"
  536. {{- end }}
  537. - name: METHOD
  538. value: {{ .Values.sidecar.notifiers.watchMethod }}
  539. - name: LABEL
  540. value: "{{ .Values.sidecar.notifiers.label }}"
  541. {{- if .Values.sidecar.notifiers.labelValue }}
  542. - name: LABEL_VALUE
  543. value: {{ quote .Values.sidecar.notifiers.labelValue }}
  544. {{- end }}
  545. {{- if or .Values.sidecar.logLevel .Values.sidecar.notifiers.logLevel }}
  546. - name: LOG_LEVEL
  547. value: {{ default .Values.sidecar.logLevel .Values.sidecar.notifiers.logLevel }}
  548. {{- end }}
  549. - name: FOLDER
  550. value: "/etc/grafana/provisioning/notifiers"
  551. - name: RESOURCE
  552. value: {{ quote .Values.sidecar.notifiers.resource }}
  553. {{- if .Values.sidecar.enableUniqueFilenames }}
  554. - name: UNIQUE_FILENAMES
  555. value: "{{ .Values.sidecar.enableUniqueFilenames }}"
  556. {{- end }}
  557. {{- if .Values.sidecar.notifiers.searchNamespace }}
  558. - name: NAMESPACE
  559. value: "{{ tpl (.Values.sidecar.notifiers.searchNamespace | join ",") . }}"
  560. {{- end }}
  561. {{- if .Values.sidecar.skipTlsVerify }}
  562. - name: SKIP_TLS_VERIFY
  563. value: "{{ .Values.sidecar.skipTlsVerify }}"
  564. {{- end }}
  565. {{- if .Values.sidecar.notifiers.script }}
  566. - name: SCRIPT
  567. value: "{{ .Values.sidecar.notifiers.script }}"
  568. {{- end }}
  569. {{- if and (not .Values.env.GF_SECURITY_ADMIN_USER) (not .Values.env.GF_SECURITY_DISABLE_INITIAL_ADMIN_CREATION) }}
  570. - name: REQ_USERNAME
  571. valueFrom:
  572. secretKeyRef:
  573. name: {{ (tpl .Values.admin.existingSecret .) | default (include "grafana.fullname" .) }}
  574. key: {{ .Values.admin.userKey | default "admin-user" }}
  575. {{- end }}
  576. {{- 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) }}
  577. - name: REQ_PASSWORD
  578. valueFrom:
  579. secretKeyRef:
  580. name: {{ (tpl .Values.admin.existingSecret .) | default (include "grafana.fullname" .) }}
  581. key: {{ .Values.admin.passwordKey | default "admin-password" }}
  582. {{- end }}
  583. {{- if not .Values.sidecar.notifiers.skipReload }}
  584. - name: REQ_URL
  585. value: {{ .Values.sidecar.notifiers.reloadURL }}
  586. - name: REQ_METHOD
  587. value: POST
  588. {{- end }}
  589. {{- if .Values.sidecar.notifiers.watchServerTimeout }}
  590. {{- if ne .Values.sidecar.notifiers.watchMethod "WATCH" }}
  591. {{- fail (printf "Cannot use .Values.sidecar.notifiers.watchServerTimeout with .Values.sidecar.notifiers.watchMethod %s" .Values.sidecar.notifiers.watchMethod) }}
  592. {{- end }}
  593. - name: WATCH_SERVER_TIMEOUT
  594. value: "{{ .Values.sidecar.notifiers.watchServerTimeout }}"
  595. {{- end }}
  596. {{- if .Values.sidecar.notifiers.watchClientTimeout }}
  597. {{- if ne .Values.sidecar.notifiers.watchMethod "WATCH" }}
  598. {{- fail (printf "Cannot use .Values.sidecar.notifiers.watchClientTimeout with .Values.sidecar.notifiers.watchMethod %s" .Values.sidecar.notifiers.watchMethod) }}
  599. {{- end }}
  600. - name: WATCH_CLIENT_TIMEOUT
  601. value: "{{ .Values.sidecar.notifiers.watchClientTimeout }}"
  602. {{- end }}
  603. {{- with .Values.sidecar.livenessProbe }}
  604. livenessProbe:
  605. {{- toYaml . | nindent 6 }}
  606. {{- end }}
  607. {{- with .Values.sidecar.readinessProbe }}
  608. readinessProbe:
  609. {{- toYaml . | nindent 6 }}
  610. {{- end }}
  611. {{- with .Values.sidecar.resources }}
  612. resources:
  613. {{- toYaml . | nindent 6 }}
  614. {{- end }}
  615. {{- with .Values.sidecar.securityContext }}
  616. securityContext:
  617. {{- toYaml . | nindent 6 }}
  618. {{- end }}
  619. volumeMounts:
  620. - name: sc-notifiers-volume
  621. mountPath: "/etc/grafana/provisioning/notifiers"
  622. {{- end}}
  623. {{- if .Values.sidecar.plugins.enabled }}
  624. - name: {{ template "grafana.name" . }}-sc-plugins
  625. {{- if .Values.sidecar.image.sha }}
  626. image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}@sha256:{{ .Values.sidecar.image.sha }}"
  627. {{- else }}
  628. image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}"
  629. {{- end }}
  630. imagePullPolicy: {{ .Values.sidecar.imagePullPolicy }}
  631. env:
  632. {{- range $key, $value := .Values.sidecar.plugins.env }}
  633. - name: "{{ $key }}"
  634. value: "{{ $value }}"
  635. {{- end }}
  636. {{- if .Values.sidecar.plugins.ignoreAlreadyProcessed }}
  637. - name: IGNORE_ALREADY_PROCESSED
  638. value: "true"
  639. {{- end }}
  640. - name: METHOD
  641. value: {{ .Values.sidecar.plugins.watchMethod }}
  642. - name: LABEL
  643. value: "{{ .Values.sidecar.plugins.label }}"
  644. {{- if .Values.sidecar.plugins.labelValue }}
  645. - name: LABEL_VALUE
  646. value: {{ quote .Values.sidecar.plugins.labelValue }}
  647. {{- end }}
  648. {{- if or .Values.sidecar.logLevel .Values.sidecar.plugins.logLevel }}
  649. - name: LOG_LEVEL
  650. value: {{ default .Values.sidecar.logLevel .Values.sidecar.plugins.logLevel }}
  651. {{- end }}
  652. - name: FOLDER
  653. value: "/etc/grafana/provisioning/plugins"
  654. - name: RESOURCE
  655. value: {{ quote .Values.sidecar.plugins.resource }}
  656. {{- if .Values.sidecar.enableUniqueFilenames }}
  657. - name: UNIQUE_FILENAMES
  658. value: "{{ .Values.sidecar.enableUniqueFilenames }}"
  659. {{- end }}
  660. {{- if .Values.sidecar.plugins.searchNamespace }}
  661. - name: NAMESPACE
  662. value: "{{ tpl (.Values.sidecar.plugins.searchNamespace | join ",") . }}"
  663. {{- end }}
  664. {{- if .Values.sidecar.plugins.script }}
  665. - name: SCRIPT
  666. value: "{{ .Values.sidecar.plugins.script }}"
  667. {{- end }}
  668. {{- if .Values.sidecar.skipTlsVerify }}
  669. - name: SKIP_TLS_VERIFY
  670. value: "{{ .Values.sidecar.skipTlsVerify }}"
  671. {{- end }}
  672. {{- if and (not .Values.env.GF_SECURITY_ADMIN_USER) (not .Values.env.GF_SECURITY_DISABLE_INITIAL_ADMIN_CREATION) }}
  673. - name: REQ_USERNAME
  674. valueFrom:
  675. secretKeyRef:
  676. name: {{ (tpl .Values.admin.existingSecret .) | default (include "grafana.fullname" .) }}
  677. key: {{ .Values.admin.userKey | default "admin-user" }}
  678. {{- end }}
  679. {{- 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) }}
  680. - name: REQ_PASSWORD
  681. valueFrom:
  682. secretKeyRef:
  683. name: {{ (tpl .Values.admin.existingSecret .) | default (include "grafana.fullname" .) }}
  684. key: {{ .Values.admin.passwordKey | default "admin-password" }}
  685. {{- end }}
  686. {{- if not .Values.sidecar.plugins.skipReload }}
  687. - name: REQ_URL
  688. value: {{ .Values.sidecar.plugins.reloadURL }}
  689. - name: REQ_METHOD
  690. value: POST
  691. {{- end }}
  692. {{- if .Values.sidecar.plugins.watchServerTimeout }}
  693. {{- if ne .Values.sidecar.plugins.watchMethod "WATCH" }}
  694. {{- fail (printf "Cannot use .Values.sidecar.plugins.watchServerTimeout with .Values.sidecar.plugins.watchMethod %s" .Values.sidecar.plugins.watchMethod) }}
  695. {{- end }}
  696. - name: WATCH_SERVER_TIMEOUT
  697. value: "{{ .Values.sidecar.plugins.watchServerTimeout }}"
  698. {{- end }}
  699. {{- if .Values.sidecar.plugins.watchClientTimeout }}
  700. {{- if ne .Values.sidecar.plugins.watchMethod "WATCH" }}
  701. {{- fail (printf "Cannot use .Values.sidecar.plugins.watchClientTimeout with .Values.sidecar.plugins.watchMethod %s" .Values.sidecar.plugins.watchMethod) }}
  702. {{- end }}
  703. - name: WATCH_CLIENT_TIMEOUT
  704. value: "{{ .Values.sidecar.plugins.watchClientTimeout }}"
  705. {{- end }}
  706. {{- with .Values.sidecar.livenessProbe }}
  707. livenessProbe:
  708. {{- toYaml . | nindent 6 }}
  709. {{- end }}
  710. {{- with .Values.sidecar.readinessProbe }}
  711. readinessProbe:
  712. {{- toYaml . | nindent 6 }}
  713. {{- end }}
  714. {{- with .Values.sidecar.resources }}
  715. resources:
  716. {{- toYaml . | nindent 6 }}
  717. {{- end }}
  718. {{- with .Values.sidecar.securityContext }}
  719. securityContext:
  720. {{- toYaml . | nindent 6 }}
  721. {{- end }}
  722. volumeMounts:
  723. - name: sc-plugins-volume
  724. mountPath: "/etc/grafana/provisioning/plugins"
  725. {{- end}}
  726. - name: {{ .Chart.Name }}
  727. {{- if .Values.image.sha }}
  728. image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}@sha256:{{ .Values.image.sha }}"
  729. {{- else }}
  730. image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
  731. {{- end }}
  732. imagePullPolicy: {{ .Values.image.pullPolicy }}
  733. {{- if .Values.command }}
  734. command:
  735. {{- range .Values.command }}
  736. - {{ . | quote }}
  737. {{- end }}
  738. {{- end}}
  739. {{- with .Values.containerSecurityContext }}
  740. securityContext:
  741. {{- toYaml . | nindent 6 }}
  742. {{- end }}
  743. volumeMounts:
  744. - name: config
  745. mountPath: "/etc/grafana/grafana.ini"
  746. subPath: grafana.ini
  747. {{- if .Values.ldap.enabled }}
  748. - name: ldap
  749. mountPath: "/etc/grafana/ldap.toml"
  750. subPath: ldap.toml
  751. {{- end }}
  752. {{- $root := . }}
  753. {{- range .Values.extraConfigmapMounts }}
  754. - name: {{ tpl .name $root }}
  755. mountPath: {{ tpl .mountPath $root }}
  756. subPath: {{ (tpl .subPath $root) | default "" }}
  757. readOnly: {{ .readOnly }}
  758. {{- end }}
  759. - name: storage
  760. mountPath: "/var/lib/grafana"
  761. {{- if .Values.persistence.subPath }}
  762. subPath: {{ tpl .Values.persistence.subPath . }}
  763. {{- end }}
  764. {{- if .Values.dashboards }}
  765. {{- range $provider, $dashboards := .Values.dashboards }}
  766. {{- range $key, $value := $dashboards }}
  767. {{- if (or (hasKey $value "json") (hasKey $value "file")) }}
  768. - name: dashboards-{{ $provider }}
  769. mountPath: "/var/lib/grafana/dashboards/{{ $provider }}/{{ $key }}.json"
  770. subPath: "{{ $key }}.json"
  771. {{- end }}
  772. {{- end }}
  773. {{- end }}
  774. {{- end -}}
  775. {{- if .Values.dashboardsConfigMaps }}
  776. {{- range (keys .Values.dashboardsConfigMaps | sortAlpha) }}
  777. - name: dashboards-{{ . }}
  778. mountPath: "/var/lib/grafana/dashboards/{{ . }}"
  779. {{- end }}
  780. {{- end }}
  781. {{- if .Values.datasources }}
  782. {{- range (keys .Values.datasources | sortAlpha) }}
  783. - name: config
  784. mountPath: "/etc/grafana/provisioning/datasources/{{ . }}"
  785. subPath: {{ . | quote }}
  786. {{- end }}
  787. {{- end }}
  788. {{- if .Values.notifiers }}
  789. {{- range (keys .Values.notifiers | sortAlpha) }}
  790. - name: config
  791. mountPath: "/etc/grafana/provisioning/notifiers/{{ . }}"
  792. subPath: {{ . | quote }}
  793. {{- end }}
  794. {{- end }}
  795. {{- if .Values.alerting }}
  796. {{- range (keys .Values.alerting | sortAlpha) }}
  797. - name: config
  798. mountPath: "/etc/grafana/provisioning/alerting/{{ . }}"
  799. subPath: {{ . | quote }}
  800. {{- end }}
  801. {{- end }}
  802. {{- if .Values.dashboardProviders }}
  803. {{- range (keys .Values.dashboardProviders | sortAlpha) }}
  804. - name: config
  805. mountPath: "/etc/grafana/provisioning/dashboards/{{ . }}"
  806. subPath: {{ . | quote }}
  807. {{- end }}
  808. {{- end }}
  809. {{- with .Values.sidecar.alerts.enabled }}
  810. - name: sc-alerts-volume
  811. mountPath: "/etc/grafana/provisioning/alerting"
  812. {{- end}}
  813. {{- if .Values.sidecar.dashboards.enabled }}
  814. - name: sc-dashboard-volume
  815. mountPath: {{ .Values.sidecar.dashboards.folder | quote }}
  816. {{ if .Values.sidecar.dashboards.SCProvider }}
  817. - name: sc-dashboard-provider
  818. mountPath: "/etc/grafana/provisioning/dashboards/sc-dashboardproviders.yaml"
  819. subPath: provider.yaml
  820. {{- end}}
  821. {{- end}}
  822. {{- if .Values.sidecar.datasources.enabled }}
  823. - name: sc-datasources-volume
  824. mountPath: "/etc/grafana/provisioning/datasources"
  825. {{- end}}
  826. {{- if .Values.sidecar.plugins.enabled }}
  827. - name: sc-plugins-volume
  828. mountPath: "/etc/grafana/provisioning/plugins"
  829. {{- end}}
  830. {{- if .Values.sidecar.notifiers.enabled }}
  831. - name: sc-notifiers-volume
  832. mountPath: "/etc/grafana/provisioning/notifiers"
  833. {{- end}}
  834. {{- range .Values.extraSecretMounts }}
  835. - name: {{ .name }}
  836. mountPath: {{ .mountPath }}
  837. readOnly: {{ .readOnly }}
  838. subPath: {{ .subPath | default "" }}
  839. {{- end }}
  840. {{- range .Values.extraVolumeMounts }}
  841. - name: {{ .name }}
  842. mountPath: {{ .mountPath }}
  843. subPath: {{ .subPath | default "" }}
  844. readOnly: {{ .readOnly }}
  845. {{- end }}
  846. {{- range .Values.extraEmptyDirMounts }}
  847. - name: {{ .name }}
  848. mountPath: {{ .mountPath }}
  849. {{- end }}
  850. ports:
  851. - name: {{ .Values.podPortName }}
  852. containerPort: {{ .Values.service.targetPort }}
  853. protocol: TCP
  854. env:
  855. {{- if and (not .Values.env.GF_SECURITY_ADMIN_USER) (not .Values.env.GF_SECURITY_DISABLE_INITIAL_ADMIN_CREATION) }}
  856. - name: GF_SECURITY_ADMIN_USER
  857. valueFrom:
  858. secretKeyRef:
  859. name: {{ (tpl .Values.admin.existingSecret .) | default (include "grafana.fullname" .) }}
  860. key: {{ .Values.admin.userKey | default "admin-user" }}
  861. {{- end }}
  862. {{- 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) }}
  863. - name: GF_SECURITY_ADMIN_PASSWORD
  864. valueFrom:
  865. secretKeyRef:
  866. name: {{ (tpl .Values.admin.existingSecret .) | default (include "grafana.fullname" .) }}
  867. key: {{ .Values.admin.passwordKey | default "admin-password" }}
  868. {{- end }}
  869. {{- if .Values.plugins }}
  870. - name: GF_INSTALL_PLUGINS
  871. valueFrom:
  872. configMapKeyRef:
  873. name: {{ template "grafana.fullname" . }}
  874. key: plugins
  875. {{- end }}
  876. {{- if .Values.smtp.existingSecret }}
  877. - name: GF_SMTP_USER
  878. valueFrom:
  879. secretKeyRef:
  880. name: {{ .Values.smtp.existingSecret }}
  881. key: {{ .Values.smtp.userKey | default "user" }}
  882. - name: GF_SMTP_PASSWORD
  883. valueFrom:
  884. secretKeyRef:
  885. name: {{ .Values.smtp.existingSecret }}
  886. key: {{ .Values.smtp.passwordKey | default "password" }}
  887. {{- end }}
  888. {{- if .Values.imageRenderer.enabled }}
  889. - name: GF_RENDERING_SERVER_URL
  890. value: http://{{ template "grafana.fullname" . }}-image-renderer.{{ template "grafana.namespace" . }}:{{ .Values.imageRenderer.service.port }}/render
  891. - name: GF_RENDERING_CALLBACK_URL
  892. value: {{ .Values.imageRenderer.grafanaProtocol }}://{{ template "grafana.fullname" . }}.{{ template "grafana.namespace" . }}:{{ .Values.service.port }}/{{ .Values.imageRenderer.grafanaSubPath }}
  893. {{- end }}
  894. - name: GF_PATHS_DATA
  895. value: {{ (get .Values "grafana.ini").paths.data }}
  896. - name: GF_PATHS_LOGS
  897. value: {{ (get .Values "grafana.ini").paths.logs }}
  898. - name: GF_PATHS_PLUGINS
  899. value: {{ (get .Values "grafana.ini").paths.plugins }}
  900. - name: GF_PATHS_PROVISIONING
  901. value: {{ (get .Values "grafana.ini").paths.provisioning }}
  902. {{- range $key, $value := .Values.envValueFrom }}
  903. - name: {{ $key | quote }}
  904. valueFrom:
  905. {{ tpl (toYaml $value) $ | indent 10 }}
  906. {{- end }}
  907. {{- range $key, $value := .Values.env }}
  908. - name: "{{ tpl $key $ }}"
  909. value: "{{ tpl (print $value) $ }}"
  910. {{- end }}
  911. {{- if or .Values.envFromSecret (or .Values.envRenderSecret .Values.envFromSecrets) .Values.envFromConfigMaps }}
  912. envFrom:
  913. {{- if .Values.envFromSecret }}
  914. - secretRef:
  915. name: {{ tpl .Values.envFromSecret . }}
  916. {{- end }}
  917. {{- if .Values.envRenderSecret }}
  918. - secretRef:
  919. name: {{ template "grafana.fullname" . }}-env
  920. {{- end }}
  921. {{- range .Values.envFromSecrets }}
  922. - secretRef:
  923. name: {{ tpl .name $ }}
  924. optional: {{ .optional | default false }}
  925. {{- end }}
  926. {{- range .Values.envFromConfigMaps }}
  927. - configMapRef:
  928. name: {{ tpl .name $ }}
  929. optional: {{ .optional | default false }}
  930. {{- end }}
  931. {{- end }}
  932. {{- with .Values.livenessProbe }}
  933. livenessProbe:
  934. {{- toYaml . | nindent 6 }}
  935. {{- end }}
  936. {{- with .Values.readinessProbe }}
  937. readinessProbe:
  938. {{- toYaml . | nindent 6 }}
  939. {{- end }}
  940. {{- if .Values.lifecycleHooks }}
  941. lifecycle: {{ tpl (.Values.lifecycleHooks | toYaml) . | nindent 6 }}
  942. {{- end }}
  943. {{- with .Values.resources }}
  944. resources:
  945. {{- toYaml . | nindent 6 }}
  946. {{- end }}
  947. {{- with .Values.extraContainers }}
  948. {{ tpl . $ | indent 2 }}
  949. {{- end }}
  950. {{- with .Values.nodeSelector }}
  951. nodeSelector:
  952. {{- toYaml . | nindent 2 }}
  953. {{- end }}
  954. {{- $root := . }}
  955. {{- with .Values.affinity }}
  956. affinity:
  957. {{ tpl (toYaml .) $root | indent 2 }}
  958. {{- end }}
  959. {{- with .Values.topologySpreadConstraints }}
  960. topologySpreadConstraints:
  961. {{- toYaml . | nindent 2 }}
  962. {{- end }}
  963. {{- with .Values.tolerations }}
  964. tolerations:
  965. {{- toYaml . | nindent 2 }}
  966. {{- end }}
  967. volumes:
  968. - name: config
  969. configMap:
  970. name: {{ template "grafana.fullname" . }}
  971. {{- $root := . }}
  972. {{- range .Values.extraConfigmapMounts }}
  973. - name: {{ tpl .name $root }}
  974. configMap:
  975. name: {{ tpl .configMap $root }}
  976. {{- if .items }}
  977. items: {{ toYaml .items | nindent 6 }}
  978. {{- end }}
  979. {{- end }}
  980. {{- if .Values.dashboards }}
  981. {{- range (keys .Values.dashboards | sortAlpha) }}
  982. - name: dashboards-{{ . }}
  983. configMap:
  984. name: {{ template "grafana.fullname" $ }}-dashboards-{{ . }}
  985. {{- end }}
  986. {{- end }}
  987. {{- if .Values.dashboardsConfigMaps }}
  988. {{ $root := . }}
  989. {{- range $provider, $name := .Values.dashboardsConfigMaps }}
  990. - name: dashboards-{{ $provider }}
  991. configMap:
  992. name: {{ tpl $name $root }}
  993. {{- end }}
  994. {{- end }}
  995. {{- if .Values.ldap.enabled }}
  996. - name: ldap
  997. secret:
  998. {{- if .Values.ldap.existingSecret }}
  999. secretName: {{ .Values.ldap.existingSecret }}
  1000. {{- else }}
  1001. secretName: {{ template "grafana.fullname" . }}
  1002. {{- end }}
  1003. items:
  1004. - key: ldap-toml
  1005. path: ldap.toml
  1006. {{- end }}
  1007. {{- if and .Values.persistence.enabled (eq .Values.persistence.type "pvc") }}
  1008. - name: storage
  1009. persistentVolumeClaim:
  1010. claimName: {{ tpl (.Values.persistence.existingClaim | default (include "grafana.fullname" .)) . }}
  1011. {{- else if and .Values.persistence.enabled (eq .Values.persistence.type "statefulset") }}
  1012. # nothing
  1013. {{- else }}
  1014. - name: storage
  1015. {{- if .Values.persistence.inMemory.enabled }}
  1016. emptyDir:
  1017. medium: Memory
  1018. {{- if .Values.persistence.inMemory.sizeLimit }}
  1019. sizeLimit: {{ .Values.persistence.inMemory.sizeLimit }}
  1020. {{- end -}}
  1021. {{- else }}
  1022. emptyDir: {}
  1023. {{- end -}}
  1024. {{- end -}}
  1025. {{- if .Values.sidecar.alerts.enabled }}
  1026. - name: sc-alerts-volume
  1027. {{- if .Values.sidecar.alerts.sizeLimit }}
  1028. emptyDir:
  1029. sizeLimit: {{ .Values.sidecar.alerts.sizeLimit }}
  1030. {{- else }}
  1031. emptyDir: {}
  1032. {{- end -}}
  1033. {{- end -}}
  1034. {{- if .Values.sidecar.dashboards.enabled }}
  1035. - name: sc-dashboard-volume
  1036. {{- if .Values.sidecar.dashboards.sizeLimit }}
  1037. emptyDir:
  1038. sizeLimit: {{ .Values.sidecar.dashboards.sizeLimit }}
  1039. {{- else }}
  1040. emptyDir: {}
  1041. {{- end -}}
  1042. {{- if .Values.sidecar.dashboards.SCProvider }}
  1043. - name: sc-dashboard-provider
  1044. configMap:
  1045. name: {{ template "grafana.fullname" . }}-config-dashboards
  1046. {{- end }}
  1047. {{- end }}
  1048. {{- if .Values.sidecar.datasources.enabled }}
  1049. - name: sc-datasources-volume
  1050. {{- if .Values.sidecar.datasources.sizeLimit }}
  1051. emptyDir:
  1052. sizeLimit: {{ .Values.sidecar.datasources.sizeLimit }}
  1053. {{- else }}
  1054. emptyDir: {}
  1055. {{- end -}}
  1056. {{- end -}}
  1057. {{- if .Values.sidecar.plugins.enabled }}
  1058. - name: sc-plugins-volume
  1059. {{- if .Values.sidecar.plugins.sizeLimit }}
  1060. emptyDir:
  1061. sizeLimit: {{ .Values.sidecar.plugins.sizeLimit }}
  1062. {{- else }}
  1063. emptyDir: {}
  1064. {{- end -}}
  1065. {{- end -}}
  1066. {{- if .Values.sidecar.notifiers.enabled }}
  1067. - name: sc-notifiers-volume
  1068. {{- if .Values.sidecar.notifiers.sizeLimit }}
  1069. emptyDir:
  1070. sizeLimit: {{ .Values.sidecar.notifiers.sizeLimit }}
  1071. {{- else }}
  1072. emptyDir: {}
  1073. {{- end -}}
  1074. {{- end -}}
  1075. {{- range .Values.extraSecretMounts }}
  1076. {{- if .secretName }}
  1077. - name: {{ .name }}
  1078. secret:
  1079. secretName: {{ .secretName }}
  1080. defaultMode: {{ .defaultMode }}
  1081. {{- if .items }}
  1082. items: {{ toYaml .items | nindent 6 }}
  1083. {{- end }}
  1084. {{- else if .projected }}
  1085. - name: {{ .name }}
  1086. projected: {{- toYaml .projected | nindent 6 }}
  1087. {{- else if .csi }}
  1088. - name: {{ .name }}
  1089. csi: {{- toYaml .csi | nindent 6 }}
  1090. {{- end }}
  1091. {{- end }}
  1092. {{- range .Values.extraVolumeMounts }}
  1093. - name: {{ .name }}
  1094. {{- if .existingClaim }}
  1095. persistentVolumeClaim:
  1096. claimName: {{ .existingClaim }}
  1097. {{- else if .hostPath }}
  1098. hostPath:
  1099. path: {{ .hostPath }}
  1100. {{- else if .csi }}
  1101. csi:
  1102. data:
  1103. {{ toYaml .data | nindent 6 }}
  1104. {{- else }}
  1105. emptyDir: {}
  1106. {{- end }}
  1107. {{- end }}
  1108. {{- range .Values.extraEmptyDirMounts }}
  1109. - name: {{ .name }}
  1110. emptyDir: {}
  1111. {{- end -}}
  1112. {{- if .Values.extraContainerVolumes }}
  1113. {{ tpl (toYaml .Values.extraContainerVolumes) . | indent 2 }}
  1114. {{- end }}
  1115. {{- end }}