vmstorage-statefulset.yaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. {{- $app := .Values.vmstorage }}
  2. {{- if $app.enabled -}}
  3. {{- $ctx := dict "helm" . "appKey" "vmstorage" }}
  4. {{- $fullname := include "vm.plain.fullname" $ctx }}
  5. {{- $sa := include "vm.fullname" $ctx }}
  6. {{- $ns := include "vm.namespace" $ctx }}
  7. apiVersion: apps/v1
  8. kind: StatefulSet
  9. metadata:
  10. {{- with $app.annotations }}
  11. annotations: {{ toYaml . | nindent 4 }}
  12. {{- end }}
  13. {{- $_ := set $ctx "extraLabels" $app.extraLabels }}
  14. labels: {{ include "vm.labels" $ctx | nindent 4 }}
  15. {{- $_ := unset $ctx "extraLabels" }}
  16. name: {{ $fullname }}
  17. namespace: {{ $ns }}
  18. spec:
  19. serviceName: {{ $fullname }}
  20. selector:
  21. matchLabels: {{ include "vm.selectorLabels" $ctx | nindent 6 }}
  22. replicas: {{ $app.replicaCount }}
  23. podManagementPolicy: {{ $app.podManagementPolicy }}
  24. template:
  25. metadata:
  26. {{- with $app.podAnnotations }}
  27. annotations: {{ toYaml . | nindent 8 }}
  28. {{- end }}
  29. {{- $_ := set $ctx "extraLabels" $app.podLabels }}
  30. labels: {{ include "vm.podLabels" $ctx | nindent 8 }}
  31. spec:
  32. {{- with $app.priorityClassName }}
  33. priorityClassName: {{ . }}
  34. {{- end }}
  35. {{- with $app.schedulerName }}
  36. schedulerName: {{ . }}
  37. {{- end }}
  38. {{- $manager := $app.vmbackupmanager }}
  39. {{- if or $app.initContainers $manager.restore.onStart.enabled }}
  40. initContainers:
  41. {{- with $app.initContainers -}}
  42. {{- toYaml . | nindent 8 }}
  43. {{- end -}}
  44. {{- if $manager.restore.onStart.enabled }}
  45. {{- include "vm.enterprise.only" . }}
  46. - name: vmbackupmanager-restore
  47. image: {{ include "vm.image" (dict "helm" . "app" $manager) }}
  48. imagePullPolicy: {{ $app.image.pullPolicy }}
  49. {{- if $app.securityContext.enabled }}
  50. securityContext: {{ include "vm.securityContext" (dict "securityContext" $app.securityContext "helm" .) | nindent 12 }}
  51. {{- end }}
  52. args: {{ include "vmbackupmanager.restore.args" . | nindent 12 }}
  53. {{- with $manager.resources }}
  54. resources: {{ toYaml . | nindent 12 }}
  55. {{- end }}
  56. env:
  57. - name: POD_NAME
  58. valueFrom:
  59. fieldRef:
  60. fieldPath: metadata.name
  61. {{- with $manager.env }}
  62. {{- toYaml . | nindent 12 }}
  63. {{- end }}
  64. ports:
  65. - name: manager-http
  66. containerPort: 8300
  67. volumeMounts:
  68. - name: vmstorage-volume
  69. mountPath: {{ $app.persistentVolume.mountPath }}
  70. subPath: {{ $app.persistentVolume.subPath }}
  71. {{- range $manager.extraSecretMounts }}
  72. - name: {{ .name }}
  73. mountPath: {{ .mountPath }}
  74. subPath: {{ .subPath }}
  75. {{- end }}
  76. {{- end }}
  77. {{- end }}
  78. {{- with ($app.imagePullSecrets | default .Values.global.imagePullSecrets) }}
  79. imagePullSecrets: {{ toYaml . | nindent 8 }}
  80. {{- end }}
  81. containers:
  82. - name: vmstorage
  83. image: {{ include "vm.image" (dict "helm" . "app" $app) }}
  84. imagePullPolicy: {{ $app.image.pullPolicy }}
  85. {{- with $app.containerWorkingDir }}
  86. workingDir: {{ . }}
  87. {{- end }}
  88. {{- if $app.securityContext.enabled }}
  89. securityContext: {{ include "vm.securityContext" (dict "securityContext" $app.securityContext "helm" .) | nindent 12 }}
  90. {{- end }}
  91. args: {{ include "vmstorage.args" . | nindent 12 }}
  92. ports:
  93. - name: {{ $app.ports.name | default "http" }}
  94. containerPort: {{ include "vm.port.from.flag" (dict "flag" $app.extraArgs.httpListenAddr "default" "8482") }}
  95. - name: vminsert
  96. containerPort: 8400
  97. - name: vmselect
  98. containerPort: 8401
  99. {{- with $app.envFrom }}
  100. envFrom: {{ toYaml . | nindent 12 }}
  101. {{- end }}
  102. {{- with $app.env }}
  103. env: {{ toYaml . | nindent 12 }}
  104. {{- end }}
  105. {{- with (fromYaml (include "vm.probe" (dict "app" $app "type" "readiness"))) }}
  106. readinessProbe: {{ toYaml . | nindent 12 }}
  107. {{- end }}
  108. {{- with (fromYaml (include "vm.probe" (dict "app" $app "type" "liveness"))) }}
  109. livenessProbe: {{ toYaml . | nindent 12 }}
  110. {{- end }}
  111. {{- with (fromYaml (include "vm.probe" (dict "app" $app "type" "startup"))) }}
  112. startupProbe: {{ toYaml . | nindent 12 }}
  113. {{- end }}
  114. {{- with $app.resources }}
  115. resources: {{ toYaml . | nindent 12 }}
  116. {{- end }}
  117. volumeMounts:
  118. {{- with $app.persistentVolume }}
  119. - name: {{ .name }}
  120. mountPath: {{ .mountPath }}
  121. {{- with .subPath }}
  122. subPath: {{ . }}
  123. {{- end }}
  124. {{- end }}
  125. {{- range $app.extraHostPathMounts }}
  126. - name: {{ .name }}
  127. mountPath: {{ .mountPath }}
  128. {{- with .subPath }}
  129. subPath: {{ . }}
  130. {{- end }}
  131. {{- with .readOnly }}
  132. readOnly: {{ . }}
  133. {{- end }}
  134. {{- end }}
  135. {{- range $app.extraConfigmapMounts }}
  136. - name: {{ $app.name }}-{{ .name }}
  137. mountPath: {{ .mountPath }}
  138. {{- with .subPath }}
  139. subPath: {{ . }}
  140. {{- end }}
  141. {{- with .readOnly }}
  142. readOnly: {{ . }}
  143. {{- end }}
  144. {{- end }}
  145. {{- range $app.extraSecretMounts }}
  146. - name: {{ .name }}
  147. mountPath: {{ .mountPath }}
  148. {{- with .subPath }}
  149. subPath: {{ . }}
  150. {{- end }}
  151. {{- with .readOnly }}
  152. readOnly: {{ . }}
  153. {{- end }}
  154. {{- end }}
  155. {{- with $app.extraVolumeMounts }}
  156. {{- toYaml . | nindent 12 }}
  157. {{- end }}
  158. {{- include "vm.license.mount" . | nindent 12 }}
  159. {{- if $manager.enabled }}
  160. {{- include "vm.enterprise.only" . }}
  161. - name: vmbackupmanager
  162. image: {{ include "vm.image" (dict "helm" . "app" $manager) }}
  163. imagePullPolicy: {{ $app.image.pullPolicy }}
  164. {{- if $app.securityContext.enabled }}
  165. securityContext: {{ include "vm.securityContext" (dict "securityContext" $app.securityContext "helm" .) | nindent 12 }}
  166. {{- end }}
  167. args: {{ include "vmbackupmanager.args" . | nindent 12 }}
  168. {{- with $manager.resources }}
  169. resources: {{ toYaml . | nindent 12 }}
  170. {{- end }}
  171. {{- with (fromYaml (include "vm.probe" (dict "app" $manager "type" "readiness"))) }}
  172. readinessProbe: {{ toYaml . | nindent 12 }}
  173. {{- end }}
  174. {{- with (fromYaml (include "vm.probe" (dict "app" $manager "type" "liveness"))) }}
  175. livenessProbe: {{ toYaml . | nindent 12 }}
  176. {{- end }}
  177. {{- with (fromYaml (include "vm.probe" (dict "app" $manager "type" "startup"))) }}
  178. startupProbe: {{ toYaml . | nindent 12 }}
  179. {{- end }}
  180. env:
  181. - name: POD_NAME
  182. valueFrom:
  183. fieldRef:
  184. fieldPath: metadata.name
  185. {{- with $manager.env }}
  186. {{- toYaml . | nindent 12 }}
  187. {{- end }}
  188. ports:
  189. - name: manager-http
  190. containerPort: 8300
  191. volumeMounts:
  192. {{- with $app.persistentVolume }}
  193. - name: {{ .name }}
  194. mountPath: {{ .mountPath }}
  195. {{- with .subPath }}
  196. subPath: {{ . }}
  197. {{- end }}
  198. {{- end }}
  199. {{- range $manager.extraSecretMounts }}
  200. - name: {{ .name }}
  201. mountPath: {{ .mountPath }}
  202. {{- with .subPath }}
  203. subPath: {{ . }}
  204. {{- end }}
  205. {{- with .readOnly }}
  206. readOnly: {{ . }}
  207. {{- end }}
  208. {{- end }}
  209. {{- include "vm.license.mount" . | nindent 12 }}
  210. {{- end }}
  211. {{- with $app.extraContainers }}
  212. {{- toYaml . | nindent 8 }}
  213. {{- end }}
  214. {{- with $app.nodeSelector }}
  215. nodeSelector: {{ toYaml . | nindent 8 }}
  216. {{- end }}
  217. {{- if $app.podSecurityContext.enabled }}
  218. securityContext: {{ include "vm.securityContext" (dict "securityContext" $app.podSecurityContext "helm" .) | nindent 8 }}
  219. {{- end }}
  220. {{- if or (.Values.serviceAccount).name (.Values.serviceAccount).create }}
  221. automountServiceAccountToken: {{ .Values.serviceAccount.automountToken }}
  222. serviceAccountName: {{ (.Values.serviceAccount).name | default $sa }}
  223. {{- end }}
  224. {{- with $app.tolerations }}
  225. tolerations: {{ toYaml . | nindent 8 }}
  226. {{- end }}
  227. {{- with $app.affinity }}
  228. affinity: {{ toYaml . | nindent 8 }}
  229. {{- end }}
  230. {{- with $app.topologySpreadConstraints }}
  231. topologySpreadConstraints: {{ toYaml . | nindent 8 }}
  232. {{- end }}
  233. terminationGracePeriodSeconds: {{ $app.terminationGracePeriodSeconds }}
  234. {{- if or $app.extraVolumes (not $app.persistentVolume.enabled) $app.persistentVolume.existingClaim (include "vm.license.volume" .) }}
  235. volumes:
  236. {{- with $app.extraVolumes }}
  237. {{- toYaml . | nindent 8 }}
  238. {{- end }}
  239. {{- if or (not $app.persistentVolume.enabled) $app.persistentVolume.existingClaim }}
  240. - name: vmstorage-volume
  241. {{- if $app.persistentVolume.enabled }}
  242. persistentVolumeClaim:
  243. claimName: {{ $app.persistentVolume.existingClaim }}
  244. {{- else }}
  245. emptyDir: {{ toYaml $app.emptyDir | nindent 12 }}
  246. {{- end }}
  247. {{- end }}
  248. {{- include "vm.license.volume" . | nindent 8 }}
  249. {{- end }}
  250. {{- if and $app.persistentVolume.enabled (not $app.persistentVolume.existingClaim) }}
  251. volumeClaimTemplates:
  252. - apiVersion: v1
  253. kind: PersistentVolumeClaim
  254. metadata:
  255. name: {{ $app.persistentVolume.name }}
  256. {{- with $app.persistentVolume.annotations }}
  257. annotations: {{ toYaml . | nindent 10 }}
  258. {{- end }}
  259. {{- with $app.persistentVolume.labels }}
  260. labels: {{ toYaml . | nindent 10 }}
  261. {{- end }}
  262. spec:
  263. {{- with $app.persistentVolume.accessModes }}
  264. accessModes: {{ toYaml . | nindent 10 }}
  265. {{- end }}
  266. resources:
  267. requests:
  268. storage: {{ $app.persistentVolume.size }}
  269. {{- with $app.persistentVolume.storageClassName }}
  270. storageClassName: {{ ternary "" . (eq "-" .) }}
  271. {{- end }}
  272. {{- end }}
  273. {{- end }}