/cloud-run-minio

Example config for running Minio server on Google Cloud Run

Primary LanguageDockerfileMIT LicenseMIT

Minio + Google Cloud Run

This repository shows how to run Minio as gateway to Google Cloud Storage and deploy it to Google Cloud Run.

Prerequisites:

Step 1: Create service account

PROJECT_ID="$(gcloud config get-value project -q)"
SVCACCT_NAME=minio-sa

Create a service account:

gcloud iam service-accounts create "${SVCACCT_NAME?}"

Find the email address of this account:

SVCACCT_EMAIL="$(gcloud iam service-accounts list \
  --filter="name:${SVCACCT_NAME?}@"  \
  --format=value\(email\))"

Step 2: Assign permissions to the service account

We will grant to the service account Storage Admin: role, so it can access the Google Cloud Storage.

gcloud projects add-iam-policy-binding "${PROJECT_ID?}" \
   --member="serviceAccount:${SVCACCT_EMAIL?}" \
   --role="roles/storage.admin"

Step 3: Upload minio image

Check the Dockerfile and update it with your settings.

docker build -t gcr.io/"${PROJECT_ID?}"/minio .
docker push gcr.io/"${PROJECT_ID?}"/minio

Note: Your registry name may be something like "eu.gcr.io" if your project location is Europe. There are four options.

Step 4: Deploy to Cloud Run

We will now deploy our container to Google Cloud Run:

gcloud beta run deploy my-cloud-run-minio \
    --platform managed \
    --region us-central1 \
    --service-account "${SVCACCT_EMAIL?}" \
    --image gcr.io/"${PROJECT_ID?}"/minio \
    --memory 128Mi \
    --set-env-vars MINIO_ACCESS_KEY=minio \
    --set-env-vars MINIO_SECRET_KEY=minio123 \
    --allow-unauthenticated

Note: Currently Cloud Run is available only in us-central1 region.

Optinal Step: Specify storage class for your bucket

You can specify the bucket storage class of your bucket like this:

gsutil mb -p "${PROJECT_ID?}" -l us-central1 -c nearline  gs://some-bucket

Clean up

Delete the service account you created:

gcloud iam service-accounts delete "${SVCACCT_EMAIL?}"

Delete the Cloud Run application you deployed:

gcloud beta run services delete my-cloud-run-minio \
    --platform managed \
    --region us-central1

Please provide your feedback, recommendations or improvements 🙇