2
0

deploy.yaml 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. {{- if and .Values.alertmanager.enabled (not .Values.alertmanager.statefulSet.enabled) -}}
  2. apiVersion: {{ template "prometheus.deployment.apiVersion" . }}
  3. kind: Deployment
  4. metadata:
  5. {{- if .Values.alertmanager.deploymentAnnotations }}
  6. annotations:
  7. {{ toYaml .Values.alertmanager.deploymentAnnotations | nindent 4 }}
  8. {{- end }}
  9. labels:
  10. {{- include "prometheus.alertmanager.labels" . | nindent 4 }}
  11. name: {{ template "prometheus.alertmanager.fullname" . }}
  12. {{ include "prometheus.namespace" . | indent 2 }}
  13. spec:
  14. selector:
  15. matchLabels:
  16. {{- include "prometheus.alertmanager.matchLabels" . | nindent 6 }}
  17. replicas: {{ .Values.alertmanager.replicaCount }}
  18. {{- if .Values.alertmanager.strategy }}
  19. strategy:
  20. {{ toYaml .Values.alertmanager.strategy | trim | indent 4 }}
  21. {{ if eq .Values.alertmanager.strategy.type "Recreate" }}rollingUpdate: null{{ end }}
  22. {{- end }}
  23. template:
  24. metadata:
  25. {{- if .Values.alertmanager.podAnnotations }}
  26. annotations:
  27. {{ toYaml .Values.alertmanager.podAnnotations | nindent 8 }}
  28. {{- end }}
  29. labels:
  30. {{- include "prometheus.alertmanager.labels" . | nindent 8 }}
  31. {{- if .Values.alertmanager.podLabels}}
  32. {{ toYaml .Values.alertmanager.podLabels | nindent 8 }}
  33. {{- end}}
  34. spec:
  35. {{- if .Values.alertmanager.schedulerName }}
  36. schedulerName: "{{ .Values.alertmanager.schedulerName }}"
  37. {{- end }}
  38. serviceAccountName: {{ template "prometheus.serviceAccountName.alertmanager" . }}
  39. {{- if .Values.alertmanager.extraInitContainers }}
  40. initContainers:
  41. {{ toYaml .Values.alertmanager.extraInitContainers | indent 8 }}
  42. {{- end }}
  43. {{- if .Values.alertmanager.priorityClassName }}
  44. priorityClassName: "{{ .Values.alertmanager.priorityClassName }}"
  45. {{- end }}
  46. containers:
  47. - name: {{ template "prometheus.name" . }}-{{ .Values.alertmanager.name }}
  48. image: "{{ .Values.alertmanager.image.repository }}:{{ .Values.alertmanager.image.tag }}"
  49. imagePullPolicy: "{{ .Values.alertmanager.image.pullPolicy }}"
  50. env:
  51. {{- range $key, $value := .Values.alertmanager.extraEnv }}
  52. - name: {{ $key }}
  53. value: {{ $value }}
  54. {{- end }}
  55. - name: POD_IP
  56. valueFrom:
  57. fieldRef:
  58. apiVersion: v1
  59. fieldPath: status.podIP
  60. args:
  61. - --config.file=/etc/config/{{ .Values.alertmanager.configFileName }}
  62. - --storage.path={{ .Values.alertmanager.persistentVolume.mountPath }}
  63. {{- if .Values.alertmanager.service.enableMeshPeer }}
  64. - --cluster.listen-address=0.0.0.0:6783
  65. - --cluster.advertise-address=[$(POD_IP)]:6783
  66. {{- else }}
  67. - --cluster.listen-address=
  68. {{- end }}
  69. {{- range $key, $value := .Values.alertmanager.extraArgs }}
  70. - --{{ $key }}={{ $value }}
  71. {{- end }}
  72. {{- if .Values.alertmanager.baseURL }}
  73. - --web.external-url={{ .Values.alertmanager.baseURL }}
  74. {{- end }}
  75. {{- range .Values.alertmanager.clusterPeers }}
  76. - --cluster.peer={{ . }}
  77. {{- end }}
  78. ports:
  79. - containerPort: 9093
  80. readinessProbe:
  81. httpGet:
  82. path: {{ .Values.alertmanager.prefixURL }}/-/ready
  83. port: 9093
  84. {{- if .Values.alertmanager.probeHeaders }}
  85. httpHeaders:
  86. {{- range .Values.alertmanager.probeHeaders }}
  87. - name: {{ .name }}
  88. value: {{ .value }}
  89. {{- end }}
  90. {{- end }}
  91. initialDelaySeconds: 30
  92. timeoutSeconds: 30
  93. resources:
  94. {{ toYaml .Values.alertmanager.resources | indent 12 }}
  95. volumeMounts:
  96. - name: config-volume
  97. mountPath: /etc/config
  98. - name: storage-volume
  99. mountPath: "{{ .Values.alertmanager.persistentVolume.mountPath }}"
  100. subPath: "{{ .Values.alertmanager.persistentVolume.subPath }}"
  101. {{- range .Values.alertmanager.extraSecretMounts }}
  102. - name: {{ .name }}
  103. mountPath: {{ .mountPath }}
  104. subPath: {{ .subPath }}
  105. readOnly: {{ .readOnly }}
  106. {{- end }}
  107. {{- range .Values.alertmanager.extraConfigmapMounts }}
  108. - name: {{ .name }}
  109. mountPath: {{ .mountPath }}
  110. subPath: {{ .subPath }}
  111. readOnly: {{ .readOnly }}
  112. {{- end }}
  113. {{- if .Values.configmapReload.alertmanager.enabled }}
  114. - name: {{ template "prometheus.name" . }}-{{ .Values.alertmanager.name }}-{{ .Values.configmapReload.alertmanager.name }}
  115. image: "{{ .Values.configmapReload.alertmanager.image.repository }}:{{ .Values.configmapReload.alertmanager.image.tag }}"
  116. imagePullPolicy: "{{ .Values.configmapReload.alertmanager.image.pullPolicy }}"
  117. args:
  118. - --volume-dir=/etc/config
  119. - --webhook-url=http://127.0.0.1:9093{{ .Values.alertmanager.prefixURL }}/-/reload
  120. {{- range $key, $value := .Values.configmapReload.alertmanager.extraArgs }}
  121. - --{{ $key }}={{ $value }}
  122. {{- end }}
  123. {{- range .Values.configmapReload.alertmanager.extraVolumeDirs }}
  124. - --volume-dir={{ . }}
  125. {{- end }}
  126. resources:
  127. {{ toYaml .Values.configmapReload.alertmanager.resources | indent 12 }}
  128. volumeMounts:
  129. - name: config-volume
  130. mountPath: /etc/config
  131. readOnly: true
  132. {{- range .Values.configmapReload.alertmanager.extraConfigmapMounts }}
  133. - name: {{ $.Values.configmapReload.alertmanager.name }}-{{ .name }}
  134. mountPath: {{ .mountPath }}
  135. subPath: {{ .subPath }}
  136. readOnly: {{ .readOnly }}
  137. {{- end }}
  138. {{- end }}
  139. {{- if .Values.imagePullSecrets }}
  140. imagePullSecrets:
  141. {{ toYaml .Values.imagePullSecrets | indent 8 }}
  142. {{- end }}
  143. {{- if .Values.alertmanager.nodeSelector }}
  144. nodeSelector:
  145. {{ toYaml .Values.alertmanager.nodeSelector | indent 8 }}
  146. {{- end }}
  147. {{- with .Values.alertmanager.dnsConfig }}
  148. dnsConfig:
  149. {{ toYaml . | indent 8 }}
  150. {{- end }}
  151. {{- if .Values.alertmanager.securityContext }}
  152. securityContext:
  153. {{ toYaml .Values.alertmanager.securityContext | indent 8 }}
  154. {{- end }}
  155. {{- if .Values.alertmanager.tolerations }}
  156. tolerations:
  157. {{ toYaml .Values.alertmanager.tolerations | indent 8 }}
  158. {{- end }}
  159. {{- if .Values.alertmanager.affinity }}
  160. affinity:
  161. {{ toYaml .Values.alertmanager.affinity | indent 8 }}
  162. {{- end }}
  163. volumes:
  164. - name: config-volume
  165. {{- if empty .Values.alertmanager.configFromSecret }}
  166. configMap:
  167. name: {{ if .Values.alertmanager.configMapOverrideName }}{{ .Release.Name }}-{{ .Values.alertmanager.configMapOverrideName }}{{- else }}{{ template "prometheus.alertmanager.fullname" . }}{{- end }}
  168. {{- else }}
  169. secret:
  170. secretName: {{ .Values.alertmanager.configFromSecret }}
  171. {{- end }}
  172. {{- range .Values.alertmanager.extraSecretMounts }}
  173. - name: {{ .name }}
  174. secret:
  175. secretName: {{ .secretName }}
  176. {{- with .optional }}
  177. optional: {{ . }}
  178. {{- end }}
  179. {{- end }}
  180. {{- range .Values.alertmanager.extraConfigmapMounts }}
  181. - name: {{ .name }}
  182. configMap:
  183. name: {{ .configMap }}
  184. {{- end }}
  185. {{- range .Values.configmapReload.alertmanager.extraConfigmapMounts }}
  186. - name: {{ $.Values.configmapReload.alertmanager.name }}-{{ .name }}
  187. configMap:
  188. name: {{ .configMap }}
  189. {{- end }}
  190. - name: storage-volume
  191. {{- if .Values.alertmanager.persistentVolume.enabled }}
  192. persistentVolumeClaim:
  193. claimName: {{ if .Values.alertmanager.persistentVolume.existingClaim }}{{ .Values.alertmanager.persistentVolume.existingClaim }}{{- else }}{{ template "prometheus.alertmanager.fullname" . }}{{- end }}
  194. {{- else }}
  195. emptyDir:
  196. {{- if .Values.alertmanager.emptyDir.sizeLimit }}
  197. sizeLimit: {{ .Values.alertmanager.emptyDir.sizeLimit }}
  198. {{- else }}
  199. {}
  200. {{- end -}}
  201. {{- end -}}
  202. {{- end }}