You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

276 lines
10 KiB

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