Geen omschrijving

backend-dpl.yaml 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
  2. kind: Deployment
  3. metadata:
  4. name: {{ template "shuffle.backend.name" . }}
  5. namespace: {{ include "common.names.namespace" . | quote }}
  6. labels: {{- include "shuffle.backend.labels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
  7. {{- if or .Values.backend.deploymentAnnotations .Values.commonAnnotations }}
  8. {{- $annotations := include "common.tplvalues.merge" (dict "values" (list .Values.backend.deploymentAnnotations .Values.commonAnnotations) "context" .) }}
  9. annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 4 }}
  10. {{- end }}
  11. spec:
  12. {{- if not .Values.backend.autoscaling.hpa.enabled }}
  13. replicas: {{ .Values.backend.replicaCount }}
  14. {{- end }}
  15. {{- if .Values.backend.updateStrategy }}
  16. strategy: {{- toYaml .Values.backend.updateStrategy | nindent 4 }}
  17. {{- end }}
  18. {{- $podLabels := include "common.tplvalues.merge" (dict "values" (list .Values.backend.podLabels .Values.commonLabels) "context" .) }}
  19. selector:
  20. matchLabels: {{- include "shuffle.backend.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
  21. template:
  22. metadata:
  23. {{- if .Values.backend.podAnnotations }}
  24. annotations: {{- include "common.tplvalues.render" (dict "value" .Values.backend.podAnnotations "context" $) | nindent 8 }}
  25. {{- end }}
  26. labels: {{- include "shuffle.backend.labels" ( dict "customLabels" $podLabels "context" $ ) | nindent 8 }}
  27. spec:
  28. {{- include "shuffle.backend.imagePullSecrets" . | nindent 6 }}
  29. serviceAccountName: {{ template "shuffle.backend.serviceAccount.name" . }}
  30. automountServiceAccountToken: {{ .Values.backend.automountServiceAccountToken }}
  31. {{- if .Values.backend.hostAliases }}
  32. hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.backend.hostAliases "context" $) | nindent 8 }}
  33. {{- end }}
  34. {{- if .Values.backend.affinity }}
  35. affinity: {{- include "common.tplvalues.render" ( dict "value" .Values.backend.affinity "context" $) | nindent 8 }}
  36. {{- else }}
  37. affinity:
  38. podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.backend.podAffinityPreset "component" "backend" "customLabels" $podLabels "context" $) | nindent 10 }}
  39. podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.backend.podAntiAffinityPreset "component" "backend" "customLabels" $podLabels "context" $) | nindent 10 }}
  40. nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.backend.nodeAffinityPreset.type "key" .Values.backend.nodeAffinityPreset.key "values" .Values.backend.nodeAffinityPreset.values) | nindent 10 }}
  41. {{- end }}
  42. {{- if .Values.backend.nodeSelector }}
  43. nodeSelector: {{- include "common.tplvalues.render" ( dict "value" .Values.backend.nodeSelector "context" $) | nindent 8 }}
  44. {{- end }}
  45. {{- if .Values.backend.tolerations }}
  46. tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.backend.tolerations "context" .) | nindent 8 }}
  47. {{- end }}
  48. {{- if .Values.backend.priorityClassName }}
  49. priorityClassName: {{ .Values.backend.priorityClassName | quote }}
  50. {{- end }}
  51. {{- if .Values.backend.schedulerName }}
  52. schedulerName: {{ .Values.backend.schedulerName | quote }}
  53. {{- end }}
  54. {{- if .Values.backend.topologySpreadConstraints }}
  55. topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.backend.topologySpreadConstraints "context" .) | nindent 8 }}
  56. {{- end }}
  57. {{- if .Values.backend.podSecurityContext.enabled }}
  58. securityContext: {{- omit .Values.backend.podSecurityContext "enabled" | toYaml | nindent 8 }}
  59. {{- end }}
  60. {{- if .Values.backend.terminationGracePeriodSeconds }}
  61. terminationGracePeriodSeconds: {{ .Values.backend.terminationGracePeriodSeconds }}
  62. {{- end }}
  63. initContainers:
  64. {{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
  65. - name: volume-permissions
  66. image: {{ include "shuffle.volumePermissions.image" . }}
  67. imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
  68. command:
  69. - /bin/bash
  70. - -ec
  71. - |
  72. chown -vR {{ .Values.backend.containerSecurityContext.runAsUser }}:{{ .Values.backend.podSecurityContext.fsGroup }} /app/generated && \
  73. chown -vR {{ .Values.backend.containerSecurityContext.runAsUser }}:{{ .Values.backend.podSecurityContext.fsGroup }} /shuffle-apps && \
  74. chown -vR {{ .Values.backend.containerSecurityContext.runAsUser }}:{{ .Values.backend.podSecurityContext.fsGroup }} /shuffle-files
  75. {{- if .Values.volumePermissions.containerSecurityContext.enabled }}
  76. securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.volumePermissions.containerSecurityContext "context" $) | nindent 12 }}
  77. {{- end }}
  78. {{- if .Values.volumePermissions.resources }}
  79. resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
  80. {{- else if ne .Values.volumePermissions.resourcesPreset "none" }}
  81. resources: {{- include "common.resources.preset" (dict "type" .Values.volumePermissions.resourcesPreset) | nindent 12 }}
  82. {{- end }}
  83. volumeMounts:
  84. - name: shuffle-app-builder
  85. mountPath: /app/generated
  86. - name: shuffle-apps
  87. mountPath: /shuffle-apps
  88. {{- if .Values.persistence.apps.subPath }}
  89. subPath: {{ .Values.persistence.apps.subPath }}
  90. {{- end }}
  91. - name: shuffle-files
  92. mountPath: /shuffle-files
  93. {{- if .Values.persistence.files.subPath }}
  94. subPath: {{ .Values.persistence.apps.subPath }}
  95. {{- end }}
  96. {{- end }}
  97. {{- if .Values.backend.initContainers }}
  98. {{- include "common.tplvalues.render" (dict "value" .Values.backend.initContainers "context" $) | nindent 8 }}
  99. {{- end }}
  100. containers:
  101. - name: backend
  102. image: {{ template "shuffle.backend.image" . }}
  103. imagePullPolicy: {{ .Values.backend.image.pullPolicy }}
  104. {{- if .Values.backend.containerSecurityContext.enabled }}
  105. securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.backend.containerSecurityContext "context" $) | nindent 12 }}
  106. {{- end }}
  107. {{- if .Values.diagnosticMode.enabled }}
  108. command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
  109. {{- else if .Values.backend.command }}
  110. command: {{- include "common.tplvalues.render" (dict "value" .Values.backend.command "context" $) | nindent 12 }}
  111. {{- end }}
  112. {{- if .Values.diagnosticMode.enabled }}
  113. args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
  114. {{- else if .Values.backend.args }}
  115. args: {{- include "common.tplvalues.render" (dict "value" .Values.backend.args "context" $) | nindent 12 }}
  116. {{- end }}
  117. env:
  118. {{- $env := include "shuffle.backend.env" . | fromYaml }}
  119. {{- range $key, $val := $env }}
  120. - name: {{ $key | quote }}
  121. value: {{ $val | quote }}
  122. {{- end }}
  123. {{- if .Values.backend.extraEnvVars }}
  124. {{- include "common.tplvalues.render" (dict "value" .Values.backend.extraEnvVars "context" $) | nindent 12 }}
  125. {{- end }}
  126. envFrom:
  127. {{- if .Values.backend.extraEnvVarsCM }}
  128. - configMapRef:
  129. name: {{ include "common.tplvalues.render" (dict "value" .Values.backend.extraEnvVarsCM "context" $) }}
  130. {{- end }}
  131. {{- if .Values.backend.extraEnvVarsSecret }}
  132. - secretRef:
  133. name: {{ include "common.tplvalues.render" (dict "value" .Values.backend.extraEnvVarsSecret "context" $) }}
  134. {{- end }}
  135. {{- if .Values.backend.resources }}
  136. resources: {{- toYaml .Values.backend.resources | nindent 12 }}
  137. {{- else if ne .Values.backend.resourcesPreset "none" }}
  138. resources: {{- include "common.resources.preset" (dict "type" .Values.backend.resourcesPreset) | nindent 12 }}
  139. {{- end }}
  140. ports:
  141. - name: http
  142. containerPort: {{ .Values.backend.containerPorts.http }}
  143. {{- if .Values.backend.extraContainerPorts }}
  144. {{- include "common.tplvalues.render" (dict "value" .Values.backend.extraContainerPorts "context" $) | nindent 12 }}
  145. {{- end }}
  146. {{- if not .Values.diagnosticMode.enabled }}
  147. {{- if .Values.backend.customLivenessProbe }}
  148. livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.backend.customLivenessProbe "context" $) | nindent 12 }}
  149. {{- else if .Values.backend.livenessProbe.enabled }}
  150. livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.backend.livenessProbe "enabled") "context" $) | nindent 12 }}
  151. httpGet:
  152. path: /api/v1/health
  153. port: {{ .Values.backend.containerPorts.http }}
  154. {{- end }}
  155. {{- if .Values.backend.customReadinessProbe }}
  156. readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.backend.customReadinessProbe "context" $) | nindent 12 }}
  157. {{- else if .Values.backend.readinessProbe.enabled }}
  158. readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.backend.readinessProbe "enabled") "context" $) | nindent 12 }}
  159. httpGet:
  160. path: /api/v1/health
  161. port: {{ .Values.backend.containerPorts.http }}
  162. {{- end }}
  163. {{- if .Values.backend.customStartupProbe }}
  164. startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.backend.customStartupProbe "context" $) | nindent 12 }}
  165. {{- else if .Values.backend.startupProbe.enabled }}
  166. startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.backend.startupProbe "enabled") "context" $) | nindent 12 }}
  167. httpGet:
  168. path: /api/v1/health
  169. port: {{ .Values.backend.containerPorts.http }}
  170. {{- end }}
  171. {{- end }}
  172. {{- if .Values.backend.lifecycleHooks }}
  173. lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.backend.lifecycleHooks "context" $) | nindent 12 }}
  174. {{- end }}
  175. volumeMounts:
  176. - name: shuffle-app-builder
  177. mountPath: /app/generated
  178. - name: shuffle-apps
  179. mountPath: /shuffle-apps
  180. {{- if .Values.persistence.apps.subPath }}
  181. subPath: {{ .Values.persistence.apps.subPath }}
  182. {{- end }}
  183. - name: shuffle-files
  184. mountPath: /shuffle-files
  185. {{- if .Values.persistence.files.subPath }}
  186. subPath: {{ .Values.persistence.apps.subPath }}
  187. {{- end }}
  188. - name: empty-dir
  189. mountPath: /tmp
  190. subPath: tmp-dir
  191. {{- if .Values.backend.extraVolumeMounts }}
  192. {{- include "common.tplvalues.render" (dict "value" .Values.backend.extraVolumeMounts "context" $) | nindent 12 }}
  193. {{- end }}
  194. {{- if .Values.backend.sidecars }}
  195. {{- include "common.tplvalues.render" ( dict "value" .Values.backend.sidecars "context" $) | nindent 8 }}
  196. {{- end }}
  197. volumes:
  198. - name: empty-dir
  199. emptyDir: {}
  200. - name: shuffle-app-builder
  201. persistentVolumeClaim:
  202. claimName: backend-apps-claim
  203. - name: shuffle-apps
  204. {{- if .Values.persistence.enabled }}
  205. persistentVolumeClaim:
  206. claimName: {{ default (printf "%s-apps" (include "shuffle.backend.name" .)) .Values.persistence.apps.existingClaim }}
  207. {{- else }}
  208. emptyDir: {}
  209. {{- end }}
  210. - name: shuffle-files
  211. {{- if .Values.persistence.enabled }}
  212. persistentVolumeClaim:
  213. claimName: {{ default (printf "%s-files" (include "shuffle.backend.name" .)) .Values.persistence.apps.existingClaim }}
  214. {{- else }}
  215. emptyDir: {}
  216. {{- end }}
  217. {{- if .Values.backend.extraVolumes }}
  218. {{- include "common.tplvalues.render" (dict "value" .Values.backend.extraVolumes "context" $) | nindent 8 }}
  219. {{- end }}