deployment-dolphinscheduler-api.yaml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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: Deployment
  19. metadata:
  20. name: {{ include "dolphinscheduler.fullname" . }}-api
  21. labels:
  22. app.kubernetes.io/name: {{ include "dolphinscheduler.fullname" . }}-api
  23. app.kubernetes.io/instance: {{ .Release.Name }}
  24. app.kubernetes.io/managed-by: {{ .Release.Service }}
  25. app.kubernetes.io/component: api
  26. spec:
  27. replicas: {{ .Values.api.replicas }}
  28. selector:
  29. matchLabels:
  30. app.kubernetes.io/name: {{ include "dolphinscheduler.fullname" . }}-api
  31. app.kubernetes.io/instance: {{ .Release.Name }}
  32. app.kubernetes.io/managed-by: {{ .Release.Service }}
  33. app.kubernetes.io/component: api
  34. strategy:
  35. type: {{ .Values.api.strategy.type | quote }}
  36. rollingUpdate:
  37. maxSurge: {{ .Values.api.strategy.rollingUpdate.maxSurge | quote }}
  38. maxUnavailable: {{ .Values.api.strategy.rollingUpdate.maxUnavailable | quote }}
  39. template:
  40. metadata:
  41. labels:
  42. app.kubernetes.io/name: {{ include "dolphinscheduler.fullname" . }}-api
  43. app.kubernetes.io/instance: {{ .Release.Name }}
  44. app.kubernetes.io/managed-by: {{ .Release.Service }}
  45. app.kubernetes.io/component: api
  46. spec:
  47. {{- if .Values.api.affinity }}
  48. affinity: {{- toYaml .Values.api.affinity | nindent 8 }}
  49. {{- end }}
  50. {{- if .Values.api.nodeSelector }}
  51. nodeSelector: {{- toYaml .Values.api.nodeSelector | nindent 8 }}
  52. {{- end }}
  53. {{- if .Values.api.tolerations }}
  54. tolerations: {{- toYaml . | nindent 8 }}
  55. {{- end }}
  56. initContainers:
  57. - name: init-postgresql
  58. image: busybox:1.31.0
  59. command:
  60. - /bin/sh
  61. - -ec
  62. - |
  63. while ! nc -z ${POSTGRESQL_HOST} ${POSTGRESQL_PORT}; do
  64. counter=$((counter+1))
  65. if [ $counter == 5 ]; then
  66. echo "Error: Couldn't connect to postgresql."
  67. exit 1
  68. fi
  69. echo "Trying to connect to postgresql at ${POSTGRESQL_HOST}:${POSTGRESQL_PORT}. Attempt $counter."
  70. sleep 60
  71. done
  72. env:
  73. - name: POSTGRESQL_HOST
  74. {{- if .Values.postgresql.enabled }}
  75. value: {{ template "dolphinscheduler.postgresql.fullname" . }}
  76. {{- else }}
  77. value: {{ .Values.externalDatabase.host | quote }}
  78. {{- end }}
  79. - name: POSTGRESQL_PORT
  80. {{- if .Values.postgresql.enabled }}
  81. value: "5432"
  82. {{- else }}
  83. value: {{ .Values.externalDatabase.port }}
  84. {{- end }}
  85. containers:
  86. - name: {{ include "dolphinscheduler.fullname" . }}-api
  87. image: {{ include "dolphinscheduler.image.repository" . | quote }}
  88. args:
  89. - "api-server"
  90. ports:
  91. - containerPort: 12345
  92. name: tcp-port
  93. imagePullPolicy: {{ .Values.image.pullPolicy }}
  94. env:
  95. - name: TZ
  96. value: {{ .Values.timezone }}
  97. - name: POSTGRESQL_HOST
  98. {{- if .Values.postgresql.enabled }}
  99. value: {{ template "dolphinscheduler.postgresql.fullname" . }}
  100. {{- else }}
  101. value: {{ .Values.externalDatabase.host | quote }}
  102. {{- end }}
  103. - name: POSTGRESQL_PORT
  104. {{- if .Values.postgresql.enabled }}
  105. value: "5432"
  106. {{- else }}
  107. value: {{ .Values.externalDatabase.port }}
  108. {{- end }}
  109. - name: POSTGRESQL_USERNAME
  110. {{- if .Values.postgresql.enabled }}
  111. value: {{ .Values.postgresql.postgresqlUsername }}
  112. {{- else }}
  113. value: {{ .Values.externalDatabase.username | quote }}
  114. {{- end }}
  115. - name: POSTGRESQL_PASSWORD
  116. valueFrom:
  117. secretKeyRef:
  118. {{- if .Values.postgresql.enabled }}
  119. name: {{ template "dolphinscheduler.postgresql.fullname" . }}
  120. key: postgresql-password
  121. {{- else }}
  122. name: {{ printf "%s-%s" .Release.Name "externaldb" }}
  123. key: db-password
  124. {{- end }}
  125. - name: ZOOKEEPER_QUORUM
  126. {{- if .Values.zookeeper.enabled }}
  127. value: "{{ template "dolphinscheduler.zookeeper.quorum" . }}"
  128. {{- else }}
  129. value: {{ .Values.externalZookeeper.zookeeperQuorum }}
  130. {{- end }}
  131. {{- if .Values.api.livenessProbe.enabled }}
  132. livenessProbe:
  133. tcpSocket:
  134. port: 12345
  135. initialDelaySeconds: {{ .Values.api.livenessProbe.initialDelaySeconds }}
  136. periodSeconds: {{ .Values.api.livenessProbe.periodSeconds }}
  137. timeoutSeconds: {{ .Values.api.livenessProbe.timeoutSeconds }}
  138. successThreshold: {{ .Values.api.livenessProbe.successThreshold }}
  139. failureThreshold: {{ .Values.api.livenessProbe.failureThreshold }}
  140. {{- end }}
  141. {{- if .Values.api.readinessProbe.enabled }}
  142. readinessProbe:
  143. tcpSocket:
  144. port: 12345
  145. initialDelaySeconds: {{ .Values.api.readinessProbe.initialDelaySeconds }}
  146. periodSeconds: {{ .Values.api.readinessProbe.periodSeconds }}
  147. timeoutSeconds: {{ .Values.api.readinessProbe.timeoutSeconds }}
  148. successThreshold: {{ .Values.api.readinessProbe.successThreshold }}
  149. failureThreshold: {{ .Values.api.readinessProbe.failureThreshold }}
  150. {{- end }}
  151. volumeMounts:
  152. - mountPath: "/opt/dolphinscheduler/logs"
  153. name: {{ include "dolphinscheduler.fullname" . }}-api
  154. volumes:
  155. - name: {{ include "dolphinscheduler.fullname" . }}-api
  156. {{- if .Values.api.persistentVolumeClaim.enabled }}
  157. persistentVolumeClaim:
  158. claimName: {{ include "dolphinscheduler.fullname" . }}-api
  159. {{- else }}
  160. emptyDir: {}
  161. {{- end }}