_grafana.tpl 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. {{- define "grafana.workload" -}}
  2. workload:
  3. grafana:
  4. enabled: true
  5. primary: true
  6. type: Deployment
  7. podSpec:
  8. hostNetwork: {{ .Values.grafanaNetwork.hostNetwork }}
  9. containers:
  10. grafana:
  11. enabled: true
  12. primary: true
  13. imageSelector: image
  14. securityContext:
  15. runAsUser: {{ .Values.grafanaRunAs.user }}
  16. runAsGroup: {{ .Values.grafanaRunAs.group }}
  17. envFrom:
  18. - configMapRef:
  19. name: grafana-config
  20. {{ with .Values.grafanaConfig.additionalEnvs }}
  21. envList:
  22. {{ range $env := . }}
  23. - name: {{ $env.name }}
  24. value: {{ $env.value }}
  25. {{ end }}
  26. {{ end }}
  27. probes:
  28. {{ $scheme := "http" }}
  29. {{ if .Values.grafanaNetwork.certificateID }}
  30. {{ $scheme = "https" }}
  31. {{ end }}
  32. liveness:
  33. enabled: true
  34. type: {{ $scheme }}
  35. port: {{ .Values.grafanaNetwork.webPort }}
  36. path: /api/health
  37. readiness:
  38. enabled: true
  39. type: {{ $scheme }}
  40. port: {{ .Values.grafanaNetwork.webPort }}
  41. path: /api/health
  42. startup:
  43. enabled: true
  44. type: {{ $scheme }}
  45. port: {{ .Values.grafanaNetwork.webPort }}
  46. path: /api/health
  47. initContainers:
  48. {{- include "ix.v1.common.app.permissions" (dict "containerName" "01-permissions"
  49. "UID" .Values.grafanaRunAs.user
  50. "GID" .Values.grafanaRunAs.group
  51. "mode" "check"
  52. "type" "install") | nindent 8 }}
  53. {{/* Service */}}
  54. service:
  55. grafana:
  56. enabled: true
  57. primary: true
  58. type: NodePort
  59. targetSelector: grafana
  60. ports:
  61. webui:
  62. enabled: true
  63. primary: true
  64. port: {{ .Values.grafanaNetwork.webPort }}
  65. nodePort: {{ .Values.grafanaNetwork.webPort }}
  66. targetSelector: grafana
  67. {{/* Persistence */}}
  68. persistence:
  69. data:
  70. enabled: true
  71. {{- include "grafana.storage.ci.migration" (dict "storage" .Values.grafanaStorage.data) }}
  72. {{- include "ix.v1.common.app.storageOptions" (dict "storage" .Values.grafanaStorage.data) | nindent 4 }}
  73. targetSelector:
  74. grafana:
  75. grafana:
  76. mountPath: /var/lib/grafana
  77. {{- if and (eq .Values.grafanaStorage.data.type "ixVolume")
  78. (not (.Values.grafanaStorage.data.ixVolumeConfig | default dict).aclEnable) }}
  79. 01-permissions:
  80. mountPath: /mnt/directories/data
  81. {{- end }}
  82. tmp:
  83. enabled: true
  84. type: emptyDir
  85. targetSelector:
  86. grafana:
  87. grafana:
  88. mountPath: /tmp
  89. {{- range $idx, $storage := .Values.grafanaStorage.additionalStorages }}
  90. {{ printf "grafana-%v:" (int $idx) }}
  91. enabled: true
  92. {{- include "grafana.storage.ci.migration" (dict "storage" $storage) }}
  93. {{- include "ix.v1.common.app.storageOptions" (dict "storage" $storage) | nindent 4 }}
  94. targetSelector:
  95. grafana:
  96. grafana:
  97. mountPath: {{ $storage.mountPath }}
  98. {{- if and (eq $storage.type "ixVolume") (not ($storage.ixVolumeConfig | default dict).aclEnable) }}
  99. 01-permissions:
  100. mountPath: /mnt/directories{{ $storage.mountPath }}
  101. {{- end }}
  102. {{- end }}
  103. {{- if .Values.grafanaNetwork.certificateID }}
  104. cert:
  105. enabled: true
  106. type: secret
  107. objectName: grafana-cert
  108. defaultMode: "0600"
  109. items:
  110. - key: tls.key
  111. path: tls.key
  112. - key: tls.crt
  113. path: tls.crt
  114. targetSelector:
  115. grafana:
  116. grafana:
  117. mountPath: /grafana/certs
  118. readOnly: true
  119. scaleCertificate:
  120. grafana-cert:
  121. enabled: true
  122. id: {{ .Values.grafanaNetwork.certificateID }}
  123. {{- end -}}
  124. {{- end -}}
  125. {{/* TODO: Remove on the next version bump, eg 1.2.0+ */}}
  126. {{- define "grafana.storage.ci.migration" -}}
  127. {{- $storage := .storage -}}
  128. {{- if $storage.hostPath -}}
  129. {{- $_ := set $storage "hostPathConfig" dict -}}
  130. {{- $_ := set $storage.hostPathConfig "hostPath" $storage.hostPath -}}
  131. {{- end -}}
  132. {{- end -}}