_prometheus.tpl 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. init-config:
  58. enabled: true
  59. type: init
  60. imageSelector: image
  61. resources:
  62. limits:
  63. cpu: 500m
  64. memory: 256Mi
  65. securityContext:
  66. runAsUser: {{ .Values.prometheusRunAs.user }}
  67. runAsGroup: {{ .Values.prometheusRunAs.group }}
  68. command: sh
  69. args:
  70. - -c
  71. - |
  72. if [ ! -f /config/prometheus.yml ]; then
  73. touch /config/prometheus.yml
  74. fi
  75. {{/* Service */}}
  76. service:
  77. prometheus:
  78. enabled: true
  79. primary: true
  80. type: NodePort
  81. targetSelector: prometheus
  82. ports:
  83. prometheus:
  84. enabled: true
  85. primary: true
  86. port: {{ .Values.prometheusNetwork.apiPort }}
  87. nodePort: {{ .Values.prometheusNetwork.apiPort }}
  88. targetSelector: prometheus
  89. {{/* Persistence */}}
  90. persistence:
  91. data:
  92. enabled: true
  93. {{- include "prometheus.storage.ci.migration" (dict "storage" .Values.prometheusStorage.data) }}
  94. {{- include "ix.v1.common.app.storageOptions" (dict "storage" .Values.prometheusStorage.data) | nindent 4 }}
  95. targetSelector:
  96. prometheus:
  97. prometheus:
  98. mountPath: /data
  99. config:
  100. enabled: true
  101. {{- include "prometheus.storage.ci.migration" (dict "storage" .Values.prometheusStorage.config) }}
  102. {{- include "ix.v1.common.app.storageOptions" (dict "storage" .Values.prometheusStorage.config) | nindent 4 }}
  103. targetSelector:
  104. prometheus:
  105. prometheus:
  106. mountPath: /config
  107. init-config:
  108. mountPath: /config
  109. {{- range $idx, $storage := .Values.prometheusStorage.additionalStorages }}
  110. {{ printf "prometheus-%v:" (int $idx) }}
  111. enabled: true
  112. {{- include "prometheus.storage.ci.migration" (dict "storage" $storage) }}
  113. {{- include "ix.v1.common.app.storageOptions" (dict "storage" $storage) | nindent 4 }}
  114. targetSelector:
  115. prometheus:
  116. prometheus:
  117. mountPath: {{ $storage.mountPath }}
  118. {{- end }}
  119. {{- end -}}
  120. {{/* TODO: Remove on the next version bump, eg 1.1.0+ */}}
  121. {{- define "prometheus.storage.ci.migration" -}}
  122. {{- $storage := .storage -}}
  123. {{- if $storage.hostPath -}}
  124. {{- $_ := set $storage "hostPathConfig" dict -}}
  125. {{- $_ := set $storage.hostPathConfig "hostPath" $storage.hostPath -}}
  126. {{- end -}}
  127. {{- end -}}