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.

263 lines
10 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 \
  94. {{- if eq .Values.master.logs.type "hostPath" }}
  95. -logdir=/logs \
  96. {{- else }}
  97. -logtostderr=true \
  98. {{- end }}
  99. {{- if .Values.master.loggingOverrideLevel }}
  100. -v={{ .Values.master.loggingOverrideLevel }} \
  101. {{- else }}
  102. -v={{ .Values.global.loggingLevel }} \
  103. {{- end }}
  104. master \
  105. -port={{ .Values.master.port }} \
  106. -mdir=/data \
  107. -ip.bind={{ .Values.master.ipBind }} \
  108. {{- if .Values.global.enableReplication }}
  109. -defaultReplication={{ .Values.global.replicationPlacment }} \
  110. {{- else }}
  111. -defaultReplication={{ .Values.master.defaultReplication }} \
  112. {{- end }}
  113. {{- if .Values.master.volumePreallocate }}
  114. -volumePreallocate \
  115. {{- end }}
  116. {{- if .Values.global.monitoring.enabled }}
  117. {{- if and .Values.global.monitoring.gatewayHost .Values.global.monitoring.gatewayPort }}
  118. -metrics.address="{{ .Values.global.monitoring.gatewayHost }}:{{ .Values.global.monitoring.gatewayPort }}" \
  119. {{- if .Values.master.metricsIntervalSec }}
  120. -metrics.intervalSeconds={{ .Values.master.metricsIntervalSec }} \
  121. {{- end }}
  122. {{- else if .Values.master.metricsPort }}
  123. -metricsPort={{ .Values.master.metricsPort }} \
  124. {{- end }}
  125. {{- end }}
  126. -volumeSizeLimitMB={{ .Values.master.volumeSizeLimitMB }} \
  127. {{- if .Values.master.disableHttp }}
  128. -disableHttp \
  129. {{- end }}
  130. {{- if .Values.master.pulseSeconds }}
  131. -pulseSeconds={{ .Values.master.pulseSeconds }} \
  132. {{- end }}
  133. {{- if .Values.master.garbageThreshold }}
  134. -garbageThreshold={{ .Values.master.garbageThreshold }} \
  135. {{- end }}
  136. -ip=${POD_NAME}.${SEAWEEDFS_FULLNAME}-master \
  137. -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 }}
  138. volumeMounts:
  139. - name : data-{{ .Release.Namespace }}
  140. mountPath: /data
  141. - name: seaweedfs-master-log-volume
  142. mountPath: "/logs/"
  143. {{- if .Values.global.enableSecurity }}
  144. - name: security-config
  145. readOnly: true
  146. mountPath: /etc/seaweedfs/security.toml
  147. subPath: security.toml
  148. - name: ca-cert
  149. readOnly: true
  150. mountPath: /usr/local/share/ca-certificates/ca/
  151. - name: master-cert
  152. readOnly: true
  153. mountPath: /usr/local/share/ca-certificates/master/
  154. - name: volume-cert
  155. readOnly: true
  156. mountPath: /usr/local/share/ca-certificates/volume/
  157. - name: filer-cert
  158. readOnly: true
  159. mountPath: /usr/local/share/ca-certificates/filer/
  160. - name: client-cert
  161. readOnly: true
  162. mountPath: /usr/local/share/ca-certificates/client/
  163. {{- end }}
  164. {{ tpl .Values.master.extraVolumeMounts . | nindent 12 | trim }}
  165. ports:
  166. - containerPort: {{ .Values.master.port }}
  167. name: swfs-master
  168. {{- if and .Values.global.monitoring.enabled .Values.master.metricsPort }}
  169. - containerPort: {{ .Values.master.metricsPort }}
  170. name: metrics
  171. {{- end }}
  172. - containerPort: {{ .Values.master.grpcPort }}
  173. #name: swfs-master-grpc
  174. readinessProbe:
  175. httpGet:
  176. path: /cluster/status
  177. port: {{ .Values.master.port }}
  178. scheme: HTTP
  179. initialDelaySeconds: 10
  180. periodSeconds: 45
  181. successThreshold: 2
  182. failureThreshold: 100
  183. timeoutSeconds: 10
  184. livenessProbe:
  185. httpGet:
  186. path: /cluster/status
  187. port: {{ .Values.master.port }}
  188. scheme: HTTP
  189. initialDelaySeconds: 20
  190. periodSeconds: 30
  191. successThreshold: 1
  192. failureThreshold: 4
  193. timeoutSeconds: 10
  194. {{- if .Values.master.resources }}
  195. resources:
  196. {{ tpl .Values.master.resources . | nindent 12 | trim }}
  197. {{- end }}
  198. {{- $hostpath_exists := include "master.hostpath_exists" . -}}
  199. {{- if $hostpath_exists }}
  200. volumes:
  201. {{- if eq .Values.master.logs.type "hostPath" }}
  202. - name: seaweedfs-master-log-volume
  203. hostPath:
  204. path: {{ .Values.master.logs.hostPathPrefix }}/logs/seaweedfs/master
  205. type: DirectoryOrCreate
  206. {{- end }}
  207. {{- if eq .Values.master.data.type "hostPath" }}
  208. - name: data-{{ .Release.Namespace }}
  209. hostPath:
  210. path: {{ .Values.master.data.hostPathPrefix }}/seaweed-master/
  211. type: DirectoryOrCreate
  212. {{- end }}
  213. {{- if .Values.global.enableSecurity }}
  214. - name: security-config
  215. configMap:
  216. name: {{ template "seaweedfs.name" . }}-security-config
  217. - name: ca-cert
  218. secret:
  219. secretName: {{ template "seaweedfs.name" . }}-ca-cert
  220. - name: master-cert
  221. secret:
  222. secretName: {{ template "seaweedfs.name" . }}-master-cert
  223. - name: volume-cert
  224. secret:
  225. secretName: {{ template "seaweedfs.name" . }}-volume-cert
  226. - name: filer-cert
  227. secret:
  228. secretName: {{ template "seaweedfs.name" . }}-filer-cert
  229. - name: client-cert
  230. secret:
  231. secretName: {{ template "seaweedfs.name" . }}-client-cert
  232. {{- end }}
  233. {{ tpl .Values.master.extraVolumes . | indent 8 | trim }}
  234. {{- end }}
  235. {{- if .Values.master.nodeSelector }}
  236. nodeSelector:
  237. {{ tpl .Values.master.nodeSelector . | indent 8 | trim }}
  238. {{- end }}
  239. {{- $pvc_exists := include "volume.pvc_exists" . -}}
  240. {{- if $pvc_exists }}
  241. volumeClaimTemplates:
  242. {{- if eq .Values.master.data.type "persistentVolumeClaim"}}
  243. - metadata:
  244. name: data-{{ .Release.Namespace }}
  245. spec:
  246. accessModes: [ "ReadWriteOnce" ]
  247. storageClassName: {{ .Values.master.data.storageClass }}
  248. resources:
  249. requests:
  250. storage: {{ .Values.master.data.size }}
  251. {{- end }}
  252. {{- if eq .Values.master.logs.type "persistentVolumeClaim"}}
  253. - metadata:
  254. name: seaweedfs-master-log-volume
  255. spec:
  256. accessModes: [ "ReadWriteOnce" ]
  257. storageClassName: {{ .Values.master.logs.storageClass }}
  258. resources:
  259. requests:
  260. storage: {{ .Values.master.logs.size }}
  261. {{- end }}
  262. {{- end }}
  263. {{- end }}