Stateful PHP app?

The answer is there in the post of @matthiasradde

Of course, creating a volume in a Kubernetes cluster is harder than doing it on a single machine. You need a network filesystem or your application needs to replicate it’s data across multiple nodes running multiple pod instance. This is what databases are doing. Your Wordpress will not do it. Here is some idea what you can use:

  • NFS volume: probably the easiest to configure, but you can have problems with file locking, NFS will be a single point of failure if the NFS server stops or becomes slow while your appliation is still running. And you will not have data redundancy by default (I heard some ways to do it, but there are better ways)
  • GlusterFS: Similar to NFS, but you can configure multiple server to replicate your data and have multiple servers to connect to in case one of them stops or you need to update them one by one.
  • Ceph: You will find it when you are searching for volumes for Kubernetes, but it is very much harder to configure and it is mainly for much larger amount of data than your wordpress will ever need.
  • Cloud storage: You can also buy some storage from a cloud povider like Amazon S3 In this case you need to handle the S3 API or mount the volume on your nodes. I don’t know if Kubernetes has a volume plugin for that. Of course S3 is not the only way, but I haven’t used any cloud storage yet.

For your use case, I think the best would be either NFS or GlusterFS, but I would recommend GlusterFS. Here is a good GlusterFS tutorial which I tried: How To Create a Redundant Storage Pool Using GlusterFS on Ubuntu 20.04 | DigitalOcean

Update:

When I last used Wordpress in a container, it was very hard to configure the volumes, because Wordpress had multiple writable folders. I ended up with using the whole wordpress on a volume and I used Docker only to run the application.