From b981a24adc1c3c5cbd1c4404d2447b0b6f5a1869 Mon Sep 17 00:00:00 2001 From: yiling Date: Sun, 18 Oct 2026 14:12:41 +0800 Subject: [PATCH] fix(k8s): configure s3 bucket cors rules in garage initialization --- k8s/garage.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/k8s/garage.yaml b/k8s/garage.yaml index 0494b674..eeebcc10 100644 --- a/k8s/garage.yaml +++ b/k8s/garage.yaml @@ -138,7 +138,7 @@ spec: - -c - | set -e - apk add --no-cache curl jq >/dev/null 2>&1 + apk add --no-cache curl jq aws-cli >/dev/null 2>&1 echo "Waiting for Garage Admin API to respond..." until curl -s -f -H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" http://garage:3903/v2/GetClusterStatus >/dev/null 2>&1; do @@ -196,4 +196,12 @@ spec: -d "{\"bucketId\": \"${BUCKET_ID}\", \"accessKeyId\": \"${S3_ACCESS_KEY_ID}\", \"permissions\": {\"read\": true, \"write\": true, \"owner\": true}}" >/dev/null || true fi + echo "Configuring S3 bucket CORS for web uploads..." + AWS_ACCESS_KEY_ID=${S3_ACCESS_KEY_ID} \ + AWS_SECRET_ACCESS_KEY=${S3_SECRET_ACCESS_KEY} \ + AWS_DEFAULT_REGION=garage \ + aws --endpoint-url http://garage:3900 s3api put-bucket-cors \ + --bucket "${S3_BUCKET}" \ + --cors-configuration '{"CORSRules":[{"AllowedHeaders":["*"],"AllowedMethods":["GET","PUT","POST","DELETE","HEAD"],"AllowedOrigins":["*"],"ExposeHeaders":["ETag"],"MaxAgeSeconds":3000}]}' || true + echo "✅ Garage S3 storage cluster initialized successfully!"