Google recently announced a new feature called volume mounts in preview. This feature aims to streamline the integration of cloud-native applications with shared data storage solutions, such as Cloud Storage buckets and NFS shares, directly within Cloud Run instances.
The volume mounts feature resides in Cloud Run, a fully managed container platform built on Google’s scalable infrastructure. By enabling containers to access storage bucket or file server content as though it were local, Google enhances file system semantics, offering developers a more familiar experience. This eliminates the need for complex solutions or alternative services previously required to access shared data.
Examples of using volume mounts include storing application configuration files, handling event-driven Cloud Storage operations, loading vector database files for applications like Langchain, and serving static websites more efficiently. For instance, developers can now mount Cloud Storage buckets to provide configurations to services or to directly serve static content for websites without the need to rebuild and redeploy container images after each update. This flexibility is beneficial for applications requiring regular static content or configuration updates.
Serving static content to websites example (Source: Google Cloud blog post)
Another example is that volume mounts facilitate the creation of event-driven Cloud Storage handlers, eliminating the need for custom code to fetch files from Cloud Storage. By mounting the relevant bucket, files can be accessed directly through the filesystem, streamlining the process.
Additionally, the ability to mount NFS storage, like a Cloud Filestore instance, is crucial for stateless services that rely on external databases, such as ChromaDB. This ensures consistent access to dynamically changing data without embedding it within the container.
Developers can mount a Cloud Storage bucket or any NFS file share using a gcloud command, update the Cloud Run YAML resource definition, or deploy it via Terraform. They can, for example, perform a source-based deployment to a new Cloud Run job and mount a Cloud Storage bucket with the following command:
gcloud beta run services update SERVICE \
--execution-environment gen2 \
--add-volume name=VOLUME_NAME,type=cloud-storage,bucket=BUCKET_NAME \
--add-volume-mount volume=VOLUME_NAME,mount-path=MOUNT_PATH
The introduction of volume mounts places Google Cloud Run in competition with similar offerings from AWS and Azure. AWS Fargate's integration with persistent storage volumes Azure Container Instances' (ACI) capability to mount Azure Files highlights the industry's move towards more flexible, scalable cloud services.
Etienne Fontaine, a site reliability engineer at BlaBlaCar, highlighted the competitive advantage Google Cloud Run might have; he tweeted:
I think it makes a difference compared to AWS with Fargate and EFS, for example.
More details on Google Cloud Run are available on the documentation website.