vmselect-statefulset.yaml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. {{- $app := .Values.vmselect }}
  2. {{- if and $app.enabled $app.statefulSet.enabled -}}
  3. {{- $ctx := dict "helm" . "appKey" "vmselect" }}
  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.statefulSet.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. {{- $_ := unset $ctx "extraLabels" }}
  32. spec:
  33. {{- with $app.priorityClassName }}
  34. priorityClassName: {{ . }}
  35. {{- end }}
  36. {{- with $app.initContainers }}
  37. initContainers: {{ toYaml . | nindent 8 }}
  38. {{- end }}
  39. {{- with ($app.imagePullSecrets | default .Values.global.imagePullSecrets) }}
  40. imagePullSecrets: {{ toYaml . | nindent 8 }}
  41. {{- end }}
  42. containers:
  43. - name: vmselect
  44. image: {{ include "vm.image" (dict "helm" . "app" $app) }}
  45. imagePullPolicy: {{ $app.image.pullPolicy }}
  46. {{- with $app.containerWorkingDir }}
  47. workingDir: {{ . }}
  48. {{- end }}
  49. {{- if $app.securityContext.enabled }}
  50. securityContext: {{ include "vm.securityContext" (dict "securityContext" $app.securityContext "helm" .) | nindent 12 }}
  51. {{- end }}
  52. args: {{ include "vmselect.args" . | nindent 12 }}
  53. {{- with $app.envFrom }}
  54. envFrom: {{ toYaml . | nindent 12 }}
  55. {{- end }}
  56. {{- with $app.env }}
  57. env: {{ toYaml . | nindent 12 }}
  58. {{- end }}
  59. ports:
  60. - name: http
  61. containerPort: {{ include "vm.port.from.flag" (dict "flag" $app.extraArgs.httpListenAddr "default" "8481") }}
  62. {{- with $app.extraArgs.clusternativeListenAddr }}
  63. - name: cluster-tcp
  64. protocol: TCP
  65. containerPort: {{ include "vm.port.from.flag" (dict "flag" .) }}
  66. {{- end }}
  67. {{- with (fromYaml (include "vm.probe" (dict "app" $app "type" "readiness"))) }}
  68. readinessProbe: {{ toYaml . | nindent 12 }}
  69. {{- end }}
  70. {{- with (fromYaml (include "vm.probe" (dict "app" $app "type" "liveness"))) }}
  71. livenessProbe: {{ toYaml . | nindent 12 }}
  72. {{- end }}
  73. {{- with (fromYaml (include "vm.probe" (dict "app" $app "type" "startup"))) }}
  74. startupProbe: {{ toYaml . | nindent 12 }}
  75. {{- end }}
  76. volumeMounts:
  77. - mountPath: {{ $app.cacheMountPath }}
  78. name: cache-volume
  79. {{- range .Values.vmstorage.extraHostPathMounts }}
  80. - name: {{ .name }}
  81. mountPath: {{ .mountPath }}
  82. {{- with .subPath }}
  83. subPath: {{ . }}
  84. {{- end }}
  85. {{- with .readOnly }}
  86. readOnly: {{ . }}
  87. {{- end }}
  88. {{- end }}
  89. {{- with $app.extraVolumeMounts }}
  90. {{- toYaml . | nindent 12 }}
  91. {{- end }}
  92. {{- include "vm.license.mount" . | nindent 12 }}
  93. {{- with $app.resources }}
  94. resources: {{ toYaml . | nindent 12 }}
  95. {{- end }}
  96. {{- with $app.extraContainers }}
  97. {{- toYaml . | nindent 8 }}
  98. {{- end }}
  99. {{- with $app.nodeSelector }}
  100. nodeSelector: {{ toYaml . | nindent 8 }}
  101. {{- end }}
  102. {{- if $app.podSecurityContext.enabled }}
  103. securityContext: {{ include "vm.securityContext" (dict "securityContext" $app.podSecurityContext "helm" .) | nindent 8 }}
  104. {{- end }}
  105. {{- if or (.Values.serviceAccount).name (.Values.serviceAccount).create }}
  106. automountServiceAccountToken: {{ .Values.serviceAccount.automountToken }}
  107. serviceAccountName: {{ (.Values.serviceAccount).name | default $sa }}
  108. {{- end }}
  109. {{- with $app.tolerations }}
  110. tolerations: {{ toYaml . | nindent 8 }}
  111. {{- end }}
  112. {{- with $app.affinity }}
  113. affinity: {{ toYaml . | nindent 8 }}
  114. {{- end }}
  115. {{- with $app.topologySpreadConstraints }}
  116. topologySpreadConstraints: {{ toYaml . | nindent 8 }}
  117. {{- end }}
  118. volumes:
  119. {{- with $app.extraVolumes }}
  120. {{- toYaml . | nindent 8 }}
  121. {{- end }}
  122. {{- if or (not $app.persistentVolume.enabled) $app.persistentVolume.existingClaim }}
  123. - name: cache-volume
  124. {{- if $app.persistentVolume.enabled }}
  125. persistentVolumeClaim:
  126. claimName: {{ $app.persistentVolume.existingClaim }}
  127. {{- else }}
  128. emptyDir: {{ toYaml $app.emptyDir | nindent 12 }}
  129. {{- end }}
  130. {{- end }}
  131. {{- include "vm.license.volume" . | nindent 8 }}
  132. {{- if and $app.persistentVolume.enabled (not $app.persistentVolume.existingClaim) }}
  133. volumeClaimTemplates:
  134. - apiVersion: v1
  135. kind: PersistentVolumeClaim
  136. metadata:
  137. name: cache-volume
  138. {{- with $app.persistentVolume.annotations }}
  139. annotations: {{ toYaml . | nindent 10 }}
  140. {{- end }}
  141. {{- with .Values.vmstorage.persistentVolume.labels }}
  142. labels: {{ toYaml . | nindent 10 }}
  143. {{- end }}
  144. spec:
  145. {{- with $app.persistentVolume.accessModes }}
  146. accessModes: {{ toYaml . | nindent 10 }}
  147. {{- end }}
  148. resources:
  149. requests:
  150. storage: {{ $app.persistentVolume.size }}
  151. {{- with $app.persistentVolume.storageClassName }}
  152. storageClassName: {{ ternary "" . (eq "-" .) }}
  153. {{- end }}
  154. {{- end }}
  155. {{- end }}