volume-statefulset.yaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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 \
  97. {{- if eq .Values.volume.logs.type "hostPath" }}
  98. -logdir=/logs \
  99. {{- else }}
  100. -logtostderr=true \
  101. {{- end }}
  102. {{- if .Values.volume.loggingOverrideLevel }}
  103. -v={{ .Values.volume.loggingOverrideLevel }} \
  104. {{- else }}
  105. -v={{ .Values.global.loggingLevel }} \
  106. {{- end }}
  107. volume \
  108. -port={{ .Values.volume.port }} \
  109. {{- if .Values.volume.metricsPort }}
  110. -metricsPort={{ .Values.volume.metricsPort }} \
  111. {{- end }}
  112. -dir={{ .Values.volume.dir }} \
  113. {{- if .Values.volume.dir_idx }}
  114. -dir.idx={{ .Values.volume.dir_idx }} \
  115. {{- end }}
  116. -max={{ .Values.volume.maxVolumes }} \
  117. {{- if .Values.volume.rack }}
  118. -rack={{ .Values.volume.rack }} \
  119. {{- end }}
  120. {{- if .Values.volume.dataCenter }}
  121. -dataCenter={{ .Values.volume.dataCenter }} \
  122. {{- end }}
  123. -ip.bind={{ .Values.volume.ipBind }} \
  124. -readMode={{ .Values.volume.readMode }} \
  125. {{- if .Values.volume.whiteList }}
  126. -whiteList={{ .Values.volume.whiteList }} \
  127. {{- end }}
  128. {{- if .Values.volume.imagesFixOrientation }}
  129. -images.fix.orientation \
  130. {{- end }}
  131. {{- if .Values.volume.pulseSeconds }}
  132. -pulseSeconds={{ .Values.volume.pulseSeconds }} \
  133. {{- end }}
  134. {{- if .Values.volume.index }}
  135. -index={{ .Values.volume.index }} \
  136. {{- end }}
  137. {{- if .Values.volume.fileSizeLimitMB }}
  138. -fileSizeLimitMB={{ .Values.volume.fileSizeLimitMB }} \
  139. {{- end }}
  140. -minFreeSpacePercent={{ .Values.volume.minFreeSpacePercent }} \
  141. -ip=${POD_NAME}.${SEAWEEDFS_FULLNAME}-volume \
  142. -compactionMBps={{ .Values.volume.compactionMBps }} \
  143. -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 }}
  144. volumeMounts:
  145. - name: data
  146. mountPath: "{{ .Values.volume.dir }}/"
  147. {{- if .Values.volume.dir_idx }}
  148. - name: idx
  149. mountPath: "{{ .Values.volume.dir_idx }}/"
  150. {{- end }}
  151. - name: logs
  152. mountPath: "/logs/"
  153. {{- if .Values.global.enableSecurity }}
  154. - name: security-config
  155. readOnly: true
  156. mountPath: /etc/seaweedfs/security.toml
  157. subPath: security.toml
  158. - name: ca-cert
  159. readOnly: true
  160. mountPath: /usr/local/share/ca-certificates/ca/
  161. - name: master-cert
  162. readOnly: true
  163. mountPath: /usr/local/share/ca-certificates/master/
  164. - name: volume-cert
  165. readOnly: true
  166. mountPath: /usr/local/share/ca-certificates/volume/
  167. - name: filer-cert
  168. readOnly: true
  169. mountPath: /usr/local/share/ca-certificates/filer/
  170. - name: client-cert
  171. readOnly: true
  172. mountPath: /usr/local/share/ca-certificates/client/
  173. {{- end }}
  174. {{ tpl .Values.volume.extraVolumeMounts . | nindent 12 | trim }}
  175. ports:
  176. - containerPort: {{ .Values.volume.port }}
  177. name: swfs-vol
  178. {{- if .Values.volume.metricsPort }}
  179. - containerPort: {{ .Values.filer.metricsPort }}
  180. name: metrics
  181. {{- end }}
  182. - containerPort: {{ .Values.volume.grpcPort }}
  183. name: swfs-vol-grpc
  184. readinessProbe:
  185. httpGet:
  186. path: /status
  187. port: {{ .Values.volume.port }}
  188. scheme: HTTP
  189. initialDelaySeconds: 15
  190. periodSeconds: 90
  191. successThreshold: 1
  192. failureThreshold: 100
  193. timeoutSeconds: 30
  194. livenessProbe:
  195. httpGet:
  196. path: /status
  197. port: {{ .Values.volume.port }}
  198. scheme: HTTP
  199. initialDelaySeconds: 20
  200. periodSeconds: 90
  201. successThreshold: 1
  202. failureThreshold: 4
  203. timeoutSeconds: 30
  204. {{- if .Values.volume.resources }}
  205. resources:
  206. {{ tpl .Values.volume.resources . | nindent 12 | trim }}
  207. {{- end }}
  208. {{- $hostpath_exists := include "volume.hostpath_exists" . -}}
  209. {{- if $hostpath_exists }}
  210. volumes:
  211. {{- if eq .Values.volume.data.type "hostPath" }}
  212. - name: data
  213. hostPath:
  214. path: {{ .Values.volume.data.hostPathPrefix }}/object_store/
  215. type: DirectoryOrCreate
  216. {{- end }}
  217. {{- if and (eq .Values.volume.idx.type "hostPath") .Values.volume.dir_idx }}
  218. - name: idx
  219. hostPath:
  220. path: {{ .Values.volume.idx.hostPathPrefix }}/seaweedfs-volume-idx/
  221. type: DirectoryOrCreate
  222. {{- end }}
  223. {{- if eq .Values.volume.logs.type "hostPath" }}
  224. - name: logs
  225. hostPath:
  226. path: {{ .Values.volume.logs.hostPathPrefix }}/logs/seaweedfs/volume
  227. type: DirectoryOrCreate
  228. {{- end }}
  229. {{- if .Values.global.enableSecurity }}
  230. - name: security-config
  231. configMap:
  232. name: {{ template "seaweedfs.name" . }}-security-config
  233. - name: ca-cert
  234. secret:
  235. secretName: {{ template "seaweedfs.name" . }}-ca-cert
  236. - name: master-cert
  237. secret:
  238. secretName: {{ template "seaweedfs.name" . }}-master-cert
  239. - name: volume-cert
  240. secret:
  241. secretName: {{ template "seaweedfs.name" . }}-volume-cert
  242. - name: filer-cert
  243. secret:
  244. secretName: {{ template "seaweedfs.name" . }}-filer-cert
  245. - name: client-cert
  246. secret:
  247. secretName: {{ template "seaweedfs.name" . }}-client-cert
  248. {{- end }}
  249. {{- if .Values.volume.extraVolumes }}
  250. {{ tpl .Values.volume.extraVolumes . | indent 8 | trim }}
  251. {{- end }}
  252. {{- end }}
  253. {{- if .Values.volume.nodeSelector }}
  254. nodeSelector:
  255. {{ tpl .Values.volume.nodeSelector . | indent 8 | trim }}
  256. {{- end }}
  257. {{- $pvc_exists := include "volume.pvc_exists" . -}}
  258. {{- if $pvc_exists }}
  259. volumeClaimTemplates:
  260. {{- if eq .Values.volume.data.type "persistentVolumeClaim"}}
  261. - metadata:
  262. name: data
  263. spec:
  264. accessModes: [ "ReadWriteOnce" ]
  265. storageClassName: {{ .Values.volume.data.storageClass }}
  266. resources:
  267. requests:
  268. storage: {{ .Values.volume.data.size }}
  269. {{- end }}
  270. {{- if and (eq .Values.volume.idx.type "persistentVolumeClaim") .Values.volume.dir_idx }}
  271. - metadata:
  272. name: idx
  273. spec:
  274. accessModes: [ "ReadWriteOnce" ]
  275. storageClassName: {{ .Values.volume.idx.storageClass }}
  276. resources:
  277. requests:
  278. storage: {{ .Values.volume.idx.size }}
  279. {{- end }}
  280. {{- if eq .Values.volume.logs.type "persistentVolumeClaim" }}
  281. - metadata:
  282. name: logs
  283. spec:
  284. accessModes: [ "ReadWriteOnce" ]
  285. storageClassName: {{ .Values.volume.logs.storageClass }}
  286. resources:
  287. requests:
  288. storage: {{ .Values.volume.logs.size }}
  289. {{- end }}
  290. {{- end }}
  291. {{- end }}