Skip to content

Commit 067b60b

Browse files
NotYuShengclaude
andcommitted
feat: Add minio-mc bucket initialization Job to MinIO Helm chart
- Created bucket-init-job.yaml as Helm hook for post-install bucket creation - Uses minio/mc:RELEASE.2025-07-21T05-28-08Z image for bucket management - Configurable bucket list and policies via values.yaml - Implemented across all environments (staging, production, prestaging) - Job runs as Helm post-install hook with proper cleanup policies - Updated MinIO image versions to RELEASE.2025-07-23T15-54-02Z across environments - Addresses missing minio_mc functionality from docker-compose setup Resolves bucket initialization that was previously handled by docker-compose createbucket service. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 80d4deb commit 067b60b

5 files changed

Lines changed: 128 additions & 4 deletions

File tree

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{{- if .Values.bucketInit.enabled }}
2+
apiVersion: batch/v1
3+
kind: Job
4+
metadata:
5+
name: {{ include "minio.fullname" . }}-bucket-init
6+
labels:
7+
{{- include "minio.labels" . | nindent 4 }}
8+
app.kubernetes.io/component: bucket-init
9+
annotations:
10+
"helm.sh/hook": post-install,post-upgrade
11+
"helm.sh/hook-weight": "1"
12+
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
13+
spec:
14+
template:
15+
metadata:
16+
labels:
17+
{{- include "minio.selectorLabels" . | nindent 8 }}
18+
app.kubernetes.io/component: bucket-init
19+
spec:
20+
restartPolicy: OnFailure
21+
{{- with .Values.imagePullSecrets }}
22+
imagePullSecrets:
23+
{{- toYaml . | nindent 8 }}
24+
{{- end }}
25+
serviceAccountName: {{ include "minio.serviceAccountName" . }}
26+
securityContext:
27+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
28+
containers:
29+
- name: bucket-init
30+
securityContext:
31+
{{- toYaml .Values.securityContext | nindent 12 }}
32+
image: "{{ .Values.bucketInit.image.repository }}:{{ .Values.bucketInit.image.tag }}"
33+
imagePullPolicy: {{ .Values.bucketInit.image.pullPolicy }}
34+
env:
35+
- name: MINIO_ROOT_USER
36+
valueFrom:
37+
secretKeyRef:
38+
name: {{ include "minio.secretName" . }}
39+
key: MINIO_ROOT_USER
40+
- name: MINIO_ROOT_PASSWORD
41+
valueFrom:
42+
secretKeyRef:
43+
name: {{ include "minio.secretName" . }}
44+
key: MINIO_ROOT_PASSWORD
45+
command:
46+
- /bin/sh
47+
- -c
48+
- |
49+
set -e
50+
echo "Waiting for MinIO to be ready..."
51+
until mc alias set minio-local http://{{ include "minio.fullname" . }}:9000 $MINIO_ROOT_USER $MINIO_ROOT_PASSWORD; do
52+
echo "MinIO not ready yet, waiting..."
53+
sleep 2
54+
done
55+
echo "MinIO is healthy, creating buckets..."
56+
{{- range .Values.bucketInit.buckets }}
57+
echo "Creating bucket: {{ . }}"
58+
mc mb --ignore-existing minio-local/{{ . }}
59+
{{- end }}
60+
{{- if .Values.bucketInit.policies }}
61+
echo "Setting bucket policies..."
62+
{{- range .Values.bucketInit.policies }}
63+
echo "Setting policy for {{ .bucket }}: {{ .policy }}"
64+
mc anonymous set {{ .policy }} minio-local/{{ .bucket }}
65+
{{- end }}
66+
{{- end }}
67+
echo "Bucket initialization completed successfully"
68+
resources:
69+
{{- toYaml .Values.bucketInit.resources | nindent 12 }}
70+
{{- with .Values.nodeSelector }}
71+
nodeSelector:
72+
{{- toYaml . | nindent 8 }}
73+
{{- end }}
74+
{{- with .Values.tolerations }}
75+
tolerations:
76+
{{- toYaml . | nindent 8 }}
77+
{{- end }}
78+
{{- end }}

helm/minio/values-prestaging.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@ replicaCount: 1
66
# Use official MinIO image
77
image:
88
repository: minio/minio
9-
tag: "RELEASE.2024-01-16T16-07-38Z"
9+
tag: "RELEASE.2025-07-23T15-54-02Z"
1010
pullPolicy: Always
1111

12+
# Prestaging bucket initialization
13+
bucketInit:
14+
enabled: true
15+
image:
16+
repository: minio/mc
17+
tag: "RELEASE.2025-07-21T05-28-08Z"
18+
pullPolicy: Always
19+
1220
# Reduced resources for prestaging
1321
resources:
1422
limits:

helm/minio/values-prod.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@ replicaCount: 1
66
# Use official MinIO image with specific stable version
77
image:
88
repository: minio/minio
9-
tag: "RELEASE.2024-01-16T16-07-38Z"
9+
tag: "RELEASE.2025-07-23T15-54-02Z"
1010
pullPolicy: Always
1111

12+
# Production bucket initialization
13+
bucketInit:
14+
enabled: true
15+
image:
16+
repository: minio/mc
17+
tag: "RELEASE.2025-07-21T05-28-08Z"
18+
pullPolicy: Always
19+
1220
# Production resources
1321
resources:
1422
limits:

helm/minio/values-staging.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@ replicaCount: 1
66
# Use official MinIO image
77
image:
88
repository: minio/minio
9-
tag: "RELEASE.2024-01-16T16-07-38Z"
9+
tag: "RELEASE.2025-07-23T15-54-02Z"
1010
pullPolicy: Always
1111

12+
# Staging bucket initialization
13+
bucketInit:
14+
enabled: true
15+
image:
16+
repository: minio/mc
17+
tag: "RELEASE.2025-07-21T05-28-08Z"
18+
pullPolicy: Always
19+
1220
# Staging resources
1321
resources:
1422
limits:

helm/minio/values.yaml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ image:
88
repository: minio/minio
99
pullPolicy: Always
1010
# Overrides the image tag whose default is the chart appVersion.
11-
tag: ""
11+
tag: "RELEASE.2025-07-23T15-54-02Z"
1212

1313
imagePullSecrets: []
1414
nameOverride: ""
@@ -204,6 +204,28 @@ podDisruptionBudget:
204204
deploymentStrategy:
205205
type: Recreate # MinIO typically uses Recreate for single-node
206206

207+
# Bucket initialization configuration using minio/mc
208+
bucketInit:
209+
enabled: true
210+
image:
211+
repository: minio/mc
212+
tag: "RELEASE.2025-07-21T05-28-08Z"
213+
pullPolicy: Always
214+
# List of buckets to create
215+
buckets:
216+
- omnifiles
217+
# Optional bucket policies
218+
policies: []
219+
# - bucket: omnifiles
220+
# policy: download # none, download, upload, public
221+
resources:
222+
limits:
223+
cpu: 100m
224+
memory: 128Mi
225+
requests:
226+
cpu: 50m
227+
memory: 64Mi
228+
207229
# Resource quota (optional)
208230
serviceMonitor:
209231
enabled: false

0 commit comments

Comments
 (0)