deployment.yaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
  2. kind: Deployment
  3. metadata:
  4. name: {{ include "common.names.fullname" . }}
  5. namespace: {{ .Release.Namespace | quote }}
  6. labels: {{- include "common.labels.standard" . | nindent 4 }}
  7. {{- if .Values.commonLabels }}
  8. {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
  9. {{- end }}
  10. {{- if .Values.commonAnnotations }}
  11. annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  12. {{- end }}
  13. spec:
  14. selector:
  15. matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
  16. {{- if .Values.updateStrategy }}
  17. strategy: {{- toYaml .Values.updateStrategy | nindent 4 }}
  18. {{- end }}
  19. replicas: {{ .Values.replicaCount }}
  20. template:
  21. metadata:
  22. labels: {{- include "common.labels.standard" . | nindent 8 }}
  23. {{- if .Values.podLabels }}
  24. {{- include "common.tplvalues.render" (dict "value" .Values.podLabels "context" $) | nindent 8 }}
  25. {{- end }}
  26. {{- if .Values.podAnnotations }}
  27. annotations:
  28. {{- if .Values.podAnnotations }}
  29. {{- include "common.tplvalues.render" (dict "value" .Values.podAnnotations "context" $) | nindent 8 }}
  30. {{- end }}
  31. {{- if .Values.metrics.podAnnotations }}
  32. {{- include "common.tplvalues.render" (dict "value" .Values.metrics.podAnnotations "context" $) | nindent 8 }}
  33. {{- end }}
  34. {{- end }}
  35. spec:
  36. {{- include "halo.imagePullSecrets" . | nindent 6 }}
  37. {{- if .Values.hostAliases }}
  38. # yamllint disable rule:indentation
  39. hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.hostAliases "context" $) | nindent 8 }}
  40. # yamllint enable rule:indentation
  41. {{- end }}
  42. {{- if .Values.affinity }}
  43. affinity: {{- include "common.tplvalues.render" (dict "value" .Values.affinity "context" $) | nindent 8 }}
  44. {{- else }}
  45. affinity:
  46. podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAffinityPreset "context" $) | nindent 10 }}
  47. podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAntiAffinityPreset "context" $) | nindent 10 }}
  48. nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.nodeAffinityPreset.type "key" .Values.nodeAffinityPreset.key "values" .Values.nodeAffinityPreset.values) | nindent 10 }}
  49. {{- end }}
  50. {{- if .Values.nodeSelector }}
  51. nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.nodeSelector "context" $) | nindent 8 }}
  52. {{- end }}
  53. {{- if .Values.tolerations }}
  54. tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.tolerations "context" $) | nindent 8 }}
  55. {{- end }}
  56. {{- if .Values.priorityClassName }}
  57. priorityClassName: {{ .Values.priorityClassName }}
  58. {{- end }}
  59. {{- if .Values.schedulerName }}
  60. schedulerName: {{ .Values.schedulerName | quote }}
  61. {{- end }}
  62. {{- if .Values.podSecurityContext.enabled }}
  63. securityContext: {{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 }}
  64. {{- end }}
  65. serviceAccountName: {{ include "halo.serviceAccountName" .}}
  66. {{- if .Values.topologySpreadConstraints }}
  67. topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.topologySpreadConstraints "context" .) | nindent 8 }}
  68. {{- end }}
  69. initContainers:
  70. - name: wait-database
  71. image: busybox:latest
  72. imagePullPolicy: IfNotPresent
  73. command:
  74. - sh
  75. - -c
  76. - |
  77. set -ex
  78. until nc -zv {{ include "halo.databaseHost" . }} {{ include "halo.databasePort" . }}; do sleep 5; done
  79. sleep 10
  80. {{- if and .Values.podSecurityContext.enabled .Values.volumePermissions.enabled .Values.persistence.enabled }}
  81. - name: volume-permissions
  82. image: "{{ include "halo.volumePermissions.image" . }}"
  83. imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
  84. command:
  85. - /bin/bash
  86. args:
  87. - -ec
  88. - |
  89. mkdir -p /data/halo
  90. {{- if eq ( toString ( .Values.volumePermissions.containerSecurityContext.runAsUser )) "auto" }}
  91. find /data/halo -mindepth 0 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" | xargs -r chown -R $(id -u):$(id -G | cut -d " " -f2)
  92. {{- else }}
  93. find /data/halo -mindepth 0 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" | xargs -r chown -R {{ .Values.containerSecurityContext.runAsUser }}:{{ .Values.podSecurityContext.fsGroup }}
  94. {{- end }}
  95. {{- if eq ( toString ( .Values.volumePermissions.containerSecurityContext.runAsUser )) "auto " }}
  96. securityContext: {{- omit .Values.volumePermissions.containerSecurityContext "runAsUser" | toYaml | nindent 12 }}
  97. {{- else }}
  98. securityContext: {{- .Values.volumePermissions.containerSecurityContext | toYaml | nindent 12 }}
  99. {{- end }}
  100. {{- if .Values.volumePermissions.resources }}
  101. resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
  102. {{- end }}
  103. volumeMounts:
  104. - mountPath: /data/halo
  105. name: halo-data
  106. subPath: halo
  107. {{- end }}
  108. {{- if .Values.initContainers }}
  109. {{- include "common.tplvalues.render" (dict "value" .Values.initContainers "context" $) | nindent 8 }}
  110. {{- end }}
  111. containers:
  112. - name: halo
  113. image: {{ include "halo.image" . }}
  114. imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
  115. {{- if .Values.diagnosticMode.enabled }}
  116. command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
  117. {{- else if .Values.command }}
  118. command: {{- include "common.tplvalues.render" ( dict "value" .Values.command "context" $) | nindent 12 }}
  119. {{- end }}
  120. {{- if .Values.diagnosticMode.enabled }}
  121. args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
  122. {{- else if .Values.args }}
  123. args: {{- include "common.tplvalues.render" ( dict "value" .Values.args "context" $) | nindent 12 }}
  124. {{- end }}
  125. {{- if .Values.containerSecurityContext.enabled }}
  126. securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }}
  127. {{- end }}
  128. env:
  129. - name: SERVER_PORT
  130. value: "{{ .Values.containerPorts.http }}"
  131. - name: HALO_WORK_DIR
  132. value: /data/halo
  133. - name: SPRING_R2DBC_URL
  134. value: {{ include "halo.r2dbcUrl" . | quote }}
  135. - name: SPRING_R2DBC_USERNAME
  136. value: {{ include "halo.databaseUser" . | quote }}
  137. - name: SPRING_R2DBC_PASSWORD
  138. valueFrom:
  139. secretKeyRef:
  140. name: {{ include "halo.databaseSecretName" . }}
  141. key: {{ include "halo.databaseSecretKeyName" . }}
  142. - name: SPRING_SQL_INIT_PLATFORM
  143. value: {{ include "halo.databasePlatform" . | quote }}
  144. - name: HALO_EXTERNAL_URL
  145. value: http://localhost:8090/
  146. - name: HALO_SECURITY_INITIALIZER_SUPERADMINUSERNAME
  147. value: {{ .Values.haloUsername | quote }}
  148. - name: HALO_SECURITY_INITIALIZER_SUPERADMINPASSWORD
  149. valueFrom:
  150. secretKeyRef:
  151. name: {{ include "halo.secretName" . }}
  152. key: halo-password
  153. {{- if .Values.extraEnvVars }}
  154. {{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }}
  155. {{- end }}
  156. envFrom:
  157. {{- if .Values.extraEnvVarsCM }}
  158. - configMapRef:
  159. name: {{ include "common.tplvalues.render" (dict "value" .Values.extraEnvVarsCM "context" $) }}
  160. {{- end }}
  161. {{- if .Values.extraEnvVarsSecret }}
  162. - secretRef:
  163. name: {{ include "common.tplvalues.render" (dict "value" .Values.extraEnvVarsSecret "context" $) }}
  164. {{- end }}
  165. ports:
  166. - name: http
  167. containerPort: {{ .Values.containerPorts.http }}
  168. {{- if .Values.extraContainerPorts }}
  169. {{- include "common.tplvalues.render" (dict "value" .Values.extraContainerPorts "context" $) | nindent 12 }}
  170. {{- end }}
  171. {{- if .Values.lifecycleHooks }}
  172. lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.lifecycleHooks "context" $) | nindent 12 }}
  173. {{- end }}
  174. {{- if not .Values.diagnosticMode.enabled }}
  175. {{- if .Values.customLivenessProbe }}
  176. livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customLivenessProbe "context" $) | nindent 12 }}
  177. {{- else if .Values.livenessProbe.enabled }}
  178. livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.livenessProbe "enabled") "context" $) | nindent 12 }}
  179. {{- end }}
  180. {{- if .Values.customReadinessProbe }}
  181. readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customReadinessProbe "context" $) | nindent 12 }}
  182. {{- else if .Values.readinessProbe.enabled }}
  183. readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.readinessProbe "enabled") "context" $) | nindent 12 }}
  184. {{- end }}
  185. {{- if .Values.customStartupProbe }}
  186. startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customStartupProbe "context" $) | nindent 12 }}
  187. {{- else if .Values.startupProbe.enabled }}
  188. startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.startupProbe "enabled") "context" $) | nindent 12 }}
  189. {{- end }}
  190. {{- end }}
  191. {{- if .Values.resources }}
  192. resources: {{- toYaml .Values.resources | nindent 12 }}
  193. {{- end }}
  194. volumeMounts:
  195. - mountPath: /data/halo
  196. name: halo-data
  197. subPath: halo
  198. {{- if .Values.extraVolumeMounts }}
  199. {{- include "common.tplvalues.render" (dict "value" .Values.extraVolumeMounts "context" $) | nindent 12 }}
  200. {{- end }}
  201. {{- if .Values.sidecars }}
  202. {{- include "common.tplvalues.render" (dict "value" .Values.sidecars "context" $) | nindent 8 }}
  203. {{- end }}
  204. volumes:
  205. - name: halo-data
  206. {{- if .Values.persistence.enabled }}
  207. persistentVolumeClaim:
  208. claimName: {{ .Values.persistence.existingClaim | default (include "common.names.fullname" .) }}
  209. {{- else }}
  210. emptyDir: {}
  211. {{- end }}
  212. {{- if .Values.extraVolumes }}
  213. {{- include "common.tplvalues.render" (dict "value" .Values.extraVolumes "context" $) | nindent 8 }}
  214. {{- end }}