_helpers.tpl 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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 }}/{{ .Values.image.master }}:{{ .Values.image.tag | default .Chart.AppVersion -}}
  31. {{- end -}}
  32. {{- define "dolphinscheduler.image.fullname.worker" -}}
  33. {{- .Values.image.registry }}/{{ .Values.image.worker }}:{{ .Values.image.tag | default .Chart.AppVersion -}}
  34. {{- end -}}
  35. {{- define "dolphinscheduler.image.fullname.api" -}}
  36. {{- .Values.image.registry }}/{{ .Values.image.api }}:{{ .Values.image.tag | default .Chart.AppVersion -}}
  37. {{- end -}}
  38. {{- define "dolphinscheduler.image.fullname.alert" -}}
  39. {{- .Values.image.registry }}/{{ .Values.image.alert }}:{{ .Values.image.tag | default .Chart.AppVersion -}}
  40. {{- end -}}
  41. {{- define "dolphinscheduler.image.fullname.tools" -}}
  42. {{- .Values.image.registry }}/{{ .Values.image.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 mysql 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.mysql.fullname" -}}
  97. {{- $name := default "mysql" .Values.mysql.nameOverride -}}
  98. {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
  99. {{- end -}}
  100. {{/*
  101. Create a default fully qualified zookeeper name.
  102. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
  103. */}}
  104. {{- define "dolphinscheduler.zookeeper.fullname" -}}
  105. {{- $name := default "zookeeper" .Values.zookeeper.nameOverride -}}
  106. {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
  107. {{- end -}}
  108. {{/*
  109. Create a default fully qualified minio name.
  110. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
  111. */}}
  112. {{- define "dolphinscheduler.minio.fullname" -}}
  113. {{- $name := default "minio" .Values.minio.nameOverride -}}
  114. {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
  115. {{- end -}}
  116. {{/*
  117. Create a default fully qualified zookkeeper quorum.
  118. */}}
  119. {{- define "dolphinscheduler.zookeeper.quorum" -}}
  120. {{- $port := default "2181" .Values.zookeeper.service.port | toString -}}
  121. {{- printf "%s:%s" (include "dolphinscheduler.zookeeper.fullname" .) $port -}}
  122. {{- end -}}
  123. {{/*
  124. Create a database environment variables.
  125. */}}
  126. {{- define "dolphinscheduler.database.env_vars" -}}
  127. - name: DATABASE
  128. {{- if .Values.postgresql.enabled }}
  129. value: "postgresql"
  130. {{- else if .Values.mysql.enabled }}
  131. value: "mysql"
  132. {{- else }}
  133. value: {{ .Values.externalDatabase.type | quote }}
  134. {{- end }}
  135. - name: SPRING_DATASOURCE_URL
  136. {{- if .Values.postgresql.enabled }}
  137. value: jdbc:postgresql://{{ template "dolphinscheduler.postgresql.fullname" . }}:5432/{{ .Values.postgresql.postgresqlDatabase }}?{{ .Values.postgresql.params }}
  138. {{- else if .Values.mysql.enabled }}
  139. value: jdbc:mysql://{{ template "dolphinscheduler.mysql.fullname" . }}:3306/{{ .Values.mysql.auth.database }}?{{ .Values.mysql.auth.params }}
  140. {{- else }}
  141. value: jdbc:{{ .Values.externalDatabase.type }}://{{ .Values.externalDatabase.host }}:{{ .Values.externalDatabase.port }}/{{ .Values.externalDatabase.database }}?{{ .Values.externalDatabase.params }}
  142. {{- end }}
  143. - name: SPRING_DATASOURCE_USERNAME
  144. {{- if .Values.postgresql.enabled }}
  145. value: {{ .Values.postgresql.postgresqlUsername }}
  146. {{- else if .Values.mysql.enabled }}
  147. value: {{ .Values.mysql.auth.username }}
  148. {{- else }}
  149. value: {{ .Values.externalDatabase.username | quote }}
  150. {{- end }}
  151. - name: SPRING_DATASOURCE_PASSWORD
  152. valueFrom:
  153. secretKeyRef:
  154. {{- if .Values.postgresql.enabled }}
  155. name: {{ template "dolphinscheduler.postgresql.fullname" . }}
  156. key: postgresql-password
  157. {{- else if .Values.mysql.enabled }}
  158. name: {{ template "dolphinscheduler.mysql.fullname" . }}
  159. key: mysql-password
  160. {{- else }}
  161. name: {{ include "dolphinscheduler.fullname" . }}-externaldb
  162. key: database-password
  163. {{- end }}
  164. {{- end -}}
  165. {{/*
  166. Create a security environment variables.
  167. */}}
  168. {{- define "dolphinscheduler.security.env_vars" -}}
  169. - name: SECURITY_AUTHENTICATION_TYPE
  170. value: {{ .Values.security.authentication.type | quote }}
  171. {{- if eq .Values.security.authentication.type "LDAP" }}
  172. - name: SECURITY_AUTHENTICATION_LDAP_URLS
  173. value: {{ .Values.security.authentication.ldap.urls | quote }}
  174. - name: SECURITY_AUTHENTICATION_LDAP_BASE_DN
  175. value: {{ .Values.security.authentication.ldap.basedn | quote }}
  176. - name: SECURITY_AUTHENTICATION_LDAP_USERNAME
  177. value: {{ .Values.security.authentication.ldap.username | quote }}
  178. - name: SECURITY_AUTHENTICATION_LDAP_PASSWORD
  179. value: {{ .Values.security.authentication.ldap.password | quote }}
  180. - name: SECURITY_AUTHENTICATION_LDAP_USER_ADMIN
  181. value: {{ .Values.security.authentication.ldap.user.admin | quote }}
  182. - name: SECURITY_AUTHENTICATION_LDAP_USER_IDENTITY_ATTRIBUTE
  183. value: {{ .Values.security.authentication.ldap.user.identityattribute | quote }}
  184. - name: SECURITY_AUTHENTICATION_LDAP_USER_EMAIL_ATTRIBUTE
  185. value: {{ .Values.security.authentication.ldap.user.emailattribute | quote }}
  186. - name: SECURITY_AUTHENTICATION_LDAP_USER_NOT_EXIST_ACTION
  187. value: {{ .Values.security.authentication.ldap.user.notexistaction | quote }}
  188. - name: SECURITY_AUTHENTICATION_LDAP_SSL_ENABLE
  189. value: {{ .Values.security.authentication.ldap.ssl.enable | quote }}
  190. - name: SECURITY_AUTHENTICATION_LDAP_SSL_TRUST_STORE
  191. value: {{ .Values.security.authentication.ldap.ssl.truststore | quote }}
  192. - name: SECURITY_AUTHENTICATION_LDAP_SSL_TRUST_STORE_PASSWORD
  193. value: {{ .Values.security.authentication.ldap.ssl.truststorepassword | quote }}
  194. {{- end }}
  195. {{- end -}}
  196. {{/*
  197. Wait for database to be ready.
  198. */}}
  199. {{- define "dolphinscheduler.database.wait-for-ready" -}}
  200. - name: wait-for-database
  201. image: {{ .Values.initImage.busybox }}
  202. imagePullPolicy: {{ .Values.initImage.pullPolicy }}
  203. {{- if .Values.postgresql.enabled }}
  204. 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']
  205. {{- else if .Values.mysql.enabled }}
  206. command: ['sh', '-xc', 'for i in $(seq 1 180); do nc -z -w3 {{ template "dolphinscheduler.mysql.fullname" . }} 3306 && exit 0 || sleep 5; done; exit 1']
  207. {{- else }}
  208. 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']
  209. {{- end }}
  210. {{- end -}}
  211. {{/*
  212. Wait for minio to be ready.
  213. */}}
  214. {{- define "dolphinscheduler.minio.wait-for-ready" -}}
  215. {{- if .Values.minio.enabled }}
  216. - name: wait-for-minio
  217. image: {{ .Values.initImage.busybox }}
  218. imagePullPolicy: {{ .Values.initImage.pullPolicy }}
  219. command: ['sh', '-xc', 'for i in $(seq 1 180); do nc -z -w3 {{ template "dolphinscheduler.minio.fullname" . }} 9000 && exit 0 || sleep 5; done; exit 1']
  220. {{- end }}
  221. {{- end -}}
  222. {{/*
  223. Create a registry environment variables.
  224. */}}
  225. {{- define "dolphinscheduler.registry.env_vars" -}}
  226. - name: REGISTRY_TYPE
  227. {{- if .Values.zookeeper.enabled }}
  228. value: "zookeeper"
  229. {{- else if .Values.etcd.enabled }}
  230. value: "etcd"
  231. {{- else }}
  232. value: {{ .Values.externalRegistry.registryPluginName }}
  233. {{- end }}
  234. {{- if .Values.etcd.enabled }}
  235. - name: REGISTRY_ENDPOINTS
  236. value: {{ .Values.etcd.endpoints }}
  237. - name: REGISTRY_NAMESPACE
  238. value: {{ .Values.etcd.namespace }}
  239. - name: REGISTRY_USER
  240. value: {{ .Values.etcd.user }}
  241. - name: REGISTRY_PASSWORD
  242. value: {{ .Values.etcd.passWord }}
  243. - name: REGISTRY_AUTHORITY
  244. value: {{ .Values.etcd.authority }}
  245. - name: REGISTRY_CERT_FILE
  246. value: {{ .Values.etcd.ssl.certFile }}
  247. - name: REGISTRY_KEY_CERT_CHAIN_FILE
  248. value: {{ .Values.etcd.ssl.keyCertChainFile }}
  249. - name: REGISTRY_KEY_FILE
  250. value: {{ .Values.etcd.ssl.keyFile }}
  251. {{- else }}
  252. - name: REGISTRY_ZOOKEEPER_CONNECT_STRING
  253. {{- if .Values.zookeeper.enabled }}
  254. value: {{ template "dolphinscheduler.zookeeper.quorum" . }}
  255. {{- else }}
  256. value: {{ .Values.externalRegistry.registryServers }}
  257. {{- end }}
  258. {{- end }}
  259. {{- end -}}
  260. {{/*
  261. Create a sharedStoragePersistence volume.
  262. */}}
  263. {{- define "dolphinscheduler.sharedStorage.volume" -}}
  264. {{- if .Values.common.sharedStoragePersistence.enabled -}}
  265. - name: {{ include "dolphinscheduler.fullname" . }}-shared
  266. persistentVolumeClaim:
  267. claimName: {{ include "dolphinscheduler.fullname" . }}-shared
  268. {{- end -}}
  269. {{- end -}}
  270. {{/*
  271. Create a sharedStoragePersistence volumeMount.
  272. */}}
  273. {{- define "dolphinscheduler.sharedStorage.volumeMount" -}}
  274. {{- if .Values.common.sharedStoragePersistence.enabled -}}
  275. - mountPath: {{ .Values.common.sharedStoragePersistence.mountPath | quote }}
  276. name: {{ include "dolphinscheduler.fullname" . }}-shared
  277. {{- end -}}
  278. {{- end -}}
  279. {{/*
  280. Create a fsFileResourcePersistence volume.
  281. */}}
  282. {{- define "dolphinscheduler.fsFileResource.volume" -}}
  283. {{- if .Values.common.fsFileResourcePersistence.enabled -}}
  284. - name: {{ include "dolphinscheduler.fullname" . }}-fs-file
  285. persistentVolumeClaim:
  286. claimName: {{ include "dolphinscheduler.fullname" . }}-fs-file
  287. {{- end -}}
  288. {{- end -}}
  289. {{/*
  290. Create a fsFileResourcePersistence volumeMount.
  291. */}}
  292. {{- define "dolphinscheduler.fsFileResource.volumeMount" -}}
  293. {{- if .Values.common.fsFileResourcePersistence.enabled -}}
  294. - mountPath: {{ default "/dolphinscheduler" .Values.common.configmap.RESOURCE_UPLOAD_PATH | quote }}
  295. name: {{ include "dolphinscheduler.fullname" . }}-fs-file
  296. {{- end -}}
  297. {{- end -}}
  298. {{/*
  299. Create a etcd ssl volume.
  300. */}}
  301. {{- define "dolphinscheduler.etcd.ssl.volume" -}}
  302. {{- if .Values.etcd.ssl.enabled -}}
  303. - name: etcd-ssl
  304. secret:
  305. secretName: {{ include "dolphinscheduler.fullname" . }}-etcd-ssl
  306. {{- end -}}
  307. {{- end -}}
  308. {{/*
  309. Create a etcd ssl volumeMount.
  310. */}}
  311. {{- define "dolphinscheduler.etcd.ssl.volumeMount" -}}
  312. {{- if .Values.etcd.ssl.enabled -}}
  313. - mountPath: /opt/dolphinscheduler/{{ .Values.etcd.ssl.certFile }}
  314. name: etcd-ssl
  315. subPath: cert-file
  316. - mountPath: /opt/dolphinscheduler/{{ .Values.etcd.ssl.keyCertChainFile }}
  317. name: etcd-ssl
  318. subPath: key-cert-chain-file
  319. - mountPath: /opt/dolphinscheduler/{{ .Values.etcd.ssl.keyFile }}
  320. name: etcd-ssl
  321. subPath: key-file
  322. {{- end -}}
  323. {{- end -}}
  324. {{/*
  325. Create a ldap ssl volume.
  326. */}}
  327. {{- define "dolphinscheduler.ldap.ssl.volume" -}}
  328. {{- if .Values.security.authentication.ldap.ssl.enable -}}
  329. - name: jks-file
  330. secret:
  331. secretName: {{ include "dolphinscheduler.fullname" . }}-ldap-ssl
  332. {{- end -}}
  333. {{- end -}}
  334. {{/*
  335. Create a ldap ssl volumeMount.
  336. */}}
  337. {{- define "dolphinscheduler.ldap.ssl.volumeMount" -}}
  338. {{- if .Values.security.authentication.ldap.ssl.enable -}}
  339. - mountPath: {{ .Values.security.authentication.ldap.ssl.truststore }}
  340. name: jks-file
  341. subPath: jks-file
  342. {{- end -}}
  343. {{- end -}}