sts.yaml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. {{- if .Values.server.statefulSet.enabled -}}
  2. apiVersion: apps/v1
  3. kind: StatefulSet
  4. metadata:
  5. {{- if .Values.server.statefulSet.annotations }}
  6. annotations:
  7. {{ toYaml .Values.server.statefulSet.annotations | nindent 4 }}
  8. {{- end }}
  9. labels:
  10. {{- include "prometheus.server.labels" . | nindent 4 }}
  11. {{- if .Values.server.statefulSet.labels}}
  12. {{ toYaml .Values.server.statefulSet.labels | nindent 4 }}
  13. {{- end}}
  14. name: {{ template "prometheus.server.fullname" . }}
  15. {{ include "prometheus.namespace" . | indent 2 }}
  16. spec:
  17. serviceName: {{ template "prometheus.server.fullname" . }}-headless
  18. selector:
  19. matchLabels:
  20. {{- include "prometheus.server.matchLabels" . | nindent 6 }}
  21. replicas: {{ .Values.server.replicaCount }}
  22. podManagementPolicy: {{ .Values.server.statefulSet.podManagementPolicy }}
  23. template:
  24. metadata:
  25. {{- if .Values.server.podAnnotations }}
  26. annotations:
  27. {{ toYaml .Values.server.podAnnotations | nindent 8 }}
  28. {{- end }}
  29. labels:
  30. {{- include "prometheus.server.labels" . | nindent 8 }}
  31. {{- if .Values.server.podLabels}}
  32. {{ toYaml .Values.server.podLabels | nindent 8 }}
  33. {{- end}}
  34. spec:
  35. {{- if .Values.server.priorityClassName }}
  36. priorityClassName: "{{ .Values.server.priorityClassName }}"
  37. {{- end }}
  38. {{- if .Values.server.schedulerName }}
  39. schedulerName: "{{ .Values.server.schedulerName }}"
  40. {{- end }}
  41. {{- if semverCompare ">=1.13-0" .Capabilities.KubeVersion.GitVersion }}
  42. {{- if or (.Values.server.enableServiceLinks) (eq (.Values.server.enableServiceLinks | toString) "<nil>") }}
  43. enableServiceLinks: true
  44. {{- else }}
  45. enableServiceLinks: false
  46. {{- end }}
  47. {{- end }}
  48. serviceAccountName: {{ template "prometheus.serviceAccountName.server" . }}
  49. {{- if .Values.server.extraInitContainers }}
  50. initContainers:
  51. {{ toYaml .Values.server.extraInitContainers | indent 8 }}
  52. {{- end }}
  53. containers:
  54. {{- if .Values.configmapReload.prometheus.enabled }}
  55. - name: {{ template "prometheus.name" . }}-{{ .Values.server.name }}-{{ .Values.configmapReload.prometheus.name }}
  56. {{- if .Values.configmapReload.prometheus.image.digest }}
  57. image: "{{ .Values.configmapReload.prometheus.image.repository }}@{{ .Values.configmapReload.prometheus.image.digest }}"
  58. {{- else }}
  59. image: "{{ .Values.configmapReload.prometheus.image.repository }}:{{ .Values.configmapReload.prometheus.image.tag }}"
  60. {{- end }}
  61. imagePullPolicy: "{{ .Values.configmapReload.prometheus.image.pullPolicy }}"
  62. {{- with .Values.configmapReload.prometheus.containerSecurityContext }}
  63. securityContext:
  64. {{- toYaml . | nindent 12 }}
  65. {{- end }}
  66. args:
  67. - --watched-dir=/etc/config
  68. - --reload-url=http://127.0.0.1:9090{{ .Values.server.prefixURL }}/-/reload
  69. {{- range $key, $value := .Values.configmapReload.prometheus.extraArgs }}
  70. - --{{ $key }}={{ $value }}
  71. {{- end }}
  72. {{- range .Values.configmapReload.prometheus.extraVolumeDirs }}
  73. - --watched-dir={{ . }}
  74. {{- end }}
  75. {{- if .Values.configmapReload.prometheus.containerPort }}
  76. ports:
  77. - containerPort: {{ .Values.configmapReload.prometheus.containerPort }}
  78. {{- end }}
  79. resources:
  80. {{ toYaml .Values.configmapReload.prometheus.resources | indent 12 }}
  81. volumeMounts:
  82. - name: config-volume
  83. mountPath: /etc/config
  84. readOnly: true
  85. {{- range .Values.configmapReload.prometheus.extraConfigmapMounts }}
  86. - name: {{ $.Values.configmapReload.prometheus.name }}-{{ .name }}
  87. mountPath: {{ .mountPath }}
  88. subPath: {{ .subPath }}
  89. readOnly: {{ .readOnly }}
  90. {{- end }}
  91. {{- end }}
  92. - name: {{ template "prometheus.name" . }}-{{ .Values.server.name }}
  93. {{- if .Values.server.image.digest }}
  94. image: "{{ .Values.server.image.repository }}@{{ .Values.server.image.digest }}"
  95. {{- else }}
  96. image: "{{ .Values.server.image.repository }}:{{ .Values.server.image.tag | default .Chart.AppVersion }}"
  97. {{- end }}
  98. imagePullPolicy: "{{ .Values.server.image.pullPolicy }}"
  99. {{- if .Values.server.env }}
  100. env:
  101. {{ toYaml .Values.server.env | indent 12}}
  102. {{- end }}
  103. args:
  104. {{- if .Values.server.defaultFlagsOverride }}
  105. {{ toYaml .Values.server.defaultFlagsOverride | nindent 12}}
  106. {{- else }}
  107. {{- if .Values.server.prefixURL }}
  108. - --web.route-prefix={{ .Values.server.prefixURL }}
  109. {{- end }}
  110. {{- if .Values.server.retention }}
  111. - --storage.tsdb.retention.time={{ .Values.server.retention }}
  112. {{- end }}
  113. - --config.file={{ .Values.server.configPath }}
  114. {{- if .Values.server.storagePath }}
  115. - --storage.tsdb.path={{ .Values.server.storagePath }}
  116. {{- else }}
  117. - --storage.tsdb.path={{ .Values.server.persistentVolume.mountPath }}
  118. {{- end }}
  119. - --web.console.libraries=/etc/prometheus/console_libraries
  120. - --web.console.templates=/etc/prometheus/consoles
  121. {{- range .Values.server.extraFlags }}
  122. - --{{ . }}
  123. {{- end }}
  124. {{- range $key, $value := .Values.server.extraArgs }}
  125. - --{{ $key }}={{ $value }}
  126. {{- end }}
  127. {{- if .Values.server.baseURL }}
  128. - --web.external-url={{ .Values.server.baseURL }}
  129. {{- end }}
  130. {{- end }}
  131. ports:
  132. - containerPort: 9090
  133. {{- if .Values.server.hostPort }}
  134. hostPort: {{ .Values.server.hostPort }}
  135. {{- end }}
  136. readinessProbe:
  137. {{- if not .Values.server.tcpSocketProbeEnabled }}
  138. httpGet:
  139. path: {{ .Values.server.prefixURL }}/-/ready
  140. port: 9090
  141. scheme: {{ .Values.server.probeScheme }}
  142. {{- with .Values.server.probeHeaders }}
  143. httpHeaders:
  144. {{- toYaml . | nindent 14 }}
  145. {{- end }}
  146. {{- else }}
  147. tcpSocket:
  148. port: 9090
  149. {{- end }}
  150. initialDelaySeconds: {{ .Values.server.readinessProbeInitialDelay }}
  151. periodSeconds: {{ .Values.server.readinessProbePeriodSeconds }}
  152. timeoutSeconds: {{ .Values.server.readinessProbeTimeout }}
  153. failureThreshold: {{ .Values.server.readinessProbeFailureThreshold }}
  154. successThreshold: {{ .Values.server.readinessProbeSuccessThreshold }}
  155. livenessProbe:
  156. {{- if not .Values.server.tcpSocketProbeEnabled }}
  157. httpGet:
  158. path: {{ .Values.server.prefixURL }}/-/healthy
  159. port: 9090
  160. scheme: {{ .Values.server.probeScheme }}
  161. {{- with .Values.server.probeHeaders }}
  162. httpHeaders:
  163. {{- toYaml . | nindent 14 }}
  164. {{- end }}
  165. {{- else }}
  166. tcpSocket:
  167. port: 9090
  168. {{- end }}
  169. initialDelaySeconds: {{ .Values.server.livenessProbeInitialDelay }}
  170. periodSeconds: {{ .Values.server.livenessProbePeriodSeconds }}
  171. timeoutSeconds: {{ .Values.server.livenessProbeTimeout }}
  172. failureThreshold: {{ .Values.server.livenessProbeFailureThreshold }}
  173. successThreshold: {{ .Values.server.livenessProbeSuccessThreshold }}
  174. {{- if .Values.server.startupProbe.enabled }}
  175. startupProbe:
  176. {{- if not .Values.server.tcpSocketProbeEnabled }}
  177. httpGet:
  178. path: {{ .Values.server.prefixURL }}/-/healthy
  179. port: 9090
  180. scheme: {{ .Values.server.probeScheme }}
  181. {{- if .Values.server.probeHeaders }}
  182. httpHeaders:
  183. {{- range .Values.server.probeHeaders}}
  184. - name: {{ .name }}
  185. value: {{ .value }}
  186. {{- end }}
  187. {{- end }}
  188. {{- else }}
  189. tcpSocket:
  190. port: 9090
  191. {{- end }}
  192. failureThreshold: {{ .Values.server.startupProbe.failureThreshold }}
  193. periodSeconds: {{ .Values.server.startupProbe.periodSeconds }}
  194. timeoutSeconds: {{ .Values.server.startupProbe.timeoutSeconds }}
  195. {{- end }}
  196. resources:
  197. {{ toYaml .Values.server.resources | indent 12 }}
  198. volumeMounts:
  199. - name: config-volume
  200. mountPath: /etc/config
  201. - name: storage-volume
  202. mountPath: {{ .Values.server.persistentVolume.mountPath }}
  203. subPath: "{{ .Values.server.persistentVolume.subPath }}"
  204. {{- range .Values.server.extraHostPathMounts }}
  205. - name: {{ .name }}
  206. mountPath: {{ .mountPath }}
  207. subPath: {{ .subPath }}
  208. readOnly: {{ .readOnly }}
  209. {{- end }}
  210. {{- range .Values.server.extraConfigmapMounts }}
  211. - name: {{ $.Values.server.name }}-{{ .name }}
  212. mountPath: {{ .mountPath }}
  213. subPath: {{ .subPath }}
  214. readOnly: {{ .readOnly }}
  215. {{- end }}
  216. {{- range .Values.server.extraSecretMounts }}
  217. - name: {{ .name }}
  218. mountPath: {{ .mountPath }}
  219. subPath: {{ .subPath }}
  220. readOnly: {{ .readOnly }}
  221. {{- end }}
  222. {{- if .Values.server.extraVolumeMounts }}
  223. {{ toYaml .Values.server.extraVolumeMounts | nindent 12 }}
  224. {{- end }}
  225. {{- with .Values.server.containerSecurityContext }}
  226. securityContext:
  227. {{- toYaml . | nindent 12 }}
  228. {{- end }}
  229. {{- if .Values.server.sidecarContainers }}
  230. {{- range $name, $spec := .Values.server.sidecarContainers }}
  231. - name: {{ $name }}
  232. {{- if kindIs "string" $spec }}
  233. {{- tpl $spec $ | nindent 10 }}
  234. {{- else }}
  235. {{- toYaml $spec | nindent 10 }}
  236. {{- end }}
  237. {{- end }}
  238. {{- end }}
  239. hostNetwork: {{ .Values.server.hostNetwork }}
  240. {{- if .Values.server.dnsPolicy }}
  241. dnsPolicy: {{ .Values.server.dnsPolicy }}
  242. {{- end }}
  243. {{- if .Values.imagePullSecrets }}
  244. imagePullSecrets:
  245. {{ toYaml .Values.imagePullSecrets | indent 8 }}
  246. {{- end }}
  247. {{- if .Values.server.nodeSelector }}
  248. nodeSelector:
  249. {{ toYaml .Values.server.nodeSelector | indent 8 }}
  250. {{- end }}
  251. {{- if .Values.server.hostAliases }}
  252. hostAliases:
  253. {{ toYaml .Values.server.hostAliases | indent 8 }}
  254. {{- end }}
  255. {{- if .Values.server.dnsConfig }}
  256. dnsConfig:
  257. {{ toYaml .Values.server.dnsConfig | indent 8 }}
  258. {{- end }}
  259. {{- with .Values.server.securityContext }}
  260. securityContext:
  261. {{- toYaml . | nindent 8 }}
  262. {{- end }}
  263. {{- if .Values.server.tolerations }}
  264. tolerations:
  265. {{ toYaml .Values.server.tolerations | indent 8 }}
  266. {{- end }}
  267. {{- if .Values.server.affinity }}
  268. affinity:
  269. {{ toYaml .Values.server.affinity | indent 8 }}
  270. {{- end }}
  271. terminationGracePeriodSeconds: {{ .Values.server.terminationGracePeriodSeconds }}
  272. volumes:
  273. - name: config-volume
  274. {{- if empty .Values.server.configFromSecret }}
  275. configMap:
  276. name: {{ if .Values.server.configMapOverrideName }}{{ .Release.Name }}-{{ .Values.server.configMapOverrideName }}{{- else }}{{ template "prometheus.server.fullname" . }}{{- end }}
  277. {{- else }}
  278. secret:
  279. secretName: {{ .Values.server.configFromSecret }}
  280. {{- end }}
  281. {{- range .Values.server.extraHostPathMounts }}
  282. - name: {{ .name }}
  283. hostPath:
  284. path: {{ .hostPath }}
  285. {{- end }}
  286. {{- range .Values.configmapReload.prometheus.extraConfigmapMounts }}
  287. - name: {{ $.Values.configmapReload.prometheus.name }}-{{ .name }}
  288. configMap:
  289. name: {{ .configMap }}
  290. {{- end }}
  291. {{- range .Values.server.extraConfigmapMounts }}
  292. - name: {{ $.Values.server.name }}-{{ .name }}
  293. configMap:
  294. name: {{ .configMap }}
  295. {{- end }}
  296. {{- range .Values.server.extraSecretMounts }}
  297. - name: {{ .name }}
  298. secret:
  299. secretName: {{ .secretName }}
  300. {{- with .optional }}
  301. optional: {{ . }}
  302. {{- end }}
  303. {{- end }}
  304. {{- range .Values.configmapReload.prometheus.extraConfigmapMounts }}
  305. - name: {{ .name }}
  306. configMap:
  307. name: {{ .configMap }}
  308. {{- with .optional }}
  309. optional: {{ . }}
  310. {{- end }}
  311. {{- end }}
  312. {{- if .Values.server.extraVolumes }}
  313. {{ toYaml .Values.server.extraVolumes | indent 8}}
  314. {{- end }}
  315. {{- if .Values.server.persistentVolume.enabled }}
  316. volumeClaimTemplates:
  317. - metadata:
  318. name: storage-volume
  319. {{- if .Values.server.persistentVolume.annotations }}
  320. annotations:
  321. {{ toYaml .Values.server.persistentVolume.annotations | indent 10 }}
  322. {{- end }}
  323. {{- if .Values.server.persistentVolume.labels }}
  324. labels:
  325. {{ toYaml .Values.server.persistentVolume.labels | indent 10 }}
  326. {{- end }}
  327. spec:
  328. accessModes:
  329. {{ toYaml .Values.server.persistentVolume.accessModes | indent 10 }}
  330. resources:
  331. requests:
  332. storage: "{{ .Values.server.persistentVolume.size }}"
  333. {{- if .Values.server.persistentVolume.storageClass }}
  334. {{- if (eq "-" .Values.server.persistentVolume.storageClass) }}
  335. storageClassName: ""
  336. {{- else }}
  337. storageClassName: "{{ .Values.server.persistentVolume.storageClass }}"
  338. {{- end }}
  339. {{- end }}
  340. {{- else }}
  341. - name: storage-volume
  342. emptyDir:
  343. {{- if .Values.server.emptyDir.sizeLimit }}
  344. sizeLimit: {{ .Values.server.emptyDir.sizeLimit }}
  345. {{- else }}
  346. {}
  347. {{- end -}}
  348. {{- end }}
  349. {{- end }}