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

ghz 1years ago ⋅ 7392 views

Question

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.


Answer

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.