_grafana.tpl 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 "ix.v1.common.app.storageOptions" (dict "storage" .Values.grafanaStorage.data) | nindent 4 }}
  72. targetSelector:
  73. grafana:
  74. grafana:
  75. mountPath: /var/lib/grafana
  76. {{- if and (eq .Values.grafanaStorage.data.type "ixVolume")
  77. (not (.Values.grafanaStorage.data.ixVolumeConfig | default dict).aclEnable) }}
  78. 01-permissions:
  79. mountPath: /mnt/directories/data
  80. {{- end }}
  81. tmp:
  82. enabled: true
  83. type: emptyDir
  84. targetSelector:
  85. grafana:
  86. grafana:
  87. mountPath: /tmp
  88. {{- range $idx, $storage := .Values.grafanaStorage.additionalStorages }}
  89. {{ printf "grafana-%v:" (int $idx) }}
  90. enabled: true
  91. {{- include "ix.v1.common.app.storageOptions" (dict "storage" $storage) | nindent 4 }}
  92. targetSelector:
  93. grafana:
  94. grafana:
  95. mountPath: {{ $storage.mountPath }}
  96. {{- if and (eq $storage.type "ixVolume") (not ($storage.ixVolumeConfig | default dict).aclEnable) }}
  97. 01-permissions:
  98. mountPath: /mnt/directories{{ $storage.mountPath }}
  99. {{- end }}
  100. {{- end }}
  101. {{- if .Values.grafanaNetwork.certificateID }}
  102. cert:
  103. enabled: true
  104. type: secret
  105. objectName: grafana-cert
  106. defaultMode: "0600"
  107. items:
  108. - key: tls.key
  109. path: tls.key
  110. - key: tls.crt
  111. path: tls.crt
  112. targetSelector:
  113. grafana:
  114. grafana:
  115. mountPath: /grafana/certs
  116. readOnly: true
  117. scaleCertificate:
  118. grafana-cert:
  119. enabled: true
  120. id: {{ .Values.grafanaNetwork.certificateID }}
  121. {{- end -}}
  122. {{- end -}}