What would be an ideal way to share writable volume across containers for a web server?

8/14/2017

The application in question is Wordpress, I need to create replicas for rolling deployment / scaling purposes.

It seem can't create more then 1 instance of the same container, if it uses a persistent volume (GCP term):

The Deployment "wordpress" is invalid: spec.template.spec.volumes[0].gcePersistentDisk.readOnly: Invalid value: false: must be true for replicated pods > 1; GCE PD can only be mounted on multiple machines if it is read-only

What are my options? There will be occasional writes and many reads. Ideally writable by all containers. I'm hesitant to use the network file systems as I'm not sure whether they'll provide sufficient performance for a web application (where page load is rather critical).

One idea I have is, create a master container (write and read permission) and slaves (read only permission), this could work - I'll just need to figure out the Kubernetes configuration required.

-- Chris Stryczynski
containers
google-cloud-platform
google-cloud-storage
kubernetes

3 Answers

9/26/2018

You can use Regional Persistent Disk. It can be mounted to many nodes (hence pods) in RW more. These nodes can be spread across two zones within one region. Regional PDs can be backed by standard or SSD disks. Just note that as of now (september 2018) they are still in beta and may be subject to backward incompatible changes.

Check the complete spec here: https://cloud.google.com/compute/docs/disks/#repds

-- Jen
Source: StackOverflow

8/15/2017

In https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistent-volumes you can see a table with the possible storage classes that allow ReadWriteMany (the option you are looking for).

  • AzureFile (not suitable if you are using GCP)
  • CephFS
  • Glusterfs
  • Quobyte
  • NFS
  • PortworxVolume

The one that I've tried is that of NFS. I had no issues with it, but I guess you should also consider potential performance issues. However, if the writes are to be occassional, it shouldn't be much of an issue.

-- Javier Salmeron
Source: StackOverflow

9/2/2017

I think what you are trying to solve is having a central location for wordperss media files, in that case this would be a better solution: https://wordpress.org/plugins/gcs/

Making your kubernetes workload truly stateless and you can scale horizontally.

-- Or Elimelech
Source: StackOverflow