statefulset-dolphinscheduler-master.yaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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. apiVersion: apps/v1
  18. kind: StatefulSet
  19. metadata:
  20. name: {{ include "dolphinscheduler.fullname" . }}-master
  21. labels:
  22. app.kubernetes.io/name: {{ include "dolphinscheduler.fullname" . }}-master
  23. app.kubernetes.io/instance: {{ .Release.Name }}
  24. app.kubernetes.io/managed-by: {{ .Release.Service }}
  25. app.kubernetes.io/component: master
  26. spec:
  27. podManagementPolicy: {{ .Values.master.podManagementPolicy }}
  28. replicas: {{ .Values.master.replicas }}
  29. selector:
  30. matchLabels:
  31. app.kubernetes.io/name: {{ include "dolphinscheduler.fullname" . }}-master
  32. app.kubernetes.io/instance: {{ .Release.Name }}
  33. app.kubernetes.io/managed-by: {{ .Release.Service }}
  34. app.kubernetes.io/component: master
  35. serviceName: {{ template "dolphinscheduler.fullname" . }}-master-headless
  36. template:
  37. metadata:
  38. labels:
  39. app.kubernetes.io/name: {{ include "dolphinscheduler.fullname" . }}-master
  40. app.kubernetes.io/instance: {{ .Release.Name }}
  41. app.kubernetes.io/managed-by: {{ .Release.Service }}
  42. app.kubernetes.io/component: master
  43. spec:
  44. {{- if .Values.master.affinity }}
  45. affinity: {{- toYaml .Values.master.affinity | nindent 8 }}
  46. {{- end }}
  47. {{- if .Values.master.nodeSelector }}
  48. nodeSelector: {{- toYaml .Values.master.nodeSelector | nindent 8 }}
  49. {{- end }}
  50. {{- if .Values.master.tolerations }}
  51. tolerations: {{- toYaml . | nindent 8 }}
  52. {{- end }}
  53. initContainers:
  54. - name: init-zookeeper
  55. image: busybox:1.31.0
  56. command:
  57. - /bin/sh
  58. - -ec
  59. - |
  60. echo "${ZOOKEEPER_QUORUM}" | awk -F ',' 'BEGIN{ i=1 }{ while( i <= NF ){ print $i; i++ } }' | while read line; do
  61. while ! nc -z ${line%:*} ${line#*:}; do
  62. counter=$((counter+1))
  63. if [ $counter == 5 ]; then
  64. echo "Error: Couldn't connect to zookeeper."
  65. exit 1
  66. fi
  67. echo "Trying to connect to zookeeper at ${line}. Attempt $counter."
  68. sleep 60
  69. done
  70. done
  71. env:
  72. - name: ZOOKEEPER_QUORUM
  73. {{- if .Values.zookeeper.enabled }}
  74. value: "{{ template "dolphinscheduler.zookeeper.quorum" . }}"
  75. {{- else }}
  76. value: {{ .Values.externalZookeeper.zookeeperQuorum }}
  77. {{- end }}
  78. - name: init-postgresql
  79. image: busybox:1.31.0
  80. command:
  81. - /bin/sh
  82. - -ec
  83. - |
  84. while ! nc -z ${POSTGRESQL_HOST} ${POSTGRESQL_PORT}; do
  85. counter=$((counter+1))
  86. if [ $counter == 5 ]; then
  87. echo "Error: Couldn't connect to postgresql."
  88. exit 1
  89. fi
  90. echo "Trying to connect to postgresql at ${POSTGRESQL_HOST}:${POSTGRESQL_PORT}. Attempt $counter."
  91. sleep 60
  92. done
  93. env:
  94. - name: POSTGRESQL_HOST
  95. {{- if .Values.postgresql.enabled }}
  96. value: {{ template "dolphinscheduler.postgresql.fullname" . }}
  97. {{- else }}
  98. value: {{ .Values.externalDatabase.host | quote }}
  99. {{- end }}
  100. - name: POSTGRESQL_PORT
  101. {{- if .Values.postgresql.enabled }}
  102. value: "5432"
  103. {{- else }}
  104. value: {{ .Values.externalDatabase.port }}
  105. {{- end }}
  106. containers:
  107. - name: {{ include "dolphinscheduler.fullname" . }}-master
  108. image: {{ include "dolphinscheduler.image.repository" . | quote }}
  109. args:
  110. - "master-server"
  111. ports:
  112. - containerPort: 8888
  113. name: unused-tcp-port
  114. imagePullPolicy: {{ .Values.image.pullPolicy }}
  115. env:
  116. - name: TZ
  117. value: {{ .Values.timezone }}
  118. - name: MASTER_EXEC_THREADS
  119. valueFrom:
  120. configMapKeyRef:
  121. name: {{ include "dolphinscheduler.fullname" . }}-master
  122. key: MASTER_EXEC_THREADS
  123. - name: MASTER_EXEC_TASK_NUM
  124. valueFrom:
  125. configMapKeyRef:
  126. name: {{ include "dolphinscheduler.fullname" . }}-master
  127. key: MASTER_EXEC_TASK_NUM
  128. - name: MASTER_HEARTBEAT_INTERVAL
  129. valueFrom:
  130. configMapKeyRef:
  131. name: {{ include "dolphinscheduler.fullname" . }}-master
  132. key: MASTER_HEARTBEAT_INTERVAL
  133. - name: MASTER_TASK_COMMIT_RETRYTIMES
  134. valueFrom:
  135. configMapKeyRef:
  136. name: {{ include "dolphinscheduler.fullname" . }}-master
  137. key: MASTER_TASK_COMMIT_RETRYTIMES
  138. - name: MASTER_TASK_COMMIT_INTERVAL
  139. valueFrom:
  140. configMapKeyRef:
  141. name: {{ include "dolphinscheduler.fullname" . }}-master
  142. key: MASTER_TASK_COMMIT_INTERVAL
  143. - name: MASTER_MAX_CPULOAD_AVG
  144. valueFrom:
  145. configMapKeyRef:
  146. name: {{ include "dolphinscheduler.fullname" . }}-master
  147. key: MASTER_MAX_CPULOAD_AVG
  148. - name: MASTER_RESERVED_MEMORY
  149. valueFrom:
  150. configMapKeyRef:
  151. name: {{ include "dolphinscheduler.fullname" . }}-master
  152. key: MASTER_RESERVED_MEMORY
  153. - name: DOLPHINSCHEDULER_DATA_BASEDIR_PATH
  154. valueFrom:
  155. configMapKeyRef:
  156. name: {{ include "dolphinscheduler.fullname" . }}-worker
  157. key: DOLPHINSCHEDULER_DATA_BASEDIR_PATH
  158. - name: DOLPHINSCHEDULER_DATA_DOWNLOAD_BASEDIR_PATH
  159. valueFrom:
  160. configMapKeyRef:
  161. name: {{ include "dolphinscheduler.fullname" . }}-worker
  162. key: DOLPHINSCHEDULER_DATA_DOWNLOAD_BASEDIR_PATH
  163. - name: DOLPHINSCHEDULER_PROCESS_EXEC_BASEPATH
  164. valueFrom:
  165. configMapKeyRef:
  166. name: {{ include "dolphinscheduler.fullname" . }}-worker
  167. key: DOLPHINSCHEDULER_PROCESS_EXEC_BASEPATH
  168. - name: POSTGRESQL_HOST
  169. {{- if .Values.postgresql.enabled }}
  170. value: {{ template "dolphinscheduler.postgresql.fullname" . }}
  171. {{- else }}
  172. value: {{ .Values.externalDatabase.host | quote }}
  173. {{- end }}
  174. - name: POSTGRESQL_PORT
  175. {{- if .Values.postgresql.enabled }}
  176. value: "5432"
  177. {{- else }}
  178. value: {{ .Values.externalDatabase.port }}
  179. {{- end }}
  180. - name: POSTGRESQL_USERNAME
  181. {{- if .Values.postgresql.enabled }}
  182. value: {{ .Values.postgresql.postgresqlUsername }}
  183. {{- else }}
  184. value: {{ .Values.externalDatabase.username | quote }}
  185. {{- end }}
  186. - name: POSTGRESQL_PASSWORD
  187. valueFrom:
  188. secretKeyRef:
  189. {{- if .Values.postgresql.enabled }}
  190. name: {{ template "dolphinscheduler.postgresql.fullname" . }}
  191. key: postgresql-password
  192. {{- else }}
  193. name: {{ printf "%s-%s" .Release.Name "externaldb" }}
  194. key: db-password
  195. {{- end }}
  196. - name: TASK_QUEUE
  197. {{- if .Values.zookeeper.enabled }}
  198. value: {{ .Values.zookeeper.taskQueue }}
  199. {{- else }}
  200. value: {{ .Values.externalZookeeper.taskQueue }}
  201. {{- end }}
  202. - name: ZOOKEEPER_QUORUM
  203. {{- if .Values.zookeeper.enabled }}
  204. value: {{ template "dolphinscheduler.zookeeper.quorum" . }}
  205. {{- else }}
  206. value: {{ .Values.externalZookeeper.zookeeperQuorum }}
  207. {{- end }}
  208. {{- if .Values.master.livenessProbe.enabled }}
  209. livenessProbe:
  210. exec:
  211. command:
  212. - sh
  213. - /root/checkpoint.sh
  214. - master-server
  215. initialDelaySeconds: {{ .Values.master.livenessProbe.initialDelaySeconds }}
  216. periodSeconds: {{ .Values.master.livenessProbe.periodSeconds }}
  217. timeoutSeconds: {{ .Values.master.livenessProbe.timeoutSeconds }}
  218. successThreshold: {{ .Values.master.livenessProbe.successThreshold }}
  219. failureThreshold: {{ .Values.master.livenessProbe.failureThreshold }}
  220. {{- end }}
  221. {{- if .Values.master.readinessProbe.enabled }}
  222. readinessProbe:
  223. exec:
  224. command:
  225. - sh
  226. - /root/checkpoint.sh
  227. - master-server
  228. initialDelaySeconds: {{ .Values.master.readinessProbe.initialDelaySeconds }}
  229. periodSeconds: {{ .Values.master.readinessProbe.periodSeconds }}
  230. timeoutSeconds: {{ .Values.master.readinessProbe.timeoutSeconds }}
  231. successThreshold: {{ .Values.master.readinessProbe.successThreshold }}
  232. failureThreshold: {{ .Values.master.readinessProbe.failureThreshold }}
  233. {{- end }}
  234. volumeMounts:
  235. - mountPath: "/opt/dolphinscheduler/logs"
  236. name: {{ include "dolphinscheduler.fullname" . }}-master
  237. volumes:
  238. - name: {{ include "dolphinscheduler.fullname" . }}-master
  239. {{- if .Values.master.persistentVolumeClaim.enabled }}
  240. persistentVolumeClaim:
  241. claimName: {{ include "dolphinscheduler.fullname" . }}-master
  242. {{- else }}
  243. emptyDir: {}
  244. {{- end }}
  245. {{- if .Values.master.persistentVolumeClaim.enabled }}
  246. volumeClaimTemplates:
  247. - metadata:
  248. name: {{ include "dolphinscheduler.fullname" . }}-master
  249. labels:
  250. app.kubernetes.io/name: {{ include "dolphinscheduler.fullname" . }}-master
  251. app.kubernetes.io/instance: {{ .Release.Name }}
  252. app.kubernetes.io/managed-by: {{ .Release.Service }}
  253. spec:
  254. accessModes:
  255. {{- range .Values.master.persistentVolumeClaim.accessModes }}
  256. - {{ . | quote }}
  257. {{- end }}
  258. storageClassName: {{ .Values.master.persistentVolumeClaim.storageClassName | quote }}
  259. resources:
  260. requests:
  261. storage: {{ .Values.master.persistentVolumeClaim.storage | quote }}
  262. {{- end }}