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.

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