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.

246 lines
9.3 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. containers:
  55. - name: seaweedfs
  56. image: {{ template "master.image" . }}
  57. imagePullPolicy: {{ default "IfNotPresent" .Values.global.imagePullPolicy }}
  58. env:
  59. - name: POD_IP
  60. valueFrom:
  61. fieldRef:
  62. fieldPath: status.podIP
  63. - name: POD_NAME
  64. valueFrom:
  65. fieldRef:
  66. fieldPath: metadata.name
  67. - name: NAMESPACE
  68. valueFrom:
  69. fieldRef:
  70. fieldPath: metadata.namespace
  71. - name: SEAWEEDFS_FULLNAME
  72. value: "{{ template "seaweedfs.name" . }}"
  73. {{- if .Values.master.extraEnvironmentVars }}
  74. {{- range $key, $value := .Values.master.extraEnvironmentVars }}
  75. - name: {{ $key }}
  76. value: {{ $value | quote }}
  77. {{- end }}
  78. {{- end }}
  79. {{- if .Values.global.extraEnvironmentVars }}
  80. {{- range $key, $value := .Values.global.extraEnvironmentVars }}
  81. - name: {{ $key }}
  82. value: {{ $value | quote }}
  83. {{- end }}
  84. {{- end }}
  85. command:
  86. - "/bin/sh"
  87. - "-ec"
  88. - |
  89. exec /usr/bin/weed -logdir=/logs \
  90. {{- if .Values.master.loggingOverrideLevel }}
  91. -v={{ .Values.master.loggingOverrideLevel }} \
  92. {{- else }}
  93. -v={{ .Values.global.loggingLevel }} \
  94. {{- end }}
  95. master \
  96. -port={{ .Values.master.port }} \
  97. -mdir=/data \
  98. -ip.bind={{ .Values.master.ipBind }} \
  99. {{- if .Values.global.enableReplication }}
  100. -defaultReplication={{ .Values.global.replicationPlacment }} \
  101. {{- else }}
  102. -defaultReplication={{ .Values.master.defaultReplication }} \
  103. {{- end }}
  104. {{- if .Values.master.volumePreallocate }}
  105. -volumePreallocate \
  106. {{- end }}
  107. {{- if .Values.global.monitoring.enabled }}
  108. -metrics.address="{{ .Values.global.monitoring.gatewayHost }}:{{ .Values.global.monitoring.gatewayPort }}" \
  109. {{- end }}
  110. -volumeSizeLimitMB={{ .Values.master.volumeSizeLimitMB }} \
  111. {{- if .Values.master.disableHttp }}
  112. -disableHttp \
  113. {{- end }}
  114. {{- if .Values.master.pulseSeconds }}
  115. -pulseSeconds={{ .Values.master.pulseSeconds }} \
  116. {{- end }}
  117. {{- if .Values.master.garbageThreshold }}
  118. -garbageThreshold={{ .Values.master.garbageThreshold }} \
  119. {{- end }}
  120. {{- if .Values.master.metricsIntervalSec }}
  121. -metrics.intervalSeconds={{ .Values.master.metricsIntervalSec }} \
  122. {{- end }}
  123. -ip=${POD_NAME}.${SEAWEEDFS_FULLNAME}-master \
  124. -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 }}
  125. volumeMounts:
  126. - name : data-{{ .Release.Namespace }}
  127. mountPath: /data
  128. - name: seaweedfs-master-log-volume
  129. mountPath: "/logs/"
  130. {{- if .Values.global.enableSecurity }}
  131. - name: security-config
  132. readOnly: true
  133. mountPath: /etc/seaweedfs/security.toml
  134. subPath: security.toml
  135. - name: ca-cert
  136. readOnly: true
  137. mountPath: /usr/local/share/ca-certificates/ca/
  138. - name: master-cert
  139. readOnly: true
  140. mountPath: /usr/local/share/ca-certificates/master/
  141. - name: volume-cert
  142. readOnly: true
  143. mountPath: /usr/local/share/ca-certificates/volume/
  144. - name: filer-cert
  145. readOnly: true
  146. mountPath: /usr/local/share/ca-certificates/filer/
  147. - name: client-cert
  148. readOnly: true
  149. mountPath: /usr/local/share/ca-certificates/client/
  150. {{- end }}
  151. {{ tpl .Values.master.extraVolumeMounts . | nindent 12 | trim }}
  152. ports:
  153. - containerPort: {{ .Values.master.port }}
  154. name: swfs-master
  155. - containerPort: {{ .Values.master.grpcPort }}
  156. #name: swfs-master-grpc
  157. readinessProbe:
  158. httpGet:
  159. path: /cluster/status
  160. port: {{ .Values.master.port }}
  161. scheme: HTTP
  162. initialDelaySeconds: 10
  163. periodSeconds: 45
  164. successThreshold: 2
  165. failureThreshold: 100
  166. timeoutSeconds: 10
  167. livenessProbe:
  168. httpGet:
  169. path: /cluster/status
  170. port: {{ .Values.master.port }}
  171. scheme: HTTP
  172. initialDelaySeconds: 20
  173. periodSeconds: 30
  174. successThreshold: 1
  175. failureThreshold: 4
  176. timeoutSeconds: 10
  177. {{- if .Values.master.resources }}
  178. resources:
  179. {{ tpl .Values.master.resources . | nindent 12 | trim }}
  180. {{- end }}
  181. {{- $hostpath_exists := include "master.hostpath_exists" . -}}
  182. {{- if $hostpath_exists }}
  183. volumes:
  184. {{- if eq .Values.master.logs.type "hostPath" }}
  185. - name: seaweedfs-master-log-volume
  186. hostPath:
  187. path: /storage/logs/seaweedfs/master
  188. type: DirectoryOrCreate
  189. {{- end }}
  190. {{- if eq .Values.master.data.type "hostPath" }}
  191. - name: data-{{ .Release.Namespace }}
  192. hostPath:
  193. path: /ssd/seaweed-master/
  194. type: DirectoryOrCreate
  195. {{- end }}
  196. {{- if .Values.global.enableSecurity }}
  197. - name: security-config
  198. configMap:
  199. name: {{ template "seaweedfs.name" . }}-security-config
  200. - name: ca-cert
  201. secret:
  202. secretName: {{ template "seaweedfs.name" . }}-ca-cert
  203. - name: master-cert
  204. secret:
  205. secretName: {{ template "seaweedfs.name" . }}-master-cert
  206. - name: volume-cert
  207. secret:
  208. secretName: {{ template "seaweedfs.name" . }}-volume-cert
  209. - name: filer-cert
  210. secret:
  211. secretName: {{ template "seaweedfs.name" . }}-filer-cert
  212. - name: client-cert
  213. secret:
  214. secretName: {{ template "seaweedfs.name" . }}-client-cert
  215. {{- end }}
  216. {{ tpl .Values.master.extraVolumes . | indent 8 | trim }}
  217. {{- end }}
  218. {{- if .Values.master.nodeSelector }}
  219. nodeSelector:
  220. {{ tpl .Values.master.nodeSelector . | indent 8 | trim }}
  221. {{- end }}
  222. {{- $pvc_exists := include "volume.pvc_exists" . -}}
  223. {{- if $pvc_exists }}
  224. volumeClaimTemplates:
  225. {{- if eq .Values.master.data.type "persistentVolumeClaim"}}
  226. - metadata:
  227. name: data-{{ .Release.Namespace }}
  228. spec:
  229. accessModes: [ "ReadWriteOnce" ]
  230. storageClassName: {{ .Values.master.data.storageClass }}
  231. resources:
  232. requests:
  233. storage: {{ .Values.master.data.size }}
  234. {{- end }}
  235. {{- if eq .Values.master.logs.type "persistentVolumeClaim"}}
  236. - metadata:
  237. name: seaweedfs-master-log-volume
  238. spec:
  239. accessModes: [ "ReadWriteOnce" ]
  240. storageClassName: {{ .Values.master.logs.storageClass }}
  241. resources:
  242. requests:
  243. storage: {{ .Values.master.logs.size }}
  244. {{- end }}
  245. {{- end }}
  246. {{- end }}