mirror of
https://github.com/pgsty/minio.git
synced 2026-08-10 00:03:29 +03:00
e071bb77e4
helm/minio becomes helm/silo: chart name silo, version 6.0.0 -> 7.0.0, the MinIO wordmark icon replaced with the project's own, image.repository and mcImage.repository pointing at pgsty/silo, and the container command changed to silo. User-visible titles, comments and documentation links are rebranded. The MINIO_* environment variables and every existing values key are kept - the first Silo chart is a rename, not a values-schema migration. The hard problem is that a chart rename normally rewrites Kubernetes resource identity, and a StatefulSet's selector and volumeClaimTemplate are immutable. An existing release upgraded carelessly would either fail or orphan its PVCs. Two things address that: - Templates no longer derive the container name from .Chart.Name. It comes from a helper, so nameOverride can pin it, which means an existing release can be upgraded with nameOverride=minio, fullnameOverride=<existing-fullname> and serviceAccount.name=minio-sa and render byte-stable identity while switching chart and image. - helm-migration-guard and verify-helm-migration.sh make that a gate rather than a documented hope. The script lints the chart, renders it in distributed and standalone modes plus the optional templates, then renders the legacy chart from a pinned commit and the new chart with those three overrides and compares resource identity. The guard additionally rejects any rendered container still pulling pgsty/minio or invoking /usr/bin/minio. It runs through a pinned alpine/helm image when helm is not installed locally, so the gate does not depend on the developer's machine. Currently green over 7 compared resources. Rollback is asymmetric and the README says so: the old chart with the new image survives via the entrypoint argv shim, but the new chart with an old MinIO image does not, because `silo server` is not a command that binary knows. Only `helm rollback` is supported, never an image-only downgrade. Not addressed here: the default image tag is pgsty/silo:RELEASE.2026-08-04T00-00-00Z, which does not exist yet. The chart must not be published until the first Silo image is pushed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
124 lines
3.5 KiB
Plaintext
124 lines
3.5 KiB
Plaintext
#!/bin/sh
|
|
set -e # Have script exit in the event of a failed command.
|
|
|
|
{{- if .Values.configPathmc }}
|
|
MC_CONFIG_DIR="{{ .Values.configPathmc }}"
|
|
MC="/usr/bin/mc --insecure --config-dir ${MC_CONFIG_DIR}"
|
|
{{- else }}
|
|
MC="/usr/bin/mc --insecure"
|
|
{{- end }}
|
|
|
|
# connectToSilo
|
|
# Use a check-sleep-check loop to wait for Silo service to be available
|
|
connectToSilo() {
|
|
SCHEME=$1
|
|
ATTEMPTS=0
|
|
LIMIT=29 # Allow 30 attempts
|
|
set -e # fail if we can't read the keys.
|
|
ACCESS=$(cat /config/rootUser)
|
|
SECRET=$(cat /config/rootPassword)
|
|
set +e # The connections to Silo are allowed to fail.
|
|
echo "Connecting to Silo server: $SCHEME://$MINIO_ENDPOINT:$MINIO_PORT"
|
|
MC_COMMAND="${MC} alias set mysilo $SCHEME://$MINIO_ENDPOINT:$MINIO_PORT $ACCESS $SECRET"
|
|
$MC_COMMAND
|
|
STATUS=$?
|
|
until [ $STATUS = 0 ]; do
|
|
ATTEMPTS=$(expr $ATTEMPTS + 1)
|
|
echo \"Failed attempts: $ATTEMPTS\"
|
|
if [ $ATTEMPTS -gt $LIMIT ]; then
|
|
exit 1
|
|
fi
|
|
sleep 2 # 1 second intervals between attempts
|
|
$MC_COMMAND
|
|
STATUS=$?
|
|
done
|
|
set -e # reset `e` as active
|
|
return 0
|
|
}
|
|
|
|
# checkBucketExists ($bucket)
|
|
# Check if the bucket exists, by using the exit code of `mc ls`
|
|
checkBucketExists() {
|
|
BUCKET=$1
|
|
CMD=$(${MC} stat mysilo/$BUCKET >/dev/null 2>&1)
|
|
return $?
|
|
}
|
|
|
|
# createBucket ($bucket, $policy, $purge)
|
|
# Ensure bucket exists, purging if asked to
|
|
createBucket() {
|
|
BUCKET=$1
|
|
POLICY=$2
|
|
PURGE=$3
|
|
VERSIONING=$4
|
|
OBJECTLOCKING=$5
|
|
|
|
# Purge the bucket, if set & exists
|
|
# Since PURGE is user input, check explicitly for `true`
|
|
if [ $PURGE = true ]; then
|
|
if checkBucketExists $BUCKET; then
|
|
echo "Purging bucket '$BUCKET'."
|
|
set +e # don't exit if this fails
|
|
${MC} rm -r --force mysilo/$BUCKET
|
|
set -e # reset `e` as active
|
|
else
|
|
echo "Bucket '$BUCKET' does not exist, skipping purge."
|
|
fi
|
|
fi
|
|
|
|
# Create the bucket if it does not exist and set objectlocking if enabled (NOTE: versioning will be not changed if OBJECTLOCKING is set because it enables versioning to the Buckets created)
|
|
if ! checkBucketExists $BUCKET; then
|
|
if [ ! -z $OBJECTLOCKING ]; then
|
|
if [ $OBJECTLOCKING = true ]; then
|
|
echo "Creating bucket with OBJECTLOCKING '$BUCKET'"
|
|
${MC} mb --with-lock mysilo/$BUCKET
|
|
elif [ $OBJECTLOCKING = false ]; then
|
|
echo "Creating bucket '$BUCKET'"
|
|
${MC} mb mysilo/$BUCKET
|
|
fi
|
|
elif [ -z $OBJECTLOCKING ]; then
|
|
echo "Creating bucket '$BUCKET'"
|
|
${MC} mb mysilo/$BUCKET
|
|
else
|
|
echo "Bucket '$BUCKET' already exists."
|
|
fi
|
|
fi
|
|
|
|
# set versioning for bucket if objectlocking is disabled or not set
|
|
if [ $OBJECTLOCKING = false ]; then
|
|
if [ ! -z $VERSIONING ]; then
|
|
if [ $VERSIONING = true ]; then
|
|
echo "Enabling versioning for '$BUCKET'"
|
|
${MC} version enable mysilo/$BUCKET
|
|
elif [ $VERSIONING = false ]; then
|
|
echo "Suspending versioning for '$BUCKET'"
|
|
${MC} version suspend mysilo/$BUCKET
|
|
fi
|
|
else
|
|
echo "No versioning action for '$BUCKET'"
|
|
fi
|
|
else
|
|
echo "Bucket '$BUCKET' versioning unchanged."
|
|
fi
|
|
|
|
# At this point, the bucket should exist, skip checking for existence
|
|
# Set policy on the bucket
|
|
echo "Setting policy of bucket '$BUCKET' to '$POLICY'."
|
|
${MC} anonymous set $POLICY mysilo/$BUCKET
|
|
}
|
|
|
|
# Try connecting to Silo instance
|
|
{{- if .Values.tls.enabled }}
|
|
scheme=https
|
|
{{- else }}
|
|
scheme=http
|
|
{{- end }}
|
|
connectToSilo $scheme
|
|
|
|
{{ if .Values.buckets }}
|
|
{{ $global := . }}
|
|
# Create the buckets
|
|
{{- range .Values.buckets }}
|
|
createBucket {{ tpl .name $global }} {{ .policy | default "none" | quote }} {{ .purge | default false }} {{ .versioning | default "" }} {{ .objectlocking | default false }}{{- end }}
|
|
{{- end }}
|