filer-statefulset.yaml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. {{- if .Values.filer.enabled }}
  2. apiVersion: apps/v1
  3. kind: StatefulSet
  4. metadata:
  5. name: {{ template "seaweedfs.name" . }}-filer
  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: filer
  13. {{- if .Values.filer.annotations }}
  14. annotations:
  15. {{- toYaml .Values.filer.annotations | nindent 4 }}
  16. {{- end }}
  17. spec:
  18. serviceName: {{ template "seaweedfs.name" . }}-filer
  19. podManagementPolicy: {{ .Values.filer.podManagementPolicy }}
  20. replicas: {{ .Values.filer.replicas }}
  21. {{- if (gt (int .Values.filer.updatePartition) 0) }}
  22. updateStrategy:
  23. type: RollingUpdate
  24. rollingUpdate:
  25. partition: {{ .Values.filer.updatePartition }}
  26. {{- end }}
  27. selector:
  28. matchLabels:
  29. app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
  30. app.kubernetes.io/instance: {{ .Release.Name }}
  31. app.kubernetes.io/component: filer
  32. template:
  33. metadata:
  34. labels:
  35. app.kubernetes.io/name: {{ template "seaweedfs.name" . }}
  36. helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
  37. app.kubernetes.io/instance: {{ .Release.Name }}
  38. app.kubernetes.io/component: filer
  39. {{- with .Values.podLabels }}
  40. {{- toYaml . | nindent 8 }}
  41. {{- end }}
  42. {{- with .Values.filer.podLabels }}
  43. {{- toYaml . | nindent 8 }}
  44. {{- end }}
  45. annotations:
  46. {{- with .Values.podAnnotations }}
  47. {{- toYaml . | nindent 8 }}
  48. {{- end }}
  49. {{- with .Values.filer.podAnnotations }}
  50. {{- toYaml . | nindent 8 }}
  51. {{- end }}
  52. {{- if .Values.filer.s3.existingConfigSecret }}
  53. {{- $configSecret := (lookup "v1" "Secret" .Release.Namespace .Values.filer.s3.existingConfigSecret) | default dict }}
  54. checksum/s3config: {{ $configSecret | toYaml | sha256sum }}
  55. {{- else }}
  56. checksum/s3config: {{ include (print .Template.BasePath "/s3/s3-secret.yaml") . | sha256sum }}
  57. {{- end }}
  58. spec:
  59. restartPolicy: {{ default .Values.global.restartPolicy .Values.filer.restartPolicy }}
  60. {{- if .Values.filer.affinity }}
  61. affinity:
  62. {{ tpl .Values.filer.affinity . | nindent 8 | trim }}
  63. {{- end }}
  64. {{- if .Values.filer.topologySpreadConstraints }}
  65. topologySpreadConstraints:
  66. {{ tpl .Values.filer.topologySpreadConstraints . | nindent 8 | trim }}
  67. {{- end }}
  68. {{- if .Values.filer.tolerations }}
  69. tolerations:
  70. {{ tpl .Values.filer.tolerations . | nindent 8 | trim }}
  71. {{- end }}
  72. {{- include "seaweedfs.imagePullSecrets" . | nindent 6 }}
  73. serviceAccountName: {{ .Values.filer.serviceAccountName | default .Values.global.serviceAccountName | quote }} # for deleting statefulset pods after migration
  74. terminationGracePeriodSeconds: 60
  75. {{- if .Values.filer.priorityClassName }}
  76. priorityClassName: {{ .Values.filer.priorityClassName | quote }}
  77. {{- end }}
  78. enableServiceLinks: false
  79. {{- if .Values.filer.initContainers }}
  80. initContainers:
  81. {{ tpl .Values.filer.initContainers . | nindent 8 | trim }}
  82. {{- end }}
  83. {{- if .Values.filer.podSecurityContext.enabled }}
  84. securityContext: {{- omit .Values.filer.podSecurityContext "enabled" | toYaml | nindent 8 }}
  85. {{- end }}
  86. containers:
  87. - name: seaweedfs
  88. image: {{ template "filer.image" . }}
  89. imagePullPolicy: {{ default "IfNotPresent" .Values.global.imagePullPolicy }}
  90. env:
  91. - name: POD_IP
  92. valueFrom:
  93. fieldRef:
  94. fieldPath: status.podIP
  95. - name: POD_NAME
  96. valueFrom:
  97. fieldRef:
  98. fieldPath: metadata.name
  99. - name: NAMESPACE
  100. valueFrom:
  101. fieldRef:
  102. fieldPath: metadata.namespace
  103. - name: WEED_MYSQL_USERNAME
  104. valueFrom:
  105. secretKeyRef:
  106. name: secret-seaweedfs-db
  107. key: user
  108. optional: true
  109. - name: WEED_MYSQL_PASSWORD
  110. valueFrom:
  111. secretKeyRef:
  112. name: secret-seaweedfs-db
  113. key: password
  114. optional: true
  115. - name: SEAWEEDFS_FULLNAME
  116. value: "{{ template "seaweedfs.name" . }}"
  117. {{- if .Values.filer.extraEnvironmentVars }}
  118. {{- range $key, $value := .Values.filer.extraEnvironmentVars }}
  119. - name: {{ $key }}
  120. {{- if kindIs "string" $value }}
  121. value: {{ $value | quote }}
  122. {{- else }}
  123. valueFrom:
  124. {{ toYaml $value | nindent 16 | trim }}
  125. {{- end -}}
  126. {{- end }}
  127. {{- end }}
  128. {{- if .Values.global.extraEnvironmentVars }}
  129. {{- range $key, $value := .Values.global.extraEnvironmentVars }}
  130. - name: {{ $key }}
  131. {{- if kindIs "string" $value }}
  132. value: {{ $value | quote }}
  133. {{- else }}
  134. valueFrom:
  135. {{ toYaml $value | nindent 16 | trim }}
  136. {{- end -}}
  137. {{- end }}
  138. {{- end }}
  139. {{- if .Values.filer.secretExtraEnvironmentVars }}
  140. {{- range $key, $value := .Values.filer.secretExtraEnvironmentVars }}
  141. - name: {{ $key }}
  142. valueFrom: {{ toYaml $value | nindent 16 }}
  143. {{- end }}
  144. {{- end }}
  145. command:
  146. - "/bin/sh"
  147. - "-ec"
  148. - |
  149. exec /usr/bin/weed \
  150. {{- if or (eq .Values.filer.logs.type "hostPath") (eq .Values.filer.logs.type "persistentVolumeClaim") (eq .Values.filer.logs.type "emptyDir") }}
  151. -logdir=/logs \
  152. {{- else }}
  153. -logtostderr=true \
  154. {{- end }}
  155. {{- if .Values.filer.loggingOverrideLevel }}
  156. -v={{ .Values.filer.loggingOverrideLevel }} \
  157. {{- else }}
  158. -v={{ .Values.global.loggingLevel }} \
  159. {{- end }}
  160. filer \
  161. -port={{ .Values.filer.port }} \
  162. {{- if .Values.filer.metricsPort }}
  163. -metricsPort={{ .Values.filer.metricsPort }} \
  164. {{- end }}
  165. {{- if .Values.filer.metricsIp }}
  166. -metricsIp={{ .Values.filer.metricsIp }} \
  167. {{- end }}
  168. {{- if .Values.filer.redirectOnRead }}
  169. -redirectOnRead \
  170. {{- end }}
  171. {{- if .Values.filer.disableHttp }}
  172. -disableHttp \
  173. {{- end }}
  174. {{- if .Values.filer.disableDirListing }}
  175. -disableDirListing \
  176. {{- end }}
  177. -dirListLimit={{ .Values.filer.dirListLimit }} \
  178. {{- if .Values.global.enableReplication }}
  179. -defaultReplicaPlacement={{ .Values.global.replicationPlacement }} \
  180. {{- else }}
  181. -defaultReplicaPlacement={{ .Values.filer.defaultReplicaPlacement }} \
  182. {{- end }}
  183. {{- if .Values.filer.disableDirListing }}
  184. -disableDirListing \
  185. {{- end }}
  186. {{- if .Values.filer.maxMB }}
  187. -maxMB={{ .Values.filer.maxMB }} \
  188. {{- end }}
  189. {{- if .Values.filer.encryptVolumeData }}
  190. -encryptVolumeData \
  191. {{- end }}
  192. -ip=${POD_IP} \
  193. -ip.bind={{ .Values.filer.ipBind }} \
  194. {{- if .Values.filer.filerGroup}}
  195. -filerGroup={{ .Values.filer.filerGroup}} \
  196. {{- end }}
  197. {{- if .Values.filer.rack }}
  198. -rack={{ .Values.filer.rack }} \
  199. {{- end }}
  200. {{- if .Values.filer.dataCenter }}
  201. -dataCenter={{ .Values.filer.dataCenter }} \
  202. {{- end }}
  203. {{- if .Values.filer.s3.enabled }}
  204. -s3 \
  205. -s3.port={{ .Values.filer.s3.port }} \
  206. {{- if .Values.filer.s3.domainName }}
  207. -s3.domainName={{ .Values.filer.s3.domainName }} \
  208. {{- end }}
  209. {{- if .Values.global.enableSecurity }}
  210. {{- if .Values.filer.s3.httpsPort }}
  211. -s3.port.https={{ .Values.filer.s3.httpsPort }} \
  212. {{- end }}
  213. -s3.cert.file=/usr/local/share/ca-certificates/client/tls.crt \
  214. -s3.key.file=/usr/local/share/ca-certificates/client/tls.key \
  215. {{- end }}
  216. {{- if eq (typeOf .Values.filer.s3.allowEmptyFolder) "bool" }}
  217. -s3.allowEmptyFolder={{ .Values.filer.s3.allowEmptyFolder }} \
  218. {{- end }}
  219. {{- if .Values.filer.s3.enableAuth }}
  220. -s3.config=/etc/sw/seaweedfs_s3_config \
  221. {{- end }}
  222. {{- if .Values.filer.s3.auditLogConfig }}
  223. -s3.auditLogConfig=/etc/sw/filer_s3_auditLogConfig.json \
  224. {{- end }}
  225. {{- end }}
  226. -master={{ if .Values.global.masterServer }}{{.Values.global.masterServer}}{{ else }}{{ range $index := until (.Values.master.replicas | int) }}${SEAWEEDFS_FULLNAME}-master-{{ $index }}.${SEAWEEDFS_FULLNAME}-master.{{ $.Release.Namespace }}:{{ $.Values.master.port }}{{ if lt $index (sub ($.Values.master.replicas | int) 1) }},{{ end }}{{ end }}{{ end }} \
  227. {{- range .Values.filer.extraArgs }}
  228. {{ . }} \
  229. {{- end }}
  230. volumeMounts:
  231. {{- if (or (eq .Values.filer.logs.type "hostPath") (eq .Values.filer.logs.type "persistentVolumeClaim") (eq .Values.filer.logs.type "emptyDir")) }}
  232. - name: seaweedfs-filer-log-volume
  233. mountPath: "/logs/"
  234. {{- end }}
  235. {{- if .Values.filer.s3.enableAuth }}
  236. - name: config-users
  237. mountPath: /etc/sw
  238. readOnly: true
  239. {{- end }}
  240. {{- if (or .Values.filer.enablePVC (or (eq .Values.filer.data.type "hostPath") (eq .Values.filer.data.type "persistentVolumeClaim") (eq .Values.filer.data.type "emptyDir"))) }}
  241. - name: data-filer
  242. mountPath: /data
  243. {{- end }}
  244. {{- if .Values.filer.notificationConfig }}
  245. - name: notification-config
  246. readOnly: true
  247. mountPath: /etc/seaweedfs/notification.toml
  248. subPath: notification.toml
  249. {{- end }}
  250. {{- if .Values.global.enableSecurity }}
  251. - name: security-config
  252. readOnly: true
  253. mountPath: /etc/seaweedfs/security.toml
  254. subPath: security.toml
  255. - name: ca-cert
  256. readOnly: true
  257. mountPath: /usr/local/share/ca-certificates/ca/
  258. - name: master-cert
  259. readOnly: true
  260. mountPath: /usr/local/share/ca-certificates/master/
  261. - name: volume-cert
  262. readOnly: true
  263. mountPath: /usr/local/share/ca-certificates/volume/
  264. - name: filer-cert
  265. readOnly: true
  266. mountPath: /usr/local/share/ca-certificates/filer/
  267. - name: client-cert
  268. readOnly: true
  269. mountPath: /usr/local/share/ca-certificates/client/
  270. {{- end }}
  271. {{ tpl .Values.filer.extraVolumeMounts . | nindent 12 | trim }}
  272. ports:
  273. - containerPort: {{ .Values.filer.port }}
  274. name: swfs-filer
  275. - containerPort: {{ .Values.filer.metricsPort }}
  276. name: metrics
  277. - containerPort: {{ .Values.filer.grpcPort }}
  278. #name: swfs-filer-grpc
  279. {{- if .Values.filer.s3.enabled }}
  280. - containerPort: {{ .Values.filer.s3.port }}
  281. name: swfs-s3
  282. {{- if .Values.filer.s3.httpsPort }}
  283. - containerPort: {{ .Values.filer.s3.httpsPort }}
  284. name: swfs-s3-tls
  285. {{- end }}
  286. {{- end }}
  287. {{- if .Values.filer.readinessProbe.enabled }}
  288. readinessProbe:
  289. httpGet:
  290. path: {{ .Values.filer.readinessProbe.httpGet.path }}
  291. port: {{ .Values.filer.port }}
  292. scheme: {{ .Values.filer.readinessProbe.scheme }}
  293. initialDelaySeconds: {{ .Values.filer.readinessProbe.initialDelaySeconds }}
  294. periodSeconds: {{ .Values.filer.readinessProbe.periodSeconds }}
  295. successThreshold: {{ .Values.filer.readinessProbe.successThreshold }}
  296. failureThreshold: {{ .Values.filer.readinessProbe.failureThreshold }}
  297. timeoutSeconds: {{ .Values.filer.readinessProbe.timeoutSeconds }}
  298. {{- end }}
  299. {{- if .Values.filer.livenessProbe.enabled }}
  300. livenessProbe:
  301. httpGet:
  302. path: {{ .Values.filer.livenessProbe.httpGet.path }}
  303. port: {{ .Values.filer.port }}
  304. scheme: {{ .Values.filer.livenessProbe.scheme }}
  305. initialDelaySeconds: {{ .Values.filer.livenessProbe.initialDelaySeconds }}
  306. periodSeconds: {{ .Values.filer.livenessProbe.periodSeconds }}
  307. successThreshold: {{ .Values.filer.livenessProbe.successThreshold }}
  308. failureThreshold: {{ .Values.filer.livenessProbe.failureThreshold }}
  309. timeoutSeconds: {{ .Values.filer.livenessProbe.timeoutSeconds }}
  310. {{- end }}
  311. {{- with .Values.filer.resources }}
  312. resources:
  313. {{- toYaml . | nindent 12 }}
  314. {{- end }}
  315. {{- if .Values.filer.containerSecurityContext.enabled }}
  316. securityContext: {{- omit .Values.filer.containerSecurityContext "enabled" | toYaml | nindent 12 }}
  317. {{- end }}
  318. {{- if .Values.filer.sidecars }}
  319. {{- include "common.tplvalues.render" (dict "value" .Values.filer.sidecars "context" $) | nindent 8 }}
  320. {{- end }}
  321. volumes:
  322. {{- if eq .Values.filer.logs.type "hostPath" }}
  323. - name: seaweedfs-filer-log-volume
  324. hostPath:
  325. path: {{ .Values.filer.logs.hostPathPrefix }}/logs/seaweedfs/filer
  326. type: DirectoryOrCreate
  327. {{- end }}
  328. {{- if eq .Values.filer.logs.type "existingClaim" }}
  329. - name: seaweedfs-filer-log-volume
  330. persistentVolumeClaim:
  331. claimName: {{ .Values.filer.logs.claimName }}
  332. {{- end }}
  333. {{- if eq .Values.filer.logs.type "emptyDir" }}
  334. - name: seaweedfs-filer-log-volume
  335. emptyDir: {}
  336. {{- end }}
  337. {{- if eq .Values.filer.data.type "hostPath" }}
  338. - name: data-filer
  339. hostPath:
  340. path: {{ .Values.filer.data.hostPathPrefix }}/filer_store
  341. type: DirectoryOrCreate
  342. {{- end }}
  343. {{- if eq .Values.filer.data.type "existingClaim" }}
  344. - name: data-filer
  345. persistentVolumeClaim:
  346. claimName: {{ .Values.filer.data.claimName }}
  347. {{- end }}
  348. {{- if eq .Values.filer.data.type "emptyDir" }}
  349. - name: data-filer
  350. emptyDir: {}
  351. {{- end }}
  352. - name: db-schema-config-volume
  353. configMap:
  354. name: seaweedfs-db-init-config
  355. {{- if and .Values.filer.s3.enabled .Values.filer.s3.enableAuth }}
  356. - name: config-users
  357. secret:
  358. defaultMode: 420
  359. {{- if .Values.filer.s3.existingConfigSecret }}
  360. secretName: {{ .Values.filer.s3.existingConfigSecret }}
  361. {{- else }}
  362. secretName: seaweedfs-s3-secret
  363. {{- end }}
  364. {{- end }}
  365. {{- if .Values.filer.notificationConfig }}
  366. - name: notification-config
  367. configMap:
  368. name: {{ template "seaweedfs.name" . }}-notification-config
  369. {{- end }}
  370. {{- if .Values.global.enableSecurity }}
  371. - name: security-config
  372. configMap:
  373. name: {{ template "seaweedfs.name" . }}-security-config
  374. - name: ca-cert
  375. secret:
  376. secretName: {{ template "seaweedfs.name" . }}-ca-cert
  377. - name: master-cert
  378. secret:
  379. secretName: {{ template "seaweedfs.name" . }}-master-cert
  380. - name: volume-cert
  381. secret:
  382. secretName: {{ template "seaweedfs.name" . }}-volume-cert
  383. - name: filer-cert
  384. secret:
  385. secretName: {{ template "seaweedfs.name" . }}-filer-cert
  386. - name: client-cert
  387. secret:
  388. secretName: {{ template "seaweedfs.name" . }}-client-cert
  389. {{- end }}
  390. {{ tpl .Values.filer.extraVolumes . | indent 8 | trim }}
  391. {{- if .Values.filer.nodeSelector }}
  392. nodeSelector:
  393. {{ tpl .Values.filer.nodeSelector . | indent 8 | trim }}
  394. {{- end }}
  395. {{- if and (.Values.filer.enablePVC) (eq .Values.filer.data.type "persistentVolumeClaim") }}
  396. # DEPRECATION: Deprecate in favor of filer.data section below
  397. volumeClaimTemplates:
  398. - metadata:
  399. name: data-filer
  400. spec:
  401. accessModes:
  402. - ReadWriteOnce
  403. resources:
  404. requests:
  405. storage: {{ .Values.filer.storage }}
  406. {{- if .Values.filer.storageClass }}
  407. storageClassName: {{ .Values.filer.storageClass }}
  408. {{- end }}
  409. {{- end }}
  410. {{- $pvc_exists := include "filer.pvc_exists" . -}}
  411. {{- if $pvc_exists }}
  412. volumeClaimTemplates:
  413. {{- if eq .Values.filer.data.type "persistentVolumeClaim" }}
  414. - metadata:
  415. name: data-filer
  416. {{- with .Values.filer.data.annotations }}
  417. annotations:
  418. {{- toYaml . | nindent 10 }}
  419. {{- end }}
  420. spec:
  421. accessModes: [ "ReadWriteOnce" ]
  422. storageClassName: {{ .Values.filer.data.storageClass }}
  423. resources:
  424. requests:
  425. storage: {{ .Values.filer.data.size }}
  426. {{- end }}
  427. {{- if eq .Values.filer.logs.type "persistentVolumeClaim" }}
  428. - metadata:
  429. name: seaweedfs-filer-log-volume
  430. {{- with .Values.filer.logs.annotations }}
  431. annotations:
  432. {{- toYaml . | nindent 10 }}
  433. {{- end }}
  434. spec:
  435. accessModes: [ "ReadWriteOnce" ]
  436. storageClassName: {{ .Values.filer.logs.storageClass }}
  437. resources:
  438. requests:
  439. storage: {{ .Values.filer.logs.size }}
  440. {{- end }}
  441. {{- end }}
  442. {{- end }}