all-in-one-deployment.yaml 19 KB

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