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.

258 lines
9.8 KiB

  1. {{- if .Values.master.enabled }}
  2. apiVersion: apps/v1
  3. kind: StatefulSet
  4. metadata:
  5. name: {{ template "seaweedfs.name" . }}-master
  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" . }}-master
  14. podManagementPolicy: Parallel
  15. replicas: {{ .Values.master.replicas }}
  16. {{- if (gt (int .Values.master.updatePartition) 0) }}
  17. updateStrategy:
  18. type: RollingUpdate
  19. rollingUpdate:
  20. partition: {{ .Values.master.updatePartition }}
  21. {{- end }}
  22. selector:
  23. matchLabels:
  24. app: {{ template "seaweedfs.name" . }}
  25. chart: {{ template "seaweedfs.chart" . }}
  26. release: {{ .Release.Name }}
  27. component: master
  28. template:
  29. metadata:
  30. labels:
  31. app: {{ template "seaweedfs.name" . }}
  32. chart: {{ template "seaweedfs.chart" . }}
  33. release: {{ .Release.Name }}
  34. component: master
  35. spec:
  36. restartPolicy: {{ default .Values.global.restartPolicy .Values.master.restartPolicy }}
  37. {{- if .Values.master.affinity }}
  38. affinity:
  39. {{ tpl .Values.master.affinity . | nindent 8 | trim }}
  40. {{- end }}
  41. {{- if .Values.master.tolerations }}
  42. tolerations:
  43. {{ tpl .Values.master.tolerations . | nindent 8 | trim }}
  44. {{- end }}
  45. {{- if .Values.global.imagePullSecrets }}
  46. imagePullSecrets:
  47. - name: {{ .Values.global.imagePullSecrets }}
  48. {{- end }}
  49. terminationGracePeriodSeconds: 60
  50. {{- if .Values.master.priorityClassName }}
  51. priorityClassName: {{ .Values.master.priorityClassName | quote }}
  52. {{- end }}
  53. enableServiceLinks: false
  54. {{- if .Values.master.initContainers }}
  55. initContainers:
  56. {{ tpl .Values.master.initContainers . | nindent 8 | trim }}
  57. {{- end }}
  58. containers:
  59. - name: seaweedfs
  60. image: {{ template "master.image" . }}
  61. imagePullPolicy: {{ default "IfNotPresent" .Values.global.imagePullPolicy }}
  62. env:
  63. - name: POD_IP
  64. valueFrom:
  65. fieldRef:
  66. fieldPath: status.podIP
  67. - name: POD_NAME
  68. valueFrom:
  69. fieldRef:
  70. fieldPath: metadata.name
  71. - name: NAMESPACE
  72. valueFrom:
  73. fieldRef:
  74. fieldPath: metadata.namespace
  75. - name: SEAWEEDFS_FULLNAME
  76. value: "{{ template "seaweedfs.name" . }}"
  77. {{- if .Values.master.extraEnvironmentVars }}
  78. {{- range $key, $value := .Values.master.extraEnvironmentVars }}
  79. - name: {{ $key }}
  80. value: {{ $value | quote }}
  81. {{- end }}
  82. {{- end }}
  83. {{- if .Values.global.extraEnvironmentVars }}
  84. {{- range $key, $value := .Values.global.extraEnvironmentVars }}
  85. - name: {{ $key }}
  86. value: {{ $value | quote }}
  87. {{- end }}
  88. {{- end }}
  89. command:
  90. - "/bin/sh"
  91. - "-ec"
  92. - |
  93. exec /usr/bin/weed -logdir=/logs \
  94. {{- if .Values.master.loggingOverrideLevel }}
  95. -v={{ .Values.master.loggingOverrideLevel }} \
  96. {{- else }}
  97. -v={{ .Values.global.loggingLevel }} \
  98. {{- end }}
  99. master \
  100. -port={{ .Values.master.port }} \
  101. -mdir=/data \
  102. -ip.bind={{ .Values.master.ipBind }} \
  103. {{- if .Values.global.enableReplication }}
  104. -defaultReplication={{ .Values.global.replicationPlacment }} \
  105. {{- else }}
  106. -defaultReplication={{ .Values.master.defaultReplication }} \
  107. {{- end }}
  108. {{- if .Values.master.volumePreallocate }}
  109. -volumePreallocate \
  110. {{- end }}
  111. {{- if .Values.global.monitoring.enabled }}
  112. {{- if and .Values.global.monitoring.gatewayHost .Values.global.monitoring.gatewayPort }}
  113. -metrics.address="{{ .Values.global.monitoring.gatewayHost }}:{{ .Values.global.monitoring.gatewayPort }}" \
  114. {{- if .Values.master.metricsIntervalSec }}
  115. -metrics.intervalSeconds={{ .Values.master.metricsIntervalSec }} \
  116. {{- end }}
  117. {{- else if .Values.master.metricsPort }}
  118. -metricsPort={{ .Values.master.metricsPort }} \
  119. {{- end }}
  120. {{- end }}
  121. -volumeSizeLimitMB={{ .Values.master.volumeSizeLimitMB }} \
  122. {{- if .Values.master.disableHttp }}
  123. -disableHttp \
  124. {{- end }}
  125. {{- if .Values.master.pulseSeconds }}
  126. -pulseSeconds={{ .Values.master.pulseSeconds }} \
  127. {{- end }}
  128. {{- if .Values.master.garbageThreshold }}
  129. -garbageThreshold={{ .Values.master.garbageThreshold }} \
  130. {{- end }}
  131. -ip=${POD_NAME}.${SEAWEEDFS_FULLNAME}-master \
  132. -peers={{ 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-{{ .Release.Namespace }}
  135. mountPath: /data
  136. - name: seaweedfs-master-log-volume
  137. mountPath: "/logs/"
  138. {{- if .Values.global.enableSecurity }}
  139. - name: security-config
  140. readOnly: true
  141. mountPath: /etc/seaweedfs/security.toml
  142. subPath: security.toml
  143. - name: ca-cert
  144. readOnly: true
  145. mountPath: /usr/local/share/ca-certificates/ca/
  146. - name: master-cert
  147. readOnly: true
  148. mountPath: /usr/local/share/ca-certificates/master/
  149. - name: volume-cert
  150. readOnly: true
  151. mountPath: /usr/local/share/ca-certificates/volume/
  152. - name: filer-cert
  153. readOnly: true
  154. mountPath: /usr/local/share/ca-certificates/filer/
  155. - name: client-cert
  156. readOnly: true
  157. mountPath: /usr/local/share/ca-certificates/client/
  158. {{- end }}
  159. {{ tpl .Values.master.extraVolumeMounts . | nindent 12 | trim }}
  160. ports:
  161. - containerPort: {{ .Values.master.port }}
  162. name: swfs-master
  163. {{- if and .Values.global.monitoring.enabled .Values.master.metricsPort }}
  164. - containerPort: {{ .Values.master.metricsPort }}
  165. name: metrics
  166. {{- end }}
  167. - containerPort: {{ .Values.master.grpcPort }}
  168. #name: swfs-master-grpc
  169. readinessProbe:
  170. httpGet:
  171. path: /cluster/status
  172. port: {{ .Values.master.port }}
  173. scheme: HTTP
  174. initialDelaySeconds: 10
  175. periodSeconds: 45
  176. successThreshold: 2
  177. failureThreshold: 100
  178. timeoutSeconds: 10
  179. livenessProbe:
  180. httpGet:
  181. path: /cluster/status
  182. port: {{ .Values.master.port }}
  183. scheme: HTTP
  184. initialDelaySeconds: 20
  185. periodSeconds: 30
  186. successThreshold: 1
  187. failureThreshold: 4
  188. timeoutSeconds: 10
  189. {{- if .Values.master.resources }}
  190. resources:
  191. {{ tpl .Values.master.resources . | nindent 12 | trim }}
  192. {{- end }}
  193. {{- $hostpath_exists := include "master.hostpath_exists" . -}}
  194. {{- if $hostpath_exists }}
  195. volumes:
  196. {{- if eq .Values.master.logs.type "hostPath" }}
  197. - name: seaweedfs-master-log-volume
  198. hostPath:
  199. path: /storage/logs/seaweedfs/master
  200. type: DirectoryOrCreate
  201. {{- end }}
  202. {{- if eq .Values.master.data.type "hostPath" }}
  203. - name: data-{{ .Release.Namespace }}
  204. hostPath:
  205. path: /ssd/seaweed-master/
  206. type: DirectoryOrCreate
  207. {{- end }}
  208. {{- if .Values.global.enableSecurity }}
  209. - name: security-config
  210. configMap:
  211. name: {{ template "seaweedfs.name" . }}-security-config
  212. - name: ca-cert
  213. secret:
  214. secretName: {{ template "seaweedfs.name" . }}-ca-cert
  215. - name: master-cert
  216. secret:
  217. secretName: {{ template "seaweedfs.name" . }}-master-cert
  218. - name: volume-cert
  219. secret:
  220. secretName: {{ template "seaweedfs.name" . }}-volume-cert
  221. - name: filer-cert
  222. secret:
  223. secretName: {{ template "seaweedfs.name" . }}-filer-cert
  224. - name: client-cert
  225. secret:
  226. secretName: {{ template "seaweedfs.name" . }}-client-cert
  227. {{- end }}
  228. {{ tpl .Values.master.extraVolumes . | indent 8 | trim }}
  229. {{- end }}
  230. {{- if .Values.master.nodeSelector }}
  231. nodeSelector:
  232. {{ tpl .Values.master.nodeSelector . | indent 8 | trim }}
  233. {{- end }}
  234. {{- $pvc_exists := include "volume.pvc_exists" . -}}
  235. {{- if $pvc_exists }}
  236. volumeClaimTemplates:
  237. {{- if eq .Values.master.data.type "persistentVolumeClaim"}}
  238. - metadata:
  239. name: data-{{ .Release.Namespace }}
  240. spec:
  241. accessModes: [ "ReadWriteOnce" ]
  242. storageClassName: {{ .Values.master.data.storageClass }}
  243. resources:
  244. requests:
  245. storage: {{ .Values.master.data.size }}
  246. {{- end }}
  247. {{- if eq .Values.master.logs.type "persistentVolumeClaim"}}
  248. - metadata:
  249. name: seaweedfs-master-log-volume
  250. spec:
  251. accessModes: [ "ReadWriteOnce" ]
  252. storageClassName: {{ .Values.master.logs.storageClass }}
  253. resources:
  254. requests:
  255. storage: {{ .Values.master.logs.size }}
  256. {{- end }}
  257. {{- end }}
  258. {{- end }}