init-job.yaml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. {{/*
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. */}}
  15. {{- if .Values.init.enabled }}
  16. apiVersion: batch/v1
  17. kind: Job
  18. metadata:
  19. name: {{ template "superset.fullname" . }}-init-db
  20. namespace: {{ .Release.Namespace }}
  21. {{- if .Values.init.jobAnnotations }}
  22. annotations: {{- toYaml .Values.init.jobAnnotations | nindent 4 }}
  23. {{- end }}
  24. spec:
  25. template:
  26. metadata:
  27. name: {{ template "superset.fullname" . }}-init-db
  28. {{- if .Values.init.podAnnotations }}
  29. annotations: {{- toYaml .Values.init.podAnnotations | nindent 8 }}
  30. {{- end }}
  31. spec:
  32. {{- if or (.Values.serviceAccount.create) (.Values.serviceAccountName) }}
  33. serviceAccountName: {{ template "superset.serviceAccountName" . }}
  34. {{- end }}
  35. securityContext:
  36. runAsUser: {{ .Values.runAsUser }}
  37. {{- if .Values.init.podSecurityContext }}
  38. {{- toYaml .Values.init.podSecurityContext | nindent 8 }}
  39. {{- end }}
  40. {{- if .Values.init.initContainers }}
  41. initContainers: {{- tpl (toYaml .Values.init.initContainers) . | nindent 6 }}
  42. {{- end }}
  43. containers:
  44. - name: {{ template "superset.name" . }}-init-db
  45. image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
  46. {{- if or .Values.extraEnv .Values.extraEnvRaw }}
  47. env:
  48. {{- range $key, $value := .Values.extraEnv }}
  49. - name: {{ $key | quote }}
  50. value: {{ $value | quote }}
  51. {{- end }}
  52. {{- if .Values.extraEnvRaw }}
  53. {{- toYaml .Values.extraEnvRaw | nindent 10 }}
  54. {{- end }}
  55. {{- end }}
  56. envFrom:
  57. - secretRef:
  58. name: {{ tpl .Values.envFromSecret . }}
  59. {{- range .Values.envFromSecrets }}
  60. - secretRef:
  61. name: {{ tpl . $ | quote }}
  62. {{- end }}
  63. imagePullPolicy: {{ .Values.image.pullPolicy }}
  64. {{- if .Values.init.containerSecurityContext }}
  65. securityContext: {{- toYaml .Values.init.containerSecurityContext | nindent 12 }}
  66. {{- end }}
  67. volumeMounts:
  68. - name: superset-config
  69. mountPath: {{ .Values.configMountPath | quote }}
  70. readOnly: true
  71. {{- if .Values.extraConfigs }}
  72. - name: superset-extra-config
  73. mountPath: {{ .Values.extraConfigMountPath | quote }}
  74. readOnly: true
  75. {{- end }}
  76. {{- with .Values.extraVolumeMounts }}
  77. {{- tpl (toYaml .) $ | nindent 10 -}}
  78. {{- end }}
  79. command: {{ tpl (toJson .Values.init.command) . }}
  80. resources: {{- toYaml .Values.init.resources | nindent 10 }}
  81. {{- if .Values.init.extraContainers }}
  82. {{- toYaml .Values.init.extraContainers | nindent 6 }}
  83. {{- end }}
  84. {{- with .Values.nodeSelector }}
  85. nodeSelector: {{- toYaml . | nindent 8 }}
  86. {{- end }}
  87. {{- if or .Values.affinity .Values.init.affinity }}
  88. affinity:
  89. {{- with .Values.affinity }}
  90. {{- toYaml . | nindent 8 }}
  91. {{- end }}
  92. {{- with .Values.init.affinity }}
  93. {{- toYaml . | nindent 8 }}
  94. {{- end }}
  95. {{- end }}
  96. {{- if or .Values.topologySpreadConstraints .Values.init.topologySpreadConstraints }}
  97. topologySpreadConstraints:
  98. {{- with .Values.topologySpreadConstraints }}
  99. {{- toYaml . | nindent 8 }}
  100. {{- end }}
  101. {{- with .Values.init.topologySpreadConstraints }}
  102. {{- toYaml . | nindent 8 }}
  103. {{- end }}
  104. {{- end }}
  105. {{- with .Values.tolerations }}
  106. tolerations: {{- toYaml . | nindent 8 }}
  107. {{- end }}
  108. {{- if .Values.imagePullSecrets }}
  109. imagePullSecrets: {{- toYaml .Values.imagePullSecrets | nindent 8 }}
  110. {{- end }}
  111. volumes:
  112. - name: superset-config
  113. secret:
  114. secretName: {{ tpl .Values.configFromSecret . }}
  115. {{- if .Values.extraConfigs }}
  116. - name: superset-extra-config
  117. configMap:
  118. name: {{ template "superset.fullname" . }}-extra-config
  119. {{- end }}
  120. {{- with .Values.extraVolumes }}
  121. {{- tpl (toYaml .) $ | nindent 8 -}}
  122. {{- end }}
  123. restartPolicy: Never
  124. {{- end }}