#!/bin/bash # Safe MinIO bucket initialization via Job (credentials in Secret, not env) # Usage: ./minio-bucket-init.sh [bucket2] ... set -euo pipefail NAMESPACE="${1:?Missing namespace}" shift BUCKETS=("$@") if [ ${#BUCKETS[@]} -eq 0 ]; then echo "Usage: $0 [bucket2] ..." >&2 exit 1 fi # Create Secret with Minio credentials (safe: sourced from env, not exposed in pod) kubectl create secret generic minio-creds -n "$NAMESPACE" \ --from-literal=MINIO_ROOT_USER="${MINIO_ROOT_USER:?Missing MINIO_ROOT_USER}" \ --from-literal=MINIO_ROOT_PASSWORD="${MINIO_ROOT_PASSWORD:?Missing MINIO_ROOT_PASSWORD}" \ --dry-run=client -o yaml | kubectl apply -f - # Create init Job that mounts Secret as volume, preventing env exposure BUCKET_ARGS=$(printf '"%s", ' "${BUCKETS[@]}" | sed 's/, $//') kubectl apply -f - <