_helpers.tpl 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. {{/* vim: set filetype=mustache: */}}
  18. {{/*
  19. Create a default fully qualified app name.
  20. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
  21. If release name contains chart name it will be used as a full name.
  22. */}}
  23. {{- define "dolphinscheduler.fullname" -}}
  24. {{- .Release.Name | trunc 63 | trimSuffix "-" -}}
  25. {{- end -}}
  26. {{/*
  27. Create default docker images' fullname.
  28. */}}
  29. {{- define "dolphinscheduler.image.fullname.master" -}}
  30. {{- .Values.image.registry }}/dolphinscheduler-master:{{ .Values.image.tag | default .Chart.AppVersion -}}
  31. {{- end -}}
  32. {{- define "dolphinscheduler.image.fullname.worker" -}}
  33. {{- .Values.image.registry }}/dolphinscheduler-worker:{{ .Values.image.tag | default .Chart.AppVersion -}}
  34. {{- end -}}
  35. {{- define "dolphinscheduler.image.fullname.api" -}}
  36. {{- .Values.image.registry }}/dolphinscheduler-api:{{ .Values.image.tag | default .Chart.AppVersion -}}
  37. {{- end -}}
  38. {{- define "dolphinscheduler.image.fullname.alert" -}}
  39. {{- .Values.image.registry }}/dolphinscheduler-alert-server:{{ .Values.image.tag | default .Chart.AppVersion -}}
  40. {{- end -}}
  41. {{- define "dolphinscheduler.image.fullname.tools" -}}
  42. {{- .Values.image.registry }}/dolphinscheduler-tools:{{ .Values.image.tag | default .Chart.AppVersion -}}
  43. {{- end -}}
  44. {{- define "dolphinscheduler.image.fullname.python-gateway" -}}
  45. {{- .Values.image.registry }}/dolphinscheduler-python-gateway:{{ .Values.image.tag | default .Chart.AppVersion -}}
  46. {{- end -}}
  47. {{/*
  48. Create a default common labels.
  49. */}}
  50. {{- define "dolphinscheduler.common.labels" -}}
  51. app.kubernetes.io/instance: {{ .Release.Name }}
  52. app.kubernetes.io/managed-by: {{ .Release.Service }}
  53. app.kubernetes.io/version: {{ .Chart.AppVersion }}
  54. {{- end -}}
  55. {{/*
  56. Create a master labels.
  57. */}}
  58. {{- define "dolphinscheduler.master.labels" -}}
  59. app.kubernetes.io/name: {{ include "dolphinscheduler.fullname" . }}-master
  60. app.kubernetes.io/component: master
  61. {{ include "dolphinscheduler.common.labels" . }}
  62. {{- end -}}
  63. {{/*
  64. Create a worker labels.
  65. */}}
  66. {{- define "dolphinscheduler.worker.labels" -}}
  67. app.kubernetes.io/name: {{ include "dolphinscheduler.fullname" . }}-worker
  68. app.kubernetes.io/component: worker
  69. {{ include "dolphinscheduler.common.labels" . }}
  70. {{- end -}}
  71. {{/*
  72. Create an alert labels.
  73. */}}
  74. {{- define "dolphinscheduler.alert.labels" -}}
  75. app.kubernetes.io/name: {{ include "dolphinscheduler.fullname" . }}-alert
  76. app.kubernetes.io/component: alert
  77. {{ include "dolphinscheduler.common.labels" . }}
  78. {{- end -}}
  79. {{/*
  80. Create an api labels.
  81. */}}
  82. {{- define "dolphinscheduler.api.labels" -}}
  83. app.kubernetes.io/name: {{ include "dolphinscheduler.fullname" . }}-api
  84. app.kubernetes.io/component: api
  85. {{ include "dolphinscheduler.common.labels" . }}
  86. {{- end -}}
  87. {{/*
  88. Create a default fully qualified postgresql name.
  89. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
  90. */}}
  91. {{- define "dolphinscheduler.postgresql.fullname" -}}
  92. {{- $name := default "postgresql" .Values.postgresql.nameOverride -}}
  93. {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
  94. {{- end -}}
  95. {{/*
  96. Create a default fully qualified zookkeeper name.
  97. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
  98. */}}
  99. {{- define "dolphinscheduler.zookeeper.fullname" -}}
  100. {{- $name := default "zookeeper" .Values.zookeeper.nameOverride -}}
  101. {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
  102. {{- end -}}
  103. {{/*
  104. Create a default fully qualified zookkeeper quorum.
  105. */}}
  106. {{- define "dolphinscheduler.zookeeper.quorum" -}}
  107. {{- $port := default "2181" (.Values.zookeeper.service.port | toString) -}}
  108. {{- printf "%s:%s" (include "dolphinscheduler.zookeeper.fullname" .) $port -}}
  109. {{- end -}}
  110. {{/*
  111. Create a database environment variables.
  112. */}}
  113. {{- define "dolphinscheduler.database.env_vars" -}}
  114. - name: DATABASE
  115. {{- if .Values.postgresql.enabled }}
  116. value: "postgresql"
  117. {{- else }}
  118. value: {{ .Values.externalDatabase.type | quote }}
  119. {{- end }}
  120. - name: SPRING_DATASOURCE_URL
  121. {{- if .Values.postgresql.enabled }}
  122. value: jdbc:postgresql://{{ template "dolphinscheduler.postgresql.fullname" . }}:5432/{{ .Values.postgresql.postgresqlDatabase }}?characterEncoding=utf8
  123. {{- else }}
  124. value: jdbc:{{ .Values.externalDatabase.type }}://{{ .Values.externalDatabase.host }}:{{ .Values.externalDatabase.port }}/{{ .Values.externalDatabase.database }}?{{ .Values.externalDatabase.params }}
  125. {{- end }}
  126. - name: SPRING_DATASOURCE_USERNAME
  127. {{- if .Values.postgresql.enabled }}
  128. value: {{ .Values.postgresql.postgresqlUsername }}
  129. {{- else }}
  130. value: {{ .Values.externalDatabase.username | quote }}
  131. {{- end }}
  132. - name: SPRING_DATASOURCE_PASSWORD
  133. valueFrom:
  134. secretKeyRef:
  135. {{- if .Values.postgresql.enabled }}
  136. name: {{ template "dolphinscheduler.postgresql.fullname" . }}
  137. key: postgresql-password
  138. {{- else }}
  139. name: {{ include "dolphinscheduler.fullname" . }}-externaldb
  140. key: database-password
  141. {{- end }}
  142. {{- end -}}
  143. {{/*
  144. Wait for database to be ready.
  145. */}}
  146. {{- define "dolphinscheduler.database.wait-for-ready" -}}
  147. - name: wait-for-database
  148. image: busybox:1.30
  149. imagePullPolicy: IfNotPresent
  150. {{- if .Values.postgresql.enabled }}
  151. command: ['sh', '-xc', 'for i in $(seq 1 180); do nc -z -w3 {{ template "dolphinscheduler.postgresql.fullname" . }} 5432 && exit 0 || sleep 5; done; exit 1']
  152. {{- else }}
  153. command: ['sh', '-xc', 'for i in $(seq 1 180); do nc -z -w3 {{ .Values.externalDatabase.host }} {{ .Values.externalDatabase.port }} && exit 0 || sleep 5; done; exit 1']
  154. {{- end }}
  155. {{- end -}}
  156. {{/*
  157. Create a registry environment variables.
  158. */}}
  159. {{- define "dolphinscheduler.registry.env_vars" -}}
  160. - name: REGISTRY_TYPE
  161. {{- if .Values.zookeeper.enabled }}
  162. value: "zookeeper"
  163. {{- else }}
  164. value: {{ .Values.externalRegistry.registryPluginName }}
  165. {{- end }}
  166. - name: REGISTRY_ZOOKEEPER_CONNECT_STRING
  167. {{- if .Values.zookeeper.enabled }}
  168. value: {{ template "dolphinscheduler.zookeeper.quorum" . }}
  169. {{- else }}
  170. value: {{ .Values.externalRegistry.registryServers }}
  171. {{- end }}
  172. {{- end -}}
  173. {{/*
  174. Create a common fs_s3a environment variables.
  175. */}}
  176. {{- define "dolphinscheduler.fs_s3a.env_vars" -}}
  177. {{- if eq (default "HDFS" .Values.common.configmap.RESOURCE_STORAGE_TYPE) "S3" -}}
  178. - name: FS_S3A_SECRET_KEY
  179. valueFrom:
  180. secretKeyRef:
  181. key: fs-s3a-secret-key
  182. name: {{ include "dolphinscheduler.fullname" . }}-fs-s3a
  183. {{- end -}}
  184. {{- end -}}
  185. {{/*
  186. Create a sharedStoragePersistence volume.
  187. */}}
  188. {{- define "dolphinscheduler.sharedStorage.volume" -}}
  189. {{- if .Values.common.sharedStoragePersistence.enabled -}}
  190. - name: {{ include "dolphinscheduler.fullname" . }}-shared
  191. persistentVolumeClaim:
  192. claimName: {{ include "dolphinscheduler.fullname" . }}-shared
  193. {{- end -}}
  194. {{- end -}}
  195. {{/*
  196. Create a sharedStoragePersistence volumeMount.
  197. */}}
  198. {{- define "dolphinscheduler.sharedStorage.volumeMount" -}}
  199. {{- if .Values.common.sharedStoragePersistence.enabled -}}
  200. - mountPath: {{ .Values.common.sharedStoragePersistence.mountPath | quote }}
  201. name: {{ include "dolphinscheduler.fullname" . }}-shared
  202. {{- end -}}
  203. {{- end -}}
  204. {{/*
  205. Create a fsFileResourcePersistence volume.
  206. */}}
  207. {{- define "dolphinscheduler.fsFileResource.volume" -}}
  208. {{- if .Values.common.fsFileResourcePersistence.enabled -}}
  209. - name: {{ include "dolphinscheduler.fullname" . }}-fs-file
  210. persistentVolumeClaim:
  211. claimName: {{ include "dolphinscheduler.fullname" . }}-fs-file
  212. {{- end -}}
  213. {{- end -}}
  214. {{/*
  215. Create a fsFileResourcePersistence volumeMount.
  216. */}}
  217. {{- define "dolphinscheduler.fsFileResource.volumeMount" -}}
  218. {{- if .Values.common.fsFileResourcePersistence.enabled -}}
  219. - mountPath: {{ default "/dolphinscheduler" .Values.common.configmap.RESOURCE_UPLOAD_PATH | quote }}
  220. name: {{ include "dolphinscheduler.fullname" . }}-fs-file
  221. {{- end -}}
  222. {{- end -}}