statefulset.yaml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. {{- /*
  2. Copyright VMware, Inc.
  3. SPDX-License-Identifier: APACHE-2.0
  4. */}}
  5. {{- if (eq .Values.mode "distributed") }}
  6. {{- $fullname := include "common.names.fullname" . }}
  7. {{- $headlessService := printf "%s-headless" (include "common.names.fullname" .) | trunc 63 }}
  8. {{- $releaseNamespace := include "common.names.namespace" . }}
  9. {{- $clusterDomain := .Values.clusterDomain }}
  10. {{- $apiPort := toString .Values.containerPorts.api }}
  11. {{- $replicaCount := int .Values.statefulset.replicaCount }}
  12. {{- $zoneCount := int .Values.statefulset.zones }}
  13. {{- $drivesPerNode := int .Values.statefulset.drivesPerNode }}
  14. {{- $mountPath := .Values.persistence.mountPath }}
  15. apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }}
  16. kind: StatefulSet
  17. metadata:
  18. name: {{ $fullname }}
  19. namespace: {{ $releaseNamespace | quote }}
  20. labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
  21. {{- if .Values.commonAnnotations }}
  22. annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  23. {{- end }}
  24. spec:
  25. {{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.podLabels .Values.commonLabels ) "context" . ) }}
  26. selector:
  27. matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
  28. serviceName: {{ $headlessService }}
  29. replicas: {{ mul $zoneCount $replicaCount }}
  30. podManagementPolicy: {{ .Values.statefulset.podManagementPolicy }}
  31. {{- if .Values.statefulset.updateStrategy }}
  32. updateStrategy: {{- toYaml .Values.statefulset.updateStrategy | nindent 4 }}
  33. {{- end }}
  34. template:
  35. metadata:
  36. labels: {{- include "common.labels.standard" ( dict "customLabels" $podLabels "context" $ ) | nindent 8 }}
  37. {{- if or .Values.podAnnotations (include "minio.createSecret" .) }}
  38. annotations:
  39. {{- if (include "minio.createSecret" .) }}
  40. checksum/credentials-secret: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }}
  41. {{- end }}
  42. {{- if .Values.podAnnotations }}
  43. {{- include "common.tplvalues.render" ( dict "value" .Values.podAnnotations "context" $) | nindent 8 }}
  44. {{- end }}
  45. {{- end }}
  46. spec:
  47. {{- include "minio.imagePullSecrets" . | nindent 6 }}
  48. {{- if .Values.schedulerName }}
  49. schedulerName: {{ .Values.schedulerName }}
  50. {{- end }}
  51. serviceAccountName: {{ template "minio.serviceAccountName" . }}
  52. {{- if .Values.affinity }}
  53. affinity: {{- include "common.tplvalues.render" (dict "value" .Values.affinity "context" $) | nindent 8 }}
  54. {{- else }}
  55. affinity:
  56. podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAffinityPreset "customLabels" $podLabels "context" $) | nindent 10 }}
  57. podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAntiAffinityPreset "customLabels" $podLabels "context" $) | nindent 10 }}
  58. nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.nodeAffinityPreset.type "key" .Values.nodeAffinityPreset.key "values" .Values.nodeAffinityPreset.values) | nindent 10 }}
  59. {{- end }}
  60. {{- if .Values.nodeSelector }}
  61. nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.nodeSelector "context" $) | nindent 8 }}
  62. {{- end }}
  63. automountServiceAccountToken: {{ .Values.automountServiceAccountToken }}
  64. {{- if .Values.hostAliases }}
  65. hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.hostAliases "context" $) | nindent 8 }}
  66. {{- end }}
  67. {{- if .Values.tolerations }}
  68. tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.tolerations "context" $) | nindent 8 }}
  69. {{- end }}
  70. {{- if .Values.topologySpreadConstraints }}
  71. topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.topologySpreadConstraints "context" $) | nindent 8 }}
  72. {{- end }}
  73. {{- if .Values.priorityClassName }}
  74. priorityClassName: {{ .Values.priorityClassName | quote }}
  75. {{- end }}
  76. {{- if .Values.podSecurityContext.enabled }}
  77. securityContext: {{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 }}
  78. {{- end }}
  79. {{- if .Values.terminationGracePeriodSeconds }}
  80. terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
  81. {{- end }}
  82. {{- if or .Values.initContainers (and .Values.volumePermissions.enabled .Values.persistence.enabled) }}
  83. initContainers:
  84. {{- if .Values.initContainers }}
  85. {{- include "common.tplvalues.render" (dict "value" .Values.initContainers "context" $) | nindent 8 }}
  86. {{- end }}
  87. {{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
  88. - name: volume-permissions
  89. image: {{ template "minio.volumePermissions.image" . }}
  90. imagePullPolicy: {{ default "" .Values.volumePermissions.image.pullPolicy | quote }}
  91. command:
  92. - /bin/bash
  93. - -ec
  94. - |
  95. {{- if and .Values.persistence.enabled (gt $drivesPerNode 1) }}
  96. chown -R {{ .Values.containerSecurityContext.runAsUser }}:{{ .Values.podSecurityContext.fsGroup }} {{ range $diskId := until $drivesPerNode }}{{ $mountPath }}-{{ $diskId }} {{ end }}
  97. {{- else }}
  98. chown -R {{ .Values.containerSecurityContext.runAsUser }}:{{ .Values.podSecurityContext.fsGroup }} {{ $mountPath }}
  99. {{- end }}
  100. securityContext: {{- .Values.volumePermissions.containerSecurityContext | toYaml | nindent 12 }}
  101. {{- if .Values.volumePermissions.resources }}
  102. resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
  103. {{- end }}
  104. volumeMounts:
  105. {{- if and .Values.persistence.enabled (gt $drivesPerNode 1) }}
  106. {{- range $diskId := until $drivesPerNode }}
  107. - name: data-{{ $diskId }}
  108. mountPath: {{ $mountPath }}-{{ $diskId }}
  109. {{- end }}
  110. {{- else }}
  111. - name: data
  112. mountPath: {{ $mountPath }}
  113. {{- end }}
  114. {{- end }}
  115. {{- end }}
  116. containers:
  117. - name: minio
  118. image: {{ include "minio.image" . }}
  119. imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
  120. {{- if .Values.containerSecurityContext.enabled }}
  121. securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }}
  122. {{- end }}
  123. {{- if .Values.command }}
  124. command: {{- include "common.tplvalues.render" (dict "value" .Values.command "context" $) | nindent 12 }}
  125. {{- end }}
  126. {{- if .Values.args }}
  127. args: {{- include "common.tplvalues.render" (dict "value" .Values.args "context" $) | nindent 12 }}
  128. {{- end }}
  129. env:
  130. - name: BITNAMI_DEBUG
  131. value: {{ ternary "true" "false" .Values.image.debug | quote }}
  132. - name: MINIO_DISTRIBUTED_MODE_ENABLED
  133. value: "yes"
  134. - name: MINIO_DISTRIBUTED_NODES
  135. {{- $clusters := list }}
  136. {{- range $i := until $zoneCount }}
  137. {{- $factor := mul $i $replicaCount }}
  138. {{- $endIndex := sub (add $factor $replicaCount) 1 }}
  139. {{- $beginIndex := mul $i $replicaCount }}
  140. {{- $bucket := ternary (printf "%s-{0...%d}" $mountPath (sub $drivesPerNode 1)) $mountPath (gt $drivesPerNode 1) }}
  141. {{- $clusters = append $clusters (printf "%s-{%d...%d}.%s.%s.svc.%s:%s%s" $fullname $beginIndex $endIndex $headlessService $releaseNamespace $clusterDomain $apiPort $bucket) }}
  142. {{- end }}
  143. value: {{ join "," $clusters | quote }}
  144. - name: MINIO_SCHEME
  145. value: {{ ternary "https" "http" .Values.tls.enabled | quote }}
  146. - name: MINIO_FORCE_NEW_KEYS
  147. value: {{ ternary "yes" "no" .Values.auth.forceNewKeys | quote }}
  148. {{- if .Values.auth.useCredentialsFiles }}
  149. - name: MINIO_ROOT_USER_FILE
  150. value: "/opt/bitnami/minio/secrets/root-user"
  151. {{- else }}
  152. - name: MINIO_ROOT_USER
  153. valueFrom:
  154. secretKeyRef:
  155. name: {{ include "minio.secretName" . }}
  156. key: root-user
  157. {{- end }}
  158. {{- if .Values.auth.useCredentialsFiles }}
  159. - name: MINIO_ROOT_PASSWORD_FILE
  160. value: "/opt/bitnami/minio/secrets/root-password"
  161. {{- else }}
  162. - name: MINIO_ROOT_PASSWORD
  163. valueFrom:
  164. secretKeyRef:
  165. name: {{ include "minio.secretName" . }}
  166. key: root-password
  167. {{- end }}
  168. - name: MINIO_SKIP_CLIENT
  169. value: {{ ternary "yes" "no" (empty .Values.defaultBuckets) | quote }}
  170. {{- if .Values.defaultBuckets }}
  171. - name: MINIO_DEFAULT_BUCKETS
  172. value: {{ .Values.defaultBuckets }}
  173. {{- end }}
  174. - name: MINIO_BROWSER
  175. value: {{ ternary "off" "on" .Values.disableWebUI | quote }}
  176. - name: MINIO_PROMETHEUS_AUTH_TYPE
  177. value: {{ .Values.metrics.prometheusAuthType | quote }}
  178. {{- if .Values.tls.mountPath }}
  179. - name: MINIO_CERTS_DIR
  180. value: {{ .Values.tls.mountPath | quote }}
  181. - name: MINIO_CONSOLE_PORT_NUMBER
  182. value: {{ .Values.containerPorts.console | quote }}
  183. {{- end }}
  184. {{- if .Values.extraEnvVars }}
  185. {{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }}
  186. {{- end }}
  187. envFrom:
  188. {{- if .Values.extraEnvVarsCM }}
  189. - configMapRef:
  190. name: {{ include "common.tplvalues.render" (dict "value" .Values.extraEnvVarsCM "context" $) }}
  191. {{- end }}
  192. {{- if .Values.extraEnvVarsSecret }}
  193. - secretRef:
  194. name: {{ include "common.tplvalues.render" (dict "value" .Values.extraEnvVarsSecret "context" $) }}
  195. {{- end }}
  196. ports:
  197. - name: minio-api
  198. containerPort: {{ .Values.containerPorts.api }}
  199. protocol: TCP
  200. - name: minio-console
  201. containerPort: {{ .Values.containerPorts.console }}
  202. protocol: TCP
  203. {{- if .Values.customLivenessProbe }}
  204. livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customLivenessProbe "context" $) | nindent 12 }}
  205. {{- else if .Values.livenessProbe.enabled }}
  206. livenessProbe:
  207. httpGet:
  208. path: /minio/health/live
  209. port: minio-api
  210. scheme: {{ ternary "HTTPS" "HTTP" .Values.tls.enabled | quote }}
  211. initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
  212. periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
  213. timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
  214. successThreshold: {{ .Values.livenessProbe.successThreshold }}
  215. failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
  216. {{- end }}
  217. {{- if .Values.customReadinessProbe }}
  218. readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customReadinessProbe "context" $) | nindent 12 }}
  219. {{- else if .Values.readinessProbe.enabled }}
  220. readinessProbe:
  221. tcpSocket:
  222. port: minio-api
  223. initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
  224. periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
  225. timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
  226. successThreshold: {{ .Values.readinessProbe.successThreshold }}
  227. failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
  228. {{- end }}
  229. {{- if .Values.customStartupProbe }}
  230. startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.customStartupProbe "context" $) | nindent 12 }}
  231. {{- else if .Values.startupProbe.enabled }}
  232. startupProbe:
  233. tcpSocket:
  234. port: minio-api
  235. initialDelaySeconds: {{ .Values.startupProbe.initialDelaySeconds }}
  236. periodSeconds: {{ .Values.startupProbe.periodSeconds }}
  237. timeoutSeconds: {{ .Values.startupProbe.timeoutSeconds }}
  238. successThreshold: {{ .Values.startupProbe.successThreshold }}
  239. failureThreshold: {{ .Values.startupProbe.failureThreshold }}
  240. {{- end }}
  241. {{- if .Values.resources }}
  242. resources: {{- toYaml .Values.resources | nindent 12 }}
  243. {{- end }}
  244. {{- if .Values.lifecycleHooks }}
  245. lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.lifecycleHooks "context" $) | nindent 12 }}
  246. {{- end }}
  247. volumeMounts:
  248. {{- if .Values.auth.useCredentialsFiles }}
  249. - name: minio-credentials
  250. mountPath: /opt/bitnami/minio/secrets/
  251. {{- end }}
  252. {{- if .Values.tls.enabled }}
  253. - name: minio-certs
  254. mountPath: {{ default "/certs" .Values.tls.mountPath }}
  255. {{- end }}
  256. {{- if gt $drivesPerNode 1 }}
  257. {{- range $diskId := until $drivesPerNode }}
  258. - name: data-{{ $diskId }}
  259. mountPath: {{ $mountPath }}-{{ $diskId }}
  260. {{- end }}
  261. {{- else }}
  262. - name: data
  263. mountPath: {{ $mountPath }}
  264. {{- end }}
  265. {{- if .Values.extraVolumeMounts }}
  266. {{- include "common.tplvalues.render" (dict "value" .Values.extraVolumeMounts "context" $) | nindent 12 }}
  267. {{- end }}
  268. {{- if .Values.sidecars }}
  269. {{- include "common.tplvalues.render" (dict "value" .Values.sidecars "context" $) | nindent 8 }}
  270. {{- end }}
  271. volumes:
  272. {{- if .Values.auth.useCredentialsFiles }}
  273. - name: minio-credentials
  274. secret:
  275. secretName: {{ include "minio.secretName" . }}
  276. {{- end }}
  277. {{- if .Values.tls.enabled }}
  278. - name: minio-certs
  279. secret:
  280. secretName: {{ include "minio.tlsSecretName" . }}
  281. items:
  282. - key: tls.crt
  283. path: public.crt
  284. - key: tls.key
  285. path: private.key
  286. - key: ca.crt
  287. path: CAs/public.crt
  288. {{- end }}
  289. {{- if .Values.extraVolumes }}
  290. {{- include "common.tplvalues.render" (dict "value" .Values.extraVolumes "context" $) | nindent 8 }}
  291. {{- end }}
  292. {{- if and (not .Values.persistence.enabled) (gt $drivesPerNode 1) }}
  293. {{- range $diskId := until $drivesPerNode }}
  294. - name: data-{{ $diskId }}
  295. emptyDir: {}
  296. {{- end }}
  297. {{- else if not .Values.persistence.enabled }}
  298. - name: data
  299. emptyDir: {}
  300. {{- else }}
  301. volumeClaimTemplates:
  302. {{- if gt $drivesPerNode 1 }}
  303. {{- range $diskId := until $drivesPerNode }}
  304. - metadata:
  305. name: data-{{ $diskId }}
  306. labels: {{- include "common.labels.matchLabels" ( dict "customLabels" $.Values.commonLabels "context" $ ) | nindent 10 }}
  307. {{- if $.Values.persistence.annotations }}
  308. annotations: {{- include "common.tplvalues.render" ( dict "value" $.Values.persistence.annotations "context" $) | nindent 10 }}
  309. {{- end }}
  310. spec:
  311. accessModes:
  312. {{- range $.Values.persistence.accessModes }}
  313. - {{ . | quote }}
  314. {{- end }}
  315. resources:
  316. requests:
  317. storage: {{ $.Values.persistence.size | quote }}
  318. {{- include "common.storage.class" (dict "persistence" $.Values.persistence "global" $.Values.global) | nindent 8 }}
  319. {{- end }}
  320. {{- else }}
  321. - metadata:
  322. name: data
  323. labels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 10 }}
  324. {{- if .Values.persistence.annotations }}
  325. annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.persistence.annotations "context" $) | nindent 10 }}
  326. {{- end }}
  327. spec:
  328. accessModes:
  329. {{- range .Values.persistence.accessModes }}
  330. - {{ . | quote }}
  331. {{- end }}
  332. resources:
  333. requests:
  334. storage: {{ .Values.persistence.size | quote }}
  335. {{- include "common.storage.class" (dict "persistence" .Values.persistence "global" .Values.global) | nindent 8 }}
  336. {{- end }}
  337. {{- end }}
  338. {{- end }}