s3-deployment.yaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. {{- if .Values.s3.enabled }}
  2. apiVersion: apps/v1
  3. kind: Deployment
  4. metadata:
  5. name: {{ template "seaweedfs.name" . }}-s3
  6. namespace: {{ .Release.Namespace }}
  7. labels:
  8. app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
  9. helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
  10. app.kubernetes.io/managed-by: {{ .Release.Service }}
  11. app.kubernetes.io/instance: {{ .Release.Name }}
  12. app.kubernetes.io/component: s3
  13. {{- if .Values.s3.annotations }}
  14. annotations:
  15. {{- toYaml .Values.s3.annotations | nindent 4 }}
  16. {{- end }}
  17. spec:
  18. replicas: {{ .Values.s3.replicas }}
  19. selector:
  20. matchLabels:
  21. app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
  22. app.kubernetes.io/instance: {{ .Release.Name }}
  23. app.kubernetes.io/component: s3
  24. template:
  25. metadata:
  26. labels:
  27. app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
  28. helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
  29. app.kubernetes.io/instance: {{ .Release.Name }}
  30. app.kubernetes.io/component: s3
  31. {{ with .Values.podLabels }}
  32. {{- toYaml . | nindent 8 }}
  33. {{- end }}
  34. {{- with .Values.s3.podLabels }}
  35. {{- toYaml . | nindent 8 }}
  36. {{- end }}
  37. annotations:
  38. {{ with .Values.podAnnotations }}
  39. {{- toYaml . | nindent 8 }}
  40. {{- end }}
  41. {{- with .Values.s3.podAnnotations }}
  42. {{- toYaml . | nindent 8 }}
  43. {{- end }}
  44. spec:
  45. restartPolicy: {{ default .Values.global.restartPolicy .Values.s3.restartPolicy }}
  46. {{- if .Values.s3.affinity }}
  47. affinity:
  48. {{ tpl .Values.s3.affinity . | nindent 8 | trim }}
  49. {{- end }}
  50. {{- if .Values.s3.topologySpreadConstraints }}
  51. topologySpreadConstraints:
  52. {{ tpl .Values.s3.topologySpreadConstraints . | nindent 8 | trim }}
  53. {{- end }}
  54. {{- if .Values.s3.tolerations }}
  55. tolerations:
  56. {{ tpl .Values.s3.tolerations . | nindent 8 | trim }}
  57. {{- end }}
  58. {{- include "seaweedfs.imagePullSecrets" . | nindent 6 }}
  59. terminationGracePeriodSeconds: 10
  60. {{- if .Values.s3.priorityClassName }}
  61. priorityClassName: {{ .Values.s3.priorityClassName | quote }}
  62. {{- end }}
  63. enableServiceLinks: false
  64. {{- if .Values.s3.serviceAccountName }}
  65. serviceAccountName: {{ .Values.s3.serviceAccountName | quote }}
  66. {{- end }}
  67. {{- if .Values.s3.initContainers }}
  68. initContainers:
  69. {{ tpl .Values.s3.initContainers . | nindent 8 | trim }}
  70. {{- end }}
  71. {{- if .Values.s3.podSecurityContext.enabled }}
  72. securityContext: {{- omit .Values.s3.podSecurityContext "enabled" | toYaml | nindent 8 }}
  73. {{- end }}
  74. containers:
  75. - name: seaweedfs
  76. image: {{ template "s3.image" . }}
  77. imagePullPolicy: {{ default "IfNotPresent" .Values.global.imagePullPolicy }}
  78. env:
  79. - name: POD_IP
  80. valueFrom:
  81. fieldRef:
  82. fieldPath: status.podIP
  83. - name: POD_NAME
  84. valueFrom:
  85. fieldRef:
  86. fieldPath: metadata.name
  87. - name: NAMESPACE
  88. valueFrom:
  89. fieldRef:
  90. fieldPath: metadata.namespace
  91. - name: SEAWEEDFS_FULLNAME
  92. value: "{{ template "seaweedfs.name" . }}"
  93. {{- if .Values.s3.extraEnvironmentVars }}
  94. {{- range $key, $value := .Values.s3.extraEnvironmentVars }}
  95. - name: {{ $key }}
  96. {{- if kindIs "string" $value }}
  97. value: {{ $value | quote }}
  98. {{- else }}
  99. valueFrom:
  100. {{ toYaml $value | nindent 16 | trim }}
  101. {{- end -}}
  102. {{- end }}
  103. {{- end }}
  104. {{- if .Values.global.extraEnvironmentVars }}
  105. {{- range $key, $value := .Values.global.extraEnvironmentVars }}
  106. - name: {{ $key }}
  107. {{- if kindIs "string" $value }}
  108. value: {{ $value | quote }}
  109. {{- else }}
  110. valueFrom:
  111. {{ toYaml $value | nindent 16 | trim }}
  112. {{- end -}}
  113. {{- end }}
  114. {{- end }}
  115. command:
  116. - "/bin/sh"
  117. - "-ec"
  118. - |
  119. exec /usr/bin/weed \
  120. {{- if or (eq .Values.s3.logs.type "hostPath") (eq .Values.s3.logs.type "emptyDir") }}
  121. -logdir=/logs \
  122. {{- else }}
  123. -logtostderr=true \
  124. {{- end }}
  125. {{- if .Values.s3.loggingOverrideLevel }}
  126. -v={{ .Values.s3.loggingOverrideLevel }} \
  127. {{- else }}
  128. -v={{ .Values.global.loggingLevel }} \
  129. {{- end }}
  130. s3 \
  131. -ip.bind={{ .Values.s3.bindAddress }} \
  132. -port={{ .Values.s3.port }} \
  133. {{- if .Values.s3.metricsPort }}
  134. -metricsPort {{ .Values.s3.metricsPort }} \
  135. {{- end }}
  136. {{- if .Values.global.enableSecurity }}
  137. {{- if .Values.s3.httpsPort }}
  138. -port.https={{ .Values.s3.httpsPort }} \
  139. {{- end }}
  140. -cert.file=/usr/local/share/ca-certificates/client/tls.crt \
  141. -key.file=/usr/local/share/ca-certificates/client/tls.key \
  142. {{- end }}
  143. {{- if .Values.s3.domainName }}
  144. -domainName={{ .Values.s3.domainName }} \
  145. {{- end }}
  146. {{- if eq (typeOf .Values.s3.allowEmptyFolder) "bool" }}
  147. -allowEmptyFolder={{ .Values.s3.allowEmptyFolder }} \
  148. {{- end }}
  149. {{- if .Values.s3.enableAuth }}
  150. -config=/etc/sw/seaweedfs_s3_config \
  151. {{- end }}
  152. {{- if .Values.s3.auditLogConfig }}
  153. -auditLogConfig=/etc/sw/s3_auditLogConfig.json \
  154. {{- end }}
  155. -filer={{ template "seaweedfs.name" . }}-filer-client.{{ .Release.Namespace }}:{{ .Values.filer.port }} \
  156. {{- range .Values.s3.extraArgs }}
  157. {{ . }} \
  158. {{- end }}
  159. volumeMounts:
  160. {{- if or (eq .Values.s3.logs.type "hostPath") (eq .Values.s3.logs.type "emptyDir") }}
  161. - name: logs
  162. mountPath: "/logs/"
  163. {{- end }}
  164. {{- if .Values.s3.enableAuth }}
  165. - mountPath: /etc/sw
  166. name: config-users
  167. readOnly: true
  168. {{- end }}
  169. {{- if .Values.global.enableSecurity }}
  170. - name: security-config
  171. readOnly: true
  172. mountPath: /etc/seaweedfs/security.toml
  173. subPath: security.toml
  174. - name: ca-cert
  175. readOnly: true
  176. mountPath: /usr/local/share/ca-certificates/ca/
  177. - name: master-cert
  178. readOnly: true
  179. mountPath: /usr/local/share/ca-certificates/master/
  180. - name: volume-cert
  181. readOnly: true
  182. mountPath: /usr/local/share/ca-certificates/volume/
  183. - name: filer-cert
  184. readOnly: true
  185. mountPath: /usr/local/share/ca-certificates/filer/
  186. - name: client-cert
  187. readOnly: true
  188. mountPath: /usr/local/share/ca-certificates/client/
  189. {{- end }}
  190. {{ tpl .Values.s3.extraVolumeMounts . | nindent 12 | trim }}
  191. ports:
  192. - containerPort: {{ .Values.s3.port }}
  193. name: swfs-s3
  194. {{- if .Values.s3.httpsPort }}
  195. - containerPort: {{ .Values.s3.httpsPort }}
  196. name: swfs-s3-tls
  197. {{- end }}
  198. {{- if .Values.s3.metricsPort }}
  199. - containerPort: {{ .Values.s3.metricsPort }}
  200. name: metrics
  201. {{- end }}
  202. {{- if .Values.s3.readinessProbe.enabled }}
  203. readinessProbe:
  204. httpGet:
  205. path: {{ .Values.s3.readinessProbe.httpGet.path }}
  206. port: {{ .Values.s3.port }}
  207. scheme: {{ .Values.s3.readinessProbe.scheme }}
  208. initialDelaySeconds: {{ .Values.s3.readinessProbe.initialDelaySeconds }}
  209. periodSeconds: {{ .Values.s3.readinessProbe.periodSeconds }}
  210. successThreshold: {{ .Values.s3.readinessProbe.successThreshold }}
  211. failureThreshold: {{ .Values.s3.readinessProbe.failureThreshold }}
  212. timeoutSeconds: {{ .Values.s3.readinessProbe.timeoutSeconds }}
  213. {{- end }}
  214. {{- if .Values.s3.livenessProbe.enabled }}
  215. livenessProbe:
  216. httpGet:
  217. path: {{ .Values.s3.livenessProbe.httpGet.path }}
  218. port: {{ .Values.s3.port }}
  219. scheme: {{ .Values.s3.livenessProbe.scheme }}
  220. initialDelaySeconds: {{ .Values.s3.livenessProbe.initialDelaySeconds }}
  221. periodSeconds: {{ .Values.s3.livenessProbe.periodSeconds }}
  222. successThreshold: {{ .Values.s3.livenessProbe.successThreshold }}
  223. failureThreshold: {{ .Values.s3.livenessProbe.failureThreshold }}
  224. timeoutSeconds: {{ .Values.s3.livenessProbe.timeoutSeconds }}
  225. {{- end }}
  226. {{- with .Values.s3.resources }}
  227. resources:
  228. {{- toYaml . | nindent 12 }}
  229. {{- end }}
  230. {{- if .Values.s3.containerSecurityContext.enabled }}
  231. securityContext: {{- omit .Values.s3.containerSecurityContext "enabled" | toYaml | nindent 12 }}
  232. {{- end }}
  233. {{- if .Values.s3.sidecars }}
  234. {{- include "common.tplvalues.render" (dict "value" .Values.s3.sidecars "context" $) | nindent 8 }}
  235. {{- end }}
  236. volumes:
  237. {{- if .Values.s3.enableAuth }}
  238. - name: config-users
  239. secret:
  240. defaultMode: 420
  241. {{- if .Values.s3.existingConfigSecret }}
  242. secretName: {{ .Values.s3.existingConfigSecret }}
  243. {{- else }}
  244. secretName: seaweedfs-s3-secret
  245. {{- end }}
  246. {{- end }}
  247. {{- if eq .Values.s3.logs.type "hostPath" }}
  248. - name: logs
  249. hostPath:
  250. path: {{ .Values.s3.logs.hostPathPrefix }}/logs/seaweedfs/s3
  251. type: DirectoryOrCreate
  252. {{- end }}
  253. {{- if eq .Values.s3.logs.type "emptyDir" }}
  254. - name: logs
  255. emptyDir: {}
  256. {{- end }}
  257. {{- if .Values.global.enableSecurity }}
  258. - name: security-config
  259. configMap:
  260. name: {{ template "seaweedfs.name" . }}-security-config
  261. - name: ca-cert
  262. secret:
  263. secretName: {{ template "seaweedfs.name" . }}-ca-cert
  264. - name: master-cert
  265. secret:
  266. secretName: {{ template "seaweedfs.name" . }}-master-cert
  267. - name: volume-cert
  268. secret:
  269. secretName: {{ template "seaweedfs.name" . }}-volume-cert
  270. - name: filer-cert
  271. secret:
  272. secretName: {{ template "seaweedfs.name" . }}-filer-cert
  273. - name: client-cert
  274. secret:
  275. secretName: {{ template "seaweedfs.name" . }}-client-cert
  276. {{- end }}
  277. {{ tpl .Values.s3.extraVolumes . | indent 8 | trim }}
  278. {{- if .Values.s3.nodeSelector }}
  279. nodeSelector:
  280. {{ tpl .Values.s3.nodeSelector . | indent 8 | trim }}
  281. {{- end }}
  282. {{- end }}