Google Cloud Storage
Prerequisites
To use Google Cloud Storage, you’ll need a bucket and a service account. You can create a service account here and a bucket here. If you want to write to the bucket, make sure the service account has theStorage Object User role for this bucket.
You can find a guide on creating a service account key here.
Mounting the bucket
To use the Google Cloud Storage we need to install thegcsfuse package. There’s simple template that can be used to create a container with the gcsfuse installed.
gcsfuse command.
Flags
The complete list of flags is available here.Allow the default user to access the files
To allow the default user to access the files, we can use the following flags:Amazon S3
To use Amazon S3, we can use thes3fs package. The template setup is similar to that of Google Cloud Storage.
s3fs command is used to mount the bucket to the sandbox.
Flags
The complete list of flags is available here.Allow the default user to access the files
To allow the default user to access the files, add the following flag:Cloudflare R2
For Cloudflare R2, we can use a setup very similar to S3. The template remains the same as for S3. However, the mounting differs slightly; we need to specify the endpoint for R2.Flags
It’s the same as for S3.Azure Blob Storage
Prerequisites
To use Azure Blob Storage, you’ll need a storage account and a container. The container must exist before you mount it. You can authenticate with the storage account access key or with a shared access signature (SAS) token for the container. Give the SAS token read and list permissions, plus write permission if you want to write files. Without list permission the mount fails.Mounting the container
To mount the container, install Microsoft’sblobfuse2 package from the Microsoft package repository in a template.
blobfuse2 reads its settings from a config file. Replace the placeholders with your storage account name, container name and access key.
blobfuse2.yaml
mem-size-mb is the memory blobfuse2 reserves for its block cache. Keep it below the sandbox’s memory. It must be at least prefetch times block-size-mb (176 MB here), or the mount fails. prefetch is set explicitly because its default grows with the number of vCPUs. disk-size-mb caps the disk space the block cache may use under path.
The container is mounted during the sandbox runtime using the blobfuse2 mount command.
sudo blobfuse2 unmount /home/user/bucket.
Authenticate with a SAS token
To use a SAS token instead of the access key, replace themode and account-key lines in the config file with:
Options
For the full list of config options, seeadvancedConfig.yaml in the azure-storage-fuse repository.
Allow the default user to access the files
The container is mounted withsudo, so only root can access it by default. The allow-other: true line in the config file lets the default user read and write the files.