vmselect-deployment.yaml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. {{- $app := .Values.vmselect -}}
  2. {{- if and $app.enabled (not $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: Deployment
  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. selector:
  20. matchLabels: {{ include "vm.selectorLabels" $ctx | nindent 6 }}
  21. {{- if not $app.horizontalPodAutoscaler.enabled }}
  22. replicas: {{ $app.replicaCount }}
  23. {{- end }}
  24. {{- with $app.strategy }}
  25. strategy: {{ toYaml . | nindent 4 }}
  26. {{- end }}
  27. template:
  28. metadata:
  29. {{- with $app.podAnnotations }}
  30. annotations: {{ toYaml . | nindent 8 }}
  31. {{- end }}
  32. {{- $_ := set $ctx "extraLabels" $app.podLabels }}
  33. labels: {{ include "vm.podLabels" $ctx | nindent 8 }}
  34. {{- $_ := unset $ctx "extraLabels" }}
  35. spec:
  36. {{- with $app.priorityClassName }}
  37. priorityClassName: {{ . }}
  38. {{- end }}
  39. {{- with $app.initContainers }}
  40. initContainers: {{ toYaml . | nindent 8 }}
  41. {{- end }}
  42. {{- with ($app.imagePullSecrets | default .Values.global.imagePullSecrets) }}
  43. imagePullSecrets: {{ toYaml . | nindent 8 }}
  44. {{- end }}
  45. containers:
  46. - name: vmselect
  47. image: {{ include "vm.image" (dict "helm" . "app" $app) }}
  48. imagePullPolicy: {{ $app.image.pullPolicy }}
  49. {{- with $app.containerWorkingDir }}
  50. workingDir: {{ . }}
  51. {{- end }}
  52. {{- if $app.securityContext.enabled }}
  53. securityContext: {{ include "vm.securityContext" (dict "securityContext" $app.securityContext "helm" .) | nindent 12 }}
  54. {{- end }}
  55. args: {{ include "vmselect.args" . | nindent 12 }}
  56. {{- with $app.envFrom }}
  57. envFrom: {{ toYaml . | nindent 12 }}
  58. {{- end }}
  59. {{- with $app.env }}
  60. env: {{ toYaml . | nindent 12 }}
  61. {{- end }}
  62. ports:
  63. - name: {{ $app.ports.name | default "http" }}
  64. containerPort: {{ include "vm.port.from.flag" (dict "flag" $app.extraArgs.httpListenAddr "default" "8481") }}
  65. {{- with $app.extraArgs.clusternativeListenAddr }}
  66. - name: cluster-tcp
  67. protocol: TCP
  68. containerPort: {{ include "vm.port.from.flag" (dict "flag" .) }}
  69. {{- end }}
  70. {{- with (fromYaml (include "vm.probe" (dict "app" $app "type" "readiness"))) }}
  71. readinessProbe: {{ toYaml . | nindent 12 }}
  72. {{- end }}
  73. {{- with (fromYaml (include "vm.probe" (dict "app" $app "type" "liveness"))) }}
  74. livenessProbe: {{ toYaml . | nindent 12 }}
  75. {{- end }}
  76. {{- with (fromYaml (include "vm.probe" (dict "app" $app "type" "startup"))) }}
  77. startupProbe: {{ toYaml . | nindent 12 }}
  78. {{- end }}
  79. volumeMounts:
  80. - mountPath: {{ $app.cacheMountPath }}
  81. name: cache-volume
  82. {{- range $app.extraHostPathMounts }}
  83. - name: {{ .name }}
  84. mountPath: {{ .mountPath }}
  85. {{- with .subPath }}
  86. subPath: {{ . }}
  87. {{- end }}
  88. {{- with .readOnly }}
  89. readOnly: {{ . }}
  90. {{- end }}
  91. {{- end }}
  92. {{- with $app.extraVolumeMounts }}
  93. {{- toYaml . | nindent 12 }}
  94. {{- end }}
  95. {{- include "vm.license.mount" . | nindent 12 }}
  96. {{- with $app.resources }}
  97. resources: {{ toYaml . | nindent 12 }}
  98. {{- end }}
  99. {{- with $app.extraContainers }}
  100. {{- toYaml . | nindent 8 }}
  101. {{- end }}
  102. {{- with $app.nodeSelector }}
  103. nodeSelector: {{ toYaml . | nindent 8 }}
  104. {{- end }}
  105. {{- if $app.podSecurityContext.enabled }}
  106. securityContext: {{ include "vm.securityContext" (dict "securityContext" $app.podSecurityContext "helm" .) | nindent 8 }}
  107. {{- end }}
  108. {{- if or (.Values.serviceAccount).name (.Values.serviceAccount).create }}
  109. automountServiceAccountToken: {{ .Values.serviceAccount.automountToken }}
  110. serviceAccountName: {{ (.Values.serviceAccount).name | default $sa }}
  111. {{- end }}
  112. {{- with $app.tolerations }}
  113. tolerations: {{ toYaml . | nindent 8 }}
  114. {{- end }}
  115. {{- with $app.affinity }}
  116. affinity: {{ toYaml . | nindent 8 }}
  117. {{- end }}
  118. {{- with $app.topologySpreadConstraints }}
  119. topologySpreadConstraints: {{ toYaml . | nindent 8 }}
  120. {{- end }}
  121. volumes:
  122. {{- with $app.extraVolumes }}
  123. {{- toYaml . | nindent 8 }}
  124. {{- end }}
  125. - name: cache-volume
  126. {{- if $app.persistentVolume.enabled }}
  127. persistentVolumeClaim:
  128. claimName: {{ $app.persistentVolume.existingClaim | default $fullname }}
  129. {{- else }}
  130. emptyDir: {{ toYaml $app.emptyDir | nindent 12 }}
  131. {{- end }}
  132. {{- include "vm.license.volume" . | nindent 8 }}
  133. {{- end }}