prometheus.j2 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. apiVersion: apps/v1beta1
  2. kind: StatefulSet
  3. metadata:
  4. name: prometheus
  5. namespace: {{ namespace }}
  6. labels:
  7. app: prometheus
  8. spec:
  9. updateStrategy:
  10. type: RollingUpdate
  11. podManagementPolicy: Parallel
  12. selector:
  13. provider: openshift
  14. matchLabels:
  15. app: prometheus
  16. template:
  17. metadata:
  18. name: prometheus
  19. labels:
  20. app: prometheus
  21. spec:
  22. serviceAccountName: prometheus
  23. {% if openshift_prometheus_node_selector is iterable and openshift_prometheus_node_selector | length > 0 %}
  24. nodeSelector:
  25. {% for key, value in openshift_prometheus_node_selector.iteritems() %}
  26. {{key}}: "{{value}}"
  27. {% endfor %}
  28. {% endif %}
  29. containers:
  30. # Deploy Prometheus behind an oauth proxy
  31. - name: prom-proxy
  32. image: "{{openshift_prometheus_proxy_image_prefix}}oauth-proxy:{{openshift_prometheus_proxy_image_version}}"
  33. imagePullPolicy: IfNotPresent
  34. resources:
  35. requests:
  36. {% if openshift_prometheus_oauth_proxy_memory_requests is defined and openshift_prometheus_oauth_proxy_memory_requests is not none %}
  37. memory: "{{openshift_prometheus_oauth_proxy_memory_requests}}"
  38. {% endif %}
  39. {% if openshift_prometheus_oauth_proxy_cpu_requests is defined and openshift_prometheus_oauth_proxy_cpu_requests is not none %}
  40. cpu: "{{openshift_prometheus_oauth_proxy_cpu_requests}}"
  41. {% endif %}
  42. limits:
  43. {% if openshift_prometheus_oauth_proxy_memory_limit is defined and openshift_prometheus_oauth_proxy_memory_limit is not none %}
  44. memory: "{{openshift_prometheus_oauth_proxy_memory_limit}}"
  45. {% endif %}
  46. {% if openshift_prometheus_oauth_proxy_cpu_limit is defined and openshift_prometheus_oauth_proxy_cpu_limit is not none %}
  47. cpu: "{{openshift_prometheus_oauth_proxy_cpu_limit}}"
  48. {% endif %}
  49. ports:
  50. - containerPort: 8443
  51. name: web
  52. args:
  53. - -provider=openshift
  54. - -https-address=:8443
  55. - -http-address=
  56. - -email-domain=*
  57. - -upstream=http://localhost:9090
  58. - -client-id=system:serviceaccount:{{ namespace }}:prometheus
  59. - '-openshift-sar={"resource": "namespaces", "verb": "get", "resourceName": "{{ namespace }}", "namespace": "{{ namespace }}"}'
  60. - '-openshift-delegate-urls={"/": {"resource": "namespaces", "verb": "get", "resourceName": "{{ namespace }}", "namespace": "{{ namespace }}"}}'
  61. - -tls-cert=/etc/tls/private/tls.crt
  62. - -tls-key=/etc/tls/private/tls.key
  63. - -client-secret-file=/var/run/secrets/kubernetes.io/serviceaccount/token
  64. - -cookie-secret-file=/etc/proxy/secrets/session_secret
  65. - -openshift-ca=/etc/pki/tls/cert.pem
  66. - -openshift-ca=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
  67. - -skip-auth-regex=^/metrics
  68. volumeMounts:
  69. - mountPath: /etc/tls/private
  70. name: prometheus-tls
  71. - mountPath: /etc/proxy/secrets
  72. name: prometheus-secrets
  73. - mountPath: /prometheus
  74. name: prometheus-data
  75. - name: prometheus
  76. args:
  77. - --storage.tsdb.retention=6h
  78. - --storage.tsdb.min-block-duration=2m
  79. - --config.file=/etc/prometheus/prometheus.yml
  80. - --web.listen-address=localhost:9090
  81. image: "{{openshift_prometheus_image_prefix}}prometheus:{{openshift_prometheus_image_version}}"
  82. imagePullPolicy: IfNotPresent
  83. resources:
  84. requests:
  85. {% if openshift_prometheus_memory_requests is defined and openshift_prometheus_memory_requests is not none %}
  86. memory: "{{openshift_prometheus_memory_requests}}"
  87. {% endif %}
  88. {% if openshift_prometheus_cpu_requests is defined and openshift_prometheus_cpu_requests is not none %}
  89. cpu: "{{openshift_prometheus_cpu_requests}}"
  90. {% endif %}
  91. limits:
  92. {% if openshift_prometheus_memory_limit is defined and openshift_prometheus_memory_limit is not none %}
  93. memory: "{{ openshift_prometheus_memory_limit }}"
  94. {% endif %}
  95. {% if openshift_prometheus_cpu_limit is defined and openshift_prometheus_cpu_limit is not none %}
  96. cpu: "{{openshift_prometheus_cpu_limit}}"
  97. {% endif %}
  98. volumeMounts:
  99. - mountPath: /etc/prometheus
  100. name: prometheus-config
  101. - mountPath: /prometheus
  102. name: prometheus-data
  103. # Deploy alertmanager behind prometheus-alert-buffer behind an oauth proxy
  104. - name: alerts-proxy
  105. image: "{{openshift_prometheus_proxy_image_prefix}}oauth-proxy:{{openshift_prometheus_proxy_image_version}}"
  106. imagePullPolicy: IfNotPresent
  107. resources:
  108. requests:
  109. {% if openshift_prometheus_oauth_proxy_memory_requests is defined and openshift_prometheus_oauth_proxy_memory_requests is not none %}
  110. memory: "{{openshift_prometheus_oauth_proxy_memory_requests}}"
  111. {% endif %}
  112. {% if openshift_prometheus_oauth_proxy_cpu_requests is defined and openshift_prometheus_oauth_proxy_cpu_requests is not none %}
  113. cpu: "{{openshift_prometheus_oauth_proxy_cpu_requests}}"
  114. {% endif %}
  115. limits:
  116. {% if openshift_prometheus_oauth_proxy_memory_limit is defined and openshift_prometheus_oauth_proxy_memory_limit is not none %}
  117. memory: "{{openshift_prometheus_oauth_proxy_memory_limit}}"
  118. {% endif %}
  119. {% if openshift_prometheus_oauth_proxy_cpu_limit is defined and openshift_prometheus_oauth_proxy_cpu_limit is not none %}
  120. cpu: "{{openshift_prometheus_oauth_proxy_cpu_limit}}"
  121. {% endif %}
  122. ports:
  123. - containerPort: 9443
  124. name: web
  125. args:
  126. - -provider=openshift
  127. - -https-address=:9443
  128. - -http-address=
  129. - -email-domain=*
  130. - -upstream=http://localhost:9099
  131. - -client-id=system:serviceaccount:{{ namespace }}:prometheus
  132. - '-openshift-sar={"resource": "namespaces", "verb": "get", "resourceName": "{{ namespace }}", "namespace": "{{ namespace }}"}'
  133. - '-openshift-delegate-urls={"/": {"resource": "namespaces", "verb": "get", "resourceName": "{{ namespace }}", "namespace": "{{ namespace }}"}}'
  134. - -tls-cert=/etc/tls/private/tls.crt
  135. - -tls-key=/etc/tls/private/tls.key
  136. - -client-secret-file=/var/run/secrets/kubernetes.io/serviceaccount/token
  137. - -cookie-secret-file=/etc/proxy/secrets/session_secret
  138. - -openshift-ca=/etc/pki/tls/cert.pem
  139. - -openshift-ca=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
  140. volumeMounts:
  141. - mountPath: /etc/tls/private
  142. name: alerts-tls
  143. - mountPath: /etc/proxy/secrets
  144. name: alerts-secrets
  145. - name: alert-buffer
  146. args:
  147. - --storage-path=/alert-buffer/messages.db
  148. image: "{{openshift_prometheus_alertbuffer_image_prefix}}prometheus-alert-buffer:{{openshift_prometheus_alertbuffer_image_version}}"
  149. imagePullPolicy: IfNotPresent
  150. resources:
  151. requests:
  152. {% if openshift_prometheus_alertbuffer_memory_requests is defined and openshift_prometheus_alertbuffer_memory_requests is not none %}
  153. memory: "{{openshift_prometheus_alertbuffer_memory_requests}}"
  154. {% endif %}
  155. {% if openshift_prometheus_alertbuffer_cpu_requests is defined and openshift_prometheus_alertbuffer_cpu_requests is not none %}
  156. cpu: "{{openshift_prometheus_alertbuffer_cpu_requests}}"
  157. {% endif %}
  158. limits:
  159. {% if openshift_prometheus_alertbuffer_memory_limit is defined and openshift_prometheus_alertbuffer_memory_limit is not none %}
  160. memory: "{{openshift_prometheus_alertbuffer_memory_limit}}"
  161. {% endif %}
  162. {% if openshift_prometheus_alertbuffer_cpu_limit is defined and openshift_prometheus_alertbuffer_cpu_limit is not none %}
  163. cpu: "{{openshift_prometheus_alertbuffer_cpu_limit}}"
  164. {% endif %}
  165. volumeMounts:
  166. - mountPath: /alert-buffer
  167. name: alert-buffer-data
  168. ports:
  169. - containerPort: 9099
  170. name: alert-buf
  171. - name: alertmanager
  172. args:
  173. - -config.file=/etc/alertmanager/alertmanager.yml
  174. image: "{{openshift_prometheus_alertmanager_image_prefix}}prometheus-alertmanager:{{openshift_prometheus_alertmanager_image_version}}"
  175. imagePullPolicy: IfNotPresent
  176. resources:
  177. requests:
  178. {% if openshift_prometheus_alertmanager_memory_requests is defined and openshift_prometheus_alertmanager_memory_requests is not none %}
  179. memory: "{{openshift_prometheus_alertmanager_memory_requests}}"
  180. {% endif %}
  181. {% if openshift_prometheus_alertmanager_cpu_requests is defined and openshift_prometheus_alertmanager_cpu_requests is not none %}
  182. cpu: "{{openshift_prometheus_alertmanager_cpu_requests}}"
  183. {% endif %}
  184. limits:
  185. {% if openshift_prometheus_alertmanager_memory_limit is defined and openshift_prometheus_alertmanager_memory_limit is not none %}
  186. memory: "{{openshift_prometheus_alertmanager_memory_limit}}"
  187. {% endif %}
  188. {% if openshift_prometheus_alertmanager_cpu_limit is defined and openshift_prometheus_alertmanager_cpu_limit is not none %}
  189. cpu: "{{openshift_prometheus_alertmanager_cpu_limit}}"
  190. {% endif %}
  191. ports:
  192. - containerPort: 9093
  193. name: web
  194. volumeMounts:
  195. - mountPath: /etc/alertmanager
  196. name: alertmanager-config
  197. - mountPath: /alertmanager
  198. name: alertmanager-data
  199. restartPolicy: Always
  200. volumes:
  201. - name: prometheus-config
  202. configMap:
  203. defaultMode: 420
  204. name: prometheus
  205. - name: prometheus-secrets
  206. secret:
  207. secretName: prometheus-proxy
  208. - name: prometheus-tls
  209. secret:
  210. secretName: prometheus-tls
  211. - name: prometheus-data
  212. {% if openshift_prometheus_storage_type == 'pvc' %}
  213. persistentVolumeClaim:
  214. claimName: {{ openshift_prometheus_pvc_name }}
  215. {% else %}
  216. emptydir: {}
  217. {% endif %}
  218. - name: alertmanager-config
  219. configMap:
  220. defaultMode: 420
  221. name: prometheus-alerts
  222. - name: alerts-secrets
  223. secret:
  224. secretName: alerts-proxy
  225. - name: alerts-tls
  226. secret:
  227. secretName: prometheus-alerts-tls
  228. - name: alertmanager-data
  229. {% if openshift_prometheus_alertmanager_storage_type == 'pvc' %}
  230. persistentVolumeClaim:
  231. claimName: {{ openshift_prometheus_alertmanager_pvc_name }}
  232. {% else %}
  233. emptydir: {}
  234. {% endif %}
  235. - name: alert-buffer-data
  236. {% if openshift_prometheus_alertbuffer_storage_type == 'pvc' %}
  237. persistentVolumeClaim:
  238. claimName: {{ openshift_prometheus_alertbuffer_pvc_name }}
  239. {% else %}
  240. emptydir: {}
  241. {% endif %}