Nessuna descrizione

shuffle-worker-dpl.yaml 9.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. {{- if .Values.worker.enableHelmDeployment }}
  2. apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
  3. kind: Deployment
  4. metadata:
  5. name: {{ template "shuffle.worker.name" . }}
  6. namespace: {{ include "common.names.namespace" . | quote }}
  7. labels: {{- include "shuffle.workerInstance.labels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
  8. {{- if or .Values.worker.deploymentAnnotations .Values.commonAnnotations }}
  9. {{- $annotations := include "common.tplvalues.merge" (dict "values" (list .Values.worker.deploymentAnnotations .Values.commonAnnotations) "context" .) }}
  10. annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 4 }}
  11. {{- end }}
  12. spec:
  13. {{- if not .Values.worker.autoscaling.hpa.enabled }}
  14. replicas: {{ .Values.worker.replicaCount }}
  15. {{- end }}
  16. {{- if .Values.worker.updateStrategy }}
  17. strategy: {{- toYaml .Values.worker.updateStrategy | nindent 4 }}
  18. {{- end }}
  19. {{- $podLabels := include "common.tplvalues.merge" (dict "values" (list .Values.worker.podLabels .Values.commonLabels) "context" .) }}
  20. selector:
  21. matchLabels: {{- include "shuffle.workerInstance.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
  22. template:
  23. metadata:
  24. {{- if .Values.worker.podAnnotations }}
  25. annotations: {{- include "common.tplvalues.render" (dict "value" .Values.worker.podAnnotations "context" $) | nindent 8 }}
  26. {{- end }}
  27. labels: {{- include "shuffle.workerInstance.labels" ( dict "customLabels" $podLabels "context" $ ) | nindent 8 }}
  28. spec:
  29. {{- include "shuffle.worker.imagePullSecrets" . | nindent 6 }}
  30. serviceAccountName: {{ template "shuffle.worker.serviceAccount.name" . }}
  31. automountServiceAccountToken: {{ .Values.worker.automountServiceAccountToken }}
  32. {{- if .Values.worker.hostAliases }}
  33. hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.worker.hostAliases "context" $) | nindent 8 }}
  34. {{- end }}
  35. {{- if .Values.worker.affinity }}
  36. affinity: {{- include "common.tplvalues.render" ( dict "value" .Values.worker.affinity "context" $) | nindent 8 }}
  37. {{- else }}
  38. affinity:
  39. podAffinity: {{- include "shuffle.workerInstance.affinities.pods" (dict "type" .Values.worker.podAffinityPreset "customLabels" $podLabels "context" $) | nindent 10 }}
  40. podAntiAffinity: {{- include "shuffle.workerInstance.affinities.pods" (dict "type" .Values.worker.podAntiAffinityPreset "customLabels" $podLabels "context" $) | nindent 10 }}
  41. nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.worker.nodeAffinityPreset.type "key" .Values.worker.nodeAffinityPreset.key "values" .Values.worker.nodeAffinityPreset.values) | nindent 10 }}
  42. {{- end }}
  43. {{- if .Values.worker.nodeSelector }}
  44. nodeSelector: {{- include "common.tplvalues.render" ( dict "value" .Values.worker.nodeSelector "context" $) | nindent 8 }}
  45. {{- end }}
  46. {{- if .Values.worker.tolerations }}
  47. tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.worker.tolerations "context" .) | nindent 8 }}
  48. {{- end }}
  49. {{- if .Values.worker.priorityClassName }}
  50. priorityClassName: {{ .Values.worker.priorityClassName | quote }}
  51. {{- end }}
  52. {{- if .Values.worker.schedulerName }}
  53. schedulerName: {{ .Values.worker.schedulerName | quote }}
  54. {{- end }}
  55. {{- if .Values.worker.topologySpreadConstraints }}
  56. topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.worker.topologySpreadConstraints "context" .) | nindent 8 }}
  57. {{- end }}
  58. {{- if .Values.worker.podSecurityContext.enabled }}
  59. securityContext: {{- omit .Values.worker.podSecurityContext "enabled" | toYaml | nindent 8 }}
  60. {{- end }}
  61. {{- if .Values.worker.terminationGracePeriodSeconds }}
  62. terminationGracePeriodSeconds: {{ .Values.worker.terminationGracePeriodSeconds }}
  63. {{- end }}
  64. initContainers:
  65. {{- if .Values.worker.initContainers }}
  66. {{- include "common.tplvalues.render" (dict "value" .Values.worker.initContainers "context" $) | nindent 8 }}
  67. {{- end }}
  68. containers:
  69. - name: worker
  70. image: {{ template "shuffle.worker.image" . }}
  71. imagePullPolicy: {{ .Values.worker.image.pullPolicy }}
  72. {{- if .Values.worker.containerSecurityContext.enabled }}
  73. securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.worker.containerSecurityContext "context" $) | nindent 12 }}
  74. {{- end }}
  75. {{- if .Values.diagnosticMode.enabled }}
  76. command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
  77. {{- else if .Values.worker.command }}
  78. command: {{- include "common.tplvalues.render" (dict "value" .Values.worker.command "context" $) | nindent 12 }}
  79. {{- end }}
  80. {{- if .Values.diagnosticMode.enabled }}
  81. args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
  82. {{- else if .Values.worker.args }}
  83. args: {{- include "common.tplvalues.render" (dict "value" .Values.worker.args "context" $) | nindent 12 }}
  84. {{- end }}
  85. env:
  86. - name: CLEANUP
  87. value: "false" # Do not remove resources when restarting worker
  88. {{- $env := include "shuffle.workerInstance.env" . | fromYaml }}
  89. {{- range $key, $val := $env }}
  90. - name: {{ $key | quote }}
  91. value: {{ $val | quote }}
  92. {{- end }}
  93. {{- if .Values.worker.extraEnvVars }}
  94. {{- include "common.tplvalues.render" (dict "value" .Values.worker.extraEnvVars "context" $) | nindent 12 }}
  95. {{- end }}
  96. envFrom:
  97. {{- if .Values.worker.extraEnvVarsCM }}
  98. - configMapRef:
  99. name: {{ include "common.tplvalues.render" (dict "value" .Values.worker.extraEnvVarsCM "context" $) }}
  100. {{- end }}
  101. {{- if .Values.worker.extraEnvVarsSecret }}
  102. - secretRef:
  103. name: {{ include "common.tplvalues.render" (dict "value" .Values.worker.extraEnvVarsSecret "context" $) }}
  104. {{- end }}
  105. {{- if .Values.worker.resources }}
  106. resources: {{- toYaml .Values.worker.resources | nindent 12 }}
  107. {{- else if ne .Values.worker.resourcesPreset "none" }}
  108. resources: {{- include "common.resources.preset" (dict "type" .Values.worker.resourcesPreset) | nindent 12 }}
  109. {{- end }}
  110. ports:
  111. - name: http
  112. containerPort: {{ .Values.worker.containerPorts.http }}
  113. {{- if .Values.worker.extraContainerPorts }}
  114. {{- include "common.tplvalues.render" (dict "value" .Values.worker.extraContainerPorts "context" $) | nindent 12 }}
  115. {{- end }}
  116. {{- if not .Values.diagnosticMode.enabled }}
  117. {{- if .Values.worker.customLivenessProbe }}
  118. livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.worker.customLivenessProbe "context" $) | nindent 12 }}
  119. {{- else if .Values.worker.livenessProbe.enabled }}
  120. livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.worker.livenessProbe "enabled") "context" $) | nindent 12 }}
  121. {{- end }}
  122. {{- if .Values.worker.customReadinessProbe }}
  123. readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.worker.customReadinessProbe "context" $) | nindent 12 }}
  124. {{- else if .Values.worker.readinessProbe.enabled }}
  125. readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.worker.readinessProbe "enabled") "context" $) | nindent 12 }}
  126. {{- end }}
  127. {{- if .Values.worker.customStartupProbe }}
  128. startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.worker.customStartupProbe "context" $) | nindent 12 }}
  129. {{- else if .Values.worker.startupProbe.enabled }}
  130. startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.worker.startupProbe "enabled") "context" $) | nindent 12 }}
  131. {{- end }}
  132. {{- end }}
  133. {{- if .Values.worker.lifecycleHooks }}
  134. lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.worker.lifecycleHooks "context" $) | nindent 12 }}
  135. {{- end }}
  136. volumeMounts:
  137. - name: empty-dir
  138. mountPath: /tmp
  139. subPath: tmp-dir
  140. {{- if .Values.worker.extraVolumeMounts }}
  141. {{- include "common.tplvalues.render" (dict "value" .Values.worker.extraVolumeMounts "context" $) | nindent 12 }}
  142. {{- end }}
  143. {{- if .Values.worker.sidecars }}
  144. {{- include "common.tplvalues.render" ( dict "value" .Values.worker.sidecars "context" $) | nindent 8 }}
  145. {{- end }}
  146. volumes:
  147. - name: empty-dir
  148. emptyDir: {}
  149. {{- if .Values.worker.extraVolumes }}
  150. {{- include "common.tplvalues.render" (dict "value" .Values.worker.extraVolumes "context" $) | nindent 8 }}
  151. {{- end }}
  152. {{- end }}