Zalán Meggyesi
Zalán Meggyesi

Reputation: 654

Attaching a disk to multiple GCE instances with one write access

I'm thinking about upgrading my company's integration server with a the repos on a separate disk that would be shared with a backup server. Like so:

[Main Integration Server] ---R/W--- [Repo Vdisk] ---R/O--- [Backup Integration Server]

My problem is that according to the GCE docs, if I attach the same Vdisk to more than one instance, all instances must only access the disk in read-only mode. What I'm looking to do would be to have one instance access it in read-write, and one in read-only mode.

Is this at all possible without powering up a third instance to act as a sort of "storage server"?

Upvotes: 2

Views: 2826

Answers (2)

Chris Madden
Chris Madden

Reputation: 2650

Unless you have a shared filesystem you can't read and write from multiple VMs to a single disk, regardless of what Persistent Disk (PD) supports. The use case for a PD with read-only attachments is for sharing of static content; check a blog I wrote for more on those use cases.

In your situation you need shared storage could look into:

  • Managed options:
  • Self-managed options:
    • Build yoruself NFS or SMB server. If you have a very large content repository to share build your own storage server with using Hyperdisk Throughput storage and dial down the provisioned MiBs for a very cost effective solution

GCSFuse was also mentioned in the comments but I don't think it is suitable for the question asked; it's optimized for read workloads of multi MB size files and not a general purpose read/write workload.

Upvotes: 0

Misha Brukman
Misha Brukman

Reputation: 13424

As you quoted from the docs and as mentioned in my earlier answer, if you attach a single persistent disk to multiple instances, they must all mount it in read-only mode.

Since you're looking for a fully-managed storage alternative so you don't have to run and manage another VM yourself, consider using Google Cloud Storage and mount your bucket with gcsfuse which will make it look like a regular mounted filesystem.

Upvotes: 1

Related Questions