_prometheus.tpl 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. {{- define "prometheus.workload" -}}
  2. workload:
  3. prometheus:
  4. enabled: true
  5. primary: true
  6. type: Deployment
  7. podSpec:
  8. hostNetwork: {{ .Values.prometheusNetwork.hostNetwork }}
  9. containers:
  10. prometheus:
  11. enabled: true
  12. primary: true
  13. imageSelector: image
  14. securityContext:
  15. runAsUser: {{ .Values.prometheusRunAs.user }}
  16. runAsGroup: {{ .Values.prometheusRunAs.group }}
  17. args:
  18. - --web.listen-address=0.0.0.0:{{ .Values.prometheusNetwork.apiPort }}
  19. - --storage.tsdb.path=/data
  20. - --config.file=/config/prometheus.yml
  21. - --storage.tsdb.retention.time={{ .Values.prometheusConfig.retentionTime }}
  22. {{ with .Values.prometheusConfig.retentionSize }}
  23. - --storage.tsdb.retention.size={{ . }}
  24. {{ end }}
  25. {{ if .Values.prometheusConfig.walCompression }}
  26. - --storage.tsdb.wal-compression
  27. {{ end }}
  28. {{ with .Values.prometheusConfig.additionalArgs }}
  29. extraArgs:
  30. {{ range $arg := . }}
  31. - {{ $arg | quote }}
  32. {{ end }}
  33. {{ end }}
  34. {{ with .Values.prometheusConfig.additionalEnvs }}
  35. env:
  36. {{ range $env := . }}
  37. {{ $env.name }}: {{ $env.value }}
  38. {{ end }}
  39. {{ end }}
  40. probes:
  41. liveness:
  42. enabled: true
  43. type: http
  44. port: {{ .Values.prometheusNetwork.apiPort }}
  45. path: /-/healthy
  46. readiness:
  47. enabled: true
  48. type: http
  49. port: {{ .Values.prometheusNetwork.apiPort }}
  50. path: /-/ready
  51. startup:
  52. enabled: true
  53. type: http
  54. port: {{ .Values.prometheusNetwork.apiPort }}
  55. path: /-/ready
  56. initContainers:
  57. {{- include "ix.v1.common.app.permissions" (dict "containerName" "01-permissions"
  58. "UID" .Values.prometheusRunAs.user
  59. "GID" .Values.prometheusRunAs.group
  60. "mode" "check"
  61. "type" "install") | nindent 8 }}
  62. init-config:
  63. enabled: true
  64. type: init
  65. imageSelector: image
  66. resources:
  67. limits:
  68. cpu: 500m
  69. memory: 256Mi
  70. securityContext:
  71. runAsUser: {{ .Values.prometheusRunAs.user }}
  72. runAsGroup: {{ .Values.prometheusRunAs.group }}
  73. command: sh
  74. args:
  75. - -c
  76. - |
  77. if [ ! -f /config/prometheus.yml ]; then
  78. touch /config/prometheus.yml
  79. fi
  80. {{/* Service */}}
  81. service:
  82. prometheus:
  83. enabled: true
  84. primary: true
  85. type: NodePort
  86. targetSelector: prometheus
  87. ports:
  88. prometheus:
  89. enabled: true
  90. primary: true
  91. port: {{ .Values.prometheusNetwork.apiPort }}
  92. nodePort: {{ .Values.prometheusNetwork.apiPort }}
  93. targetSelector: prometheus
  94. {{/* Persistence */}}
  95. persistence:
  96. data:
  97. enabled: true
  98. {{- include "ix.v1.common.app.storageOptions" (dict "storage" .Values.prometheusStorage.data) | nindent 4 }}
  99. targetSelector:
  100. prometheus:
  101. prometheus:
  102. mountPath: /data
  103. {{- if and (eq .Values.prometheusStorage.data.type "ixVolume")
  104. (not (.Values.prometheusStorage.data.ixVolumeConfig | default dict).aclEnable) }}
  105. 01-permissions:
  106. mountPath: /mnt/directories/data
  107. {{- end }}
  108. config:
  109. enabled: true
  110. {{- include "ix.v1.common.app.storageOptions" (dict "storage" .Values.prometheusStorage.config) | nindent 4 }}
  111. targetSelector:
  112. prometheus:
  113. prometheus:
  114. mountPath: /config
  115. init-config:
  116. mountPath: /config
  117. {{- if and (eq .Values.prometheusStorage.config.type "ixVolume")
  118. (not (.Values.prometheusStorage.config.ixVolumeConfig | default dict).aclEnable) }}
  119. 01-permissions:
  120. mountPath: /mnt/directories/config
  121. {{- end }}
  122. {{- range $idx, $storage := .Values.prometheusStorage.additionalStorages }}
  123. {{ printf "prometheus-%v:" (int $idx) }}
  124. enabled: true
  125. {{- include "ix.v1.common.app.storageOptions" (dict "storage" $storage) | nindent 4 }}
  126. targetSelector:
  127. prometheus:
  128. prometheus:
  129. mountPath: {{ $storage.mountPath }}
  130. {{- if and (eq $storage.type "ixVolume") (not ($storage.ixVolumeConfig | default dict).aclEnable) }}
  131. 01-permissions:
  132. mountPath: /mnt/directories{{ $storage.mountPath }}
  133. {{- end }}
  134. {{- end }}
  135. {{- end -}}