volume-statefulset.yaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. {{- if .Values.volume.enabled }}
  2. apiVersion: apps/v1
  3. kind: StatefulSet
  4. metadata:
  5. name: {{ template "seaweedfs.name" . }}-volume
  6. namespace: {{ .Release.Namespace }}
  7. labels:
  8. app: {{ template "seaweedfs.name" . }}
  9. chart: {{ template "seaweedfs.chart" . }}
  10. heritage: {{ .Release.Service }}
  11. release: {{ .Release.Name }}
  12. spec:
  13. serviceName: {{ template "seaweedfs.name" . }}-volume
  14. replicas: {{ .Values.volume.replicas }}
  15. podManagementPolicy: Parallel
  16. selector:
  17. matchLabels:
  18. app: {{ template "seaweedfs.name" . }}
  19. chart: {{ template "seaweedfs.chart" . }}
  20. release: {{ .Release.Name }}
  21. component: volume
  22. template:
  23. metadata:
  24. labels:
  25. app: {{ template "seaweedfs.name" . }}
  26. chart: {{ template "seaweedfs.chart" . }}
  27. release: {{ .Release.Name }}
  28. component: volume
  29. spec:
  30. {{- if .Values.volume.affinity }}
  31. affinity:
  32. {{ tpl .Values.volume.affinity . | nindent 8 | trim }}
  33. {{- end }}
  34. restartPolicy: {{ default .Values.global.restartPolicy .Values.volume.restartPolicy }}
  35. {{- if .Values.volume.tolerations }}
  36. tolerations:
  37. {{ tpl .Values.volume.tolerations . | nindent 8 | trim }}
  38. {{- end }}
  39. {{- if .Values.global.imagePullSecrets }}
  40. imagePullSecrets:
  41. - name: {{ .Values.global.imagePullSecrets }}
  42. {{- end }}
  43. terminationGracePeriodSeconds: 150
  44. {{- if .Values.volume.priorityClassName }}
  45. priorityClassName: {{ .Values.volume.priorityClassName | quote }}
  46. {{- end }}
  47. enableServiceLinks: false
  48. {{- $initContainers_exists := include "volume.initContainers_exists" . -}}
  49. {{- if $initContainers_exists }}
  50. initContainers:
  51. {{- if .Values.volume.dir_idx }}
  52. - name: seaweedfs-vol-move-idx
  53. image: {{ template "volume.image" . }}
  54. imagePullPolicy: {{ .Values.global.imagePullPolicy | default "IfNotPresent" }}
  55. command: [ '/bin/sh', '-c' ]
  56. args: [ 'if ls {{ .Values.volume.dir }}/*.idx >/dev/null 2>&1; then mv {{ .Values.volume.dir }}/*.idx {{ .Values.volume.dir_idx }}/; fi;' ]
  57. volumeMounts:
  58. - name: idx
  59. mountPath: {{ .Values.volume.dir_idx }}
  60. - name: data
  61. mountPath: {{ .Values.volume.dir }}
  62. {{- end }}
  63. {{- if .Values.volume.initContainers }}
  64. {{ tpl .Values.volume.initContainers . | nindent 8 | trim }}
  65. {{- end }}
  66. {{- end }}
  67. containers:
  68. - name: seaweedfs
  69. image: {{ template "volume.image" . }}
  70. imagePullPolicy: {{ default "IfNotPresent" .Values.global.imagePullPolicy }}
  71. env:
  72. - name: POD_NAME
  73. valueFrom:
  74. fieldRef:
  75. fieldPath: metadata.name
  76. - name: NAMESPACE
  77. valueFrom:
  78. fieldRef:
  79. fieldPath: metadata.namespace
  80. - name: HOST_IP
  81. valueFrom:
  82. fieldRef:
  83. fieldPath: status.hostIP
  84. - name: SEAWEEDFS_FULLNAME
  85. value: "{{ template "seaweedfs.name" . }}"
  86. {{- if .Values.global.extraEnvironmentVars }}
  87. {{- range $key, $value := .Values.global.extraEnvironmentVars }}
  88. - name: {{ $key }}
  89. value: {{ $value | quote }}
  90. {{- end }}
  91. {{- end }}
  92. command:
  93. - "/bin/sh"
  94. - "-ec"
  95. - |
  96. exec /usr/bin/weed -logdir=/logs \
  97. {{- if .Values.volume.loggingOverrideLevel }}
  98. -v={{ .Values.volume.loggingOverrideLevel }} \
  99. {{- else }}
  100. -v={{ .Values.global.loggingLevel }} \
  101. {{- end }}
  102. volume \
  103. -port={{ .Values.volume.port }} \
  104. {{- if .Values.volume.metricsPort }}
  105. -metricsPort={{ .Values.volume.metricsPort }} \
  106. {{- end }}
  107. -dir={{ .Values.volume.dir }} \
  108. {{- if .Values.volume.dir_idx }}
  109. -dir.idx={{ .Values.volume.dir_idx }} \
  110. {{- end }}
  111. -max={{ .Values.volume.maxVolumes }} \
  112. {{- if .Values.volume.rack }}
  113. -rack={{ .Values.volume.rack }} \
  114. {{- end }}
  115. {{- if .Values.volume.dataCenter }}
  116. -dataCenter={{ .Values.volume.dataCenter }} \
  117. {{- end }}
  118. -ip.bind={{ .Values.volume.ipBind }} \
  119. -readMode={{ .Values.volume.readMode }} \
  120. {{- if .Values.volume.whiteList }}
  121. -whiteList={{ .Values.volume.whiteList }} \
  122. {{- end }}
  123. {{- if .Values.volume.imagesFixOrientation }}
  124. -images.fix.orientation \
  125. {{- end }}
  126. {{- if .Values.volume.pulseSeconds }}
  127. -pulseSeconds={{ .Values.volume.pulseSeconds }} \
  128. {{- end }}
  129. {{- if .Values.volume.index }}
  130. -index={{ .Values.volume.index }} \
  131. {{- end }}
  132. {{- if .Values.volume.fileSizeLimitMB }}
  133. -fileSizeLimitMB={{ .Values.volume.fileSizeLimitMB }} \
  134. {{- end }}
  135. -minFreeSpacePercent={{ .Values.volume.minFreeSpacePercent }} \
  136. -ip=${POD_NAME}.${SEAWEEDFS_FULLNAME}-volume \
  137. -compactionMBps={{ .Values.volume.compactionMBps }} \
  138. -mserver={{ range $index := until (.Values.master.replicas | int) }}${SEAWEEDFS_FULLNAME}-master-{{ $index }}.${SEAWEEDFS_FULLNAME}-master:{{ $.Values.master.port }}{{ if lt $index (sub ($.Values.master.replicas | int) 1) }},{{ end }}{{ end }}
  139. volumeMounts:
  140. - name: data
  141. mountPath: "{{ .Values.volume.dir }}/"
  142. {{- if .Values.volume.dir_idx }}
  143. - name: idx
  144. mountPath: "{{ .Values.volume.dir_idx }}/"
  145. {{- end }}
  146. - name: logs
  147. mountPath: "/logs/"
  148. {{- if .Values.global.enableSecurity }}
  149. - name: security-config
  150. readOnly: true
  151. mountPath: /etc/seaweedfs/security.toml
  152. subPath: security.toml
  153. - name: ca-cert
  154. readOnly: true
  155. mountPath: /usr/local/share/ca-certificates/ca/
  156. - name: master-cert
  157. readOnly: true
  158. mountPath: /usr/local/share/ca-certificates/master/
  159. - name: volume-cert
  160. readOnly: true
  161. mountPath: /usr/local/share/ca-certificates/volume/
  162. - name: filer-cert
  163. readOnly: true
  164. mountPath: /usr/local/share/ca-certificates/filer/
  165. - name: client-cert
  166. readOnly: true
  167. mountPath: /usr/local/share/ca-certificates/client/
  168. {{- end }}
  169. {{ tpl .Values.volume.extraVolumeMounts . | nindent 12 | trim }}
  170. ports:
  171. - containerPort: {{ .Values.volume.port }}
  172. name: swfs-vol
  173. {{- if .Values.volume.metricsPort }}
  174. - containerPort: {{ .Values.filer.metricsPort }}
  175. name: metrics
  176. {{- end }}
  177. - containerPort: {{ .Values.volume.grpcPort }}
  178. name: swfs-vol-grpc
  179. readinessProbe:
  180. httpGet:
  181. path: /status
  182. port: {{ .Values.volume.port }}
  183. scheme: HTTP
  184. initialDelaySeconds: 15
  185. periodSeconds: 90
  186. successThreshold: 1
  187. failureThreshold: 100
  188. timeoutSeconds: 30
  189. livenessProbe:
  190. httpGet:
  191. path: /status
  192. port: {{ .Values.volume.port }}
  193. scheme: HTTP
  194. initialDelaySeconds: 20
  195. periodSeconds: 90
  196. successThreshold: 1
  197. failureThreshold: 4
  198. timeoutSeconds: 30
  199. {{- if .Values.volume.resources }}
  200. resources:
  201. {{ tpl .Values.volume.resources . | nindent 12 | trim }}
  202. {{- end }}
  203. {{- $hostpath_exists := include "volume.hostpath_exists" . -}}
  204. {{- if $hostpath_exists }}
  205. volumes:
  206. {{- if eq .Values.volume.data.type "hostPath" }}
  207. - name: data
  208. hostPath:
  209. path: /storage/object_store/
  210. type: DirectoryOrCreate
  211. {{- end }}
  212. {{- if and (eq .Values.volume.idx.type "hostPath") .Values.volume.dir_idx }}
  213. - name: idx
  214. hostPath:
  215. path: /ssd/seaweedfs-volume-idx/
  216. type: DirectoryOrCreate
  217. {{- end }}
  218. {{- if eq .Values.volume.logs.type "hostPath" }}
  219. - name: logs
  220. hostPath:
  221. path: /storage/logs/seaweedfs/volume
  222. type: DirectoryOrCreate
  223. {{- end }}
  224. {{- if .Values.global.enableSecurity }}
  225. - name: security-config
  226. configMap:
  227. name: {{ template "seaweedfs.name" . }}-security-config
  228. - name: ca-cert
  229. secret:
  230. secretName: {{ template "seaweedfs.name" . }}-ca-cert
  231. - name: master-cert
  232. secret:
  233. secretName: {{ template "seaweedfs.name" . }}-master-cert
  234. - name: volume-cert
  235. secret:
  236. secretName: {{ template "seaweedfs.name" . }}-volume-cert
  237. - name: filer-cert
  238. secret:
  239. secretName: {{ template "seaweedfs.name" . }}-filer-cert
  240. - name: client-cert
  241. secret:
  242. secretName: {{ template "seaweedfs.name" . }}-client-cert
  243. {{- end }}
  244. {{- if .Values.volume.extraVolumes }}
  245. {{ tpl .Values.volume.extraVolumes . | indent 8 | trim }}
  246. {{- end }}
  247. {{- end }}
  248. {{- if .Values.volume.nodeSelector }}
  249. nodeSelector:
  250. {{ tpl .Values.volume.nodeSelector . | indent 8 | trim }}
  251. {{- end }}
  252. {{- $pvc_exists := include "volume.pvc_exists" . -}}
  253. {{- if $pvc_exists }}
  254. volumeClaimTemplates:
  255. {{- if eq .Values.volume.data.type "persistentVolumeClaim"}}
  256. - metadata:
  257. name: data
  258. spec:
  259. accessModes: [ "ReadWriteOnce" ]
  260. storageClassName: {{ .Values.volume.data.storageClass }}
  261. resources:
  262. requests:
  263. storage: {{ .Values.volume.data.size }}
  264. {{- end }}
  265. {{- if and (eq .Values.volume.idx.type "persistentVolumeClaim") .Values.volume.dir_idx }}
  266. - metadata:
  267. name: idx
  268. spec:
  269. accessModes: [ "ReadWriteOnce" ]
  270. storageClassName: {{ .Values.volume.idx.storageClass }}
  271. resources:
  272. requests:
  273. storage: {{ .Values.volume.idx.size }}
  274. {{- end }}
  275. {{- if eq .Values.volume.logs.type "persistentVolumeClaim" }}
  276. - metadata:
  277. name: logs
  278. spec:
  279. accessModes: [ "ReadWriteOnce" ]
  280. storageClassName: {{ .Values.volume.logs.storageClass }}
  281. resources:
  282. requests:
  283. storage: {{ .Values.volume.logs.size }}
  284. {{- end }}
  285. {{- end }}
  286. {{- end }}