_helpers.tpl 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. {{/*
  45. Create a default common labels.
  46. */}}
  47. {{- define "dolphinscheduler.common.labels" -}}
  48. app.kubernetes.io/instance: {{ .Release.Name }}
  49. app.kubernetes.io/managed-by: {{ .Release.Service }}
  50. app.kubernetes.io/version: {{ .Chart.AppVersion }}
  51. {{- end -}}
  52. {{/*
  53. Create a master labels.
  54. */}}
  55. {{- define "dolphinscheduler.master.labels" -}}
  56. app.kubernetes.io/name: {{ include "dolphinscheduler.fullname" . }}-master
  57. app.kubernetes.io/component: master
  58. {{ include "dolphinscheduler.common.labels" . }}
  59. {{- end -}}
  60. {{/*
  61. Create a worker labels.
  62. */}}
  63. {{- define "dolphinscheduler.worker.labels" -}}
  64. app.kubernetes.io/name: {{ include "dolphinscheduler.fullname" . }}-worker
  65. app.kubernetes.io/component: worker
  66. {{ include "dolphinscheduler.common.labels" . }}
  67. {{- end -}}
  68. {{/*
  69. Create an alert labels.
  70. */}}
  71. {{- define "dolphinscheduler.alert.labels" -}}
  72. app.kubernetes.io/name: {{ include "dolphinscheduler.fullname" . }}-alert
  73. app.kubernetes.io/component: alert
  74. {{ include "dolphinscheduler.common.labels" . }}
  75. {{- end -}}
  76. {{/*
  77. Create an api labels.
  78. */}}
  79. {{- define "dolphinscheduler.api.labels" -}}
  80. app.kubernetes.io/name: {{ include "dolphinscheduler.fullname" . }}-api
  81. app.kubernetes.io/component: api
  82. {{ include "dolphinscheduler.common.labels" . }}
  83. {{- end -}}
  84. {{/*
  85. Create a default fully qualified postgresql name.
  86. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
  87. */}}
  88. {{- define "dolphinscheduler.postgresql.fullname" -}}
  89. {{- $name := default "postgresql" .Values.postgresql.nameOverride -}}
  90. {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
  91. {{- end -}}
  92. {{/*
  93. Create a default fully qualified zookkeeper name.
  94. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
  95. */}}
  96. {{- define "dolphinscheduler.zookeeper.fullname" -}}
  97. {{- $name := default "zookeeper" .Values.zookeeper.nameOverride -}}
  98. {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
  99. {{- end -}}
  100. {{/*
  101. Create a default fully qualified zookkeeper quorum.
  102. */}}
  103. {{- define "dolphinscheduler.zookeeper.quorum" -}}
  104. {{- $port := default "2181" .Values.zookeeper.service.port | toString -}}
  105. {{- printf "%s:%s" (include "dolphinscheduler.zookeeper.fullname" .) $port -}}
  106. {{- end -}}
  107. {{/*
  108. Create a database environment variables.
  109. */}}
  110. {{- define "dolphinscheduler.database.env_vars" -}}
  111. - name: DATABASE
  112. {{- if .Values.postgresql.enabled }}
  113. value: "postgresql"
  114. {{- else }}
  115. value: {{ .Values.externalDatabase.type | quote }}
  116. {{- end }}
  117. - name: SPRING_DATASOURCE_URL
  118. {{- if .Values.postgresql.enabled }}
  119. value: jdbc:postgresql://{{ template "dolphinscheduler.postgresql.fullname" . }}:5432/{{ .Values.postgresql.postgresqlDatabase }}?characterEncoding=utf8
  120. {{- else }}
  121. value: jdbc:{{ .Values.externalDatabase.type }}://{{ .Values.externalDatabase.host }}:{{ .Values.externalDatabase.port }}/{{ .Values.externalDatabase.database }}?{{ .Values.externalDatabase.params }}
  122. {{- end }}
  123. - name: SPRING_DATASOURCE_USERNAME
  124. {{- if .Values.postgresql.enabled }}
  125. value: {{ .Values.postgresql.postgresqlUsername }}
  126. {{- else }}
  127. value: {{ .Values.externalDatabase.username | quote }}
  128. {{- end }}
  129. - name: SPRING_DATASOURCE_PASSWORD
  130. valueFrom:
  131. secretKeyRef:
  132. {{- if .Values.postgresql.enabled }}
  133. name: {{ template "dolphinscheduler.postgresql.fullname" . }}
  134. key: postgresql-password
  135. {{- else }}
  136. name: {{ include "dolphinscheduler.fullname" . }}-externaldb
  137. key: database-password
  138. {{- end }}
  139. {{- end -}}
  140. {{/*
  141. Wait for database to be ready.
  142. */}}
  143. {{- define "dolphinscheduler.database.wait-for-ready" -}}
  144. - name: wait-for-database
  145. image: busybox:1.30
  146. imagePullPolicy: IfNotPresent
  147. {{- if .Values.postgresql.enabled }}
  148. 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']
  149. {{- else }}
  150. 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']
  151. {{- end }}
  152. {{- end -}}
  153. {{/*
  154. Create a registry environment variables.
  155. */}}
  156. {{- define "dolphinscheduler.registry.env_vars" -}}
  157. - name: REGISTRY_TYPE
  158. {{- if .Values.zookeeper.enabled }}
  159. value: "zookeeper"
  160. {{- else }}
  161. value: {{ .Values.externalRegistry.registryPluginName }}
  162. {{- end }}
  163. - name: REGISTRY_ZOOKEEPER_CONNECT_STRING
  164. {{- if .Values.zookeeper.enabled }}
  165. value: {{ template "dolphinscheduler.zookeeper.quorum" . }}
  166. {{- else }}
  167. value: {{ .Values.externalRegistry.registryServers }}
  168. {{- end }}
  169. {{- end -}}
  170. {{/*
  171. Create a sharedStoragePersistence volume.
  172. */}}
  173. {{- define "dolphinscheduler.sharedStorage.volume" -}}
  174. {{- if .Values.common.sharedStoragePersistence.enabled -}}
  175. - name: {{ include "dolphinscheduler.fullname" . }}-shared
  176. persistentVolumeClaim:
  177. claimName: {{ include "dolphinscheduler.fullname" . }}-shared
  178. {{- end -}}
  179. {{- end -}}
  180. {{/*
  181. Create a sharedStoragePersistence volumeMount.
  182. */}}
  183. {{- define "dolphinscheduler.sharedStorage.volumeMount" -}}
  184. {{- if .Values.common.sharedStoragePersistence.enabled -}}
  185. - mountPath: {{ .Values.common.sharedStoragePersistence.mountPath | quote }}
  186. name: {{ include "dolphinscheduler.fullname" . }}-shared
  187. {{- end -}}
  188. {{- end -}}
  189. {{/*
  190. Create a fsFileResourcePersistence volume.
  191. */}}
  192. {{- define "dolphinscheduler.fsFileResource.volume" -}}
  193. {{- if .Values.common.fsFileResourcePersistence.enabled -}}
  194. - name: {{ include "dolphinscheduler.fullname" . }}-fs-file
  195. persistentVolumeClaim:
  196. claimName: {{ include "dolphinscheduler.fullname" . }}-fs-file
  197. {{- end -}}
  198. {{- end -}}
  199. {{/*
  200. Create a fsFileResourcePersistence volumeMount.
  201. */}}
  202. {{- define "dolphinscheduler.fsFileResource.volumeMount" -}}
  203. {{- if .Values.common.fsFileResourcePersistence.enabled -}}
  204. - mountPath: {{ default "/dolphinscheduler" .Values.common.configmap.RESOURCE_UPLOAD_PATH | quote }}
  205. name: {{ include "dolphinscheduler.fullname" . }}-fs-file
  206. {{- end -}}
  207. {{- end -}}