Wordpress has been written as stateful application. However, when it comes to container strategy, some hacking is needed.
In particular, I was thinking about a storage configuration as follows:
/var/www/html/wp-content/
/var/www/html/wp-admin/
/var/www/html/wp-content/uploads
The k8s manifest should look like:
volumeMounts:
- name: admin
mountPath: /var/www/html/wp-admin/
- name: content
mountPath: /var/www/html/
- name: uploads
mountPath: /var/www/html/wp-content/uploads/
Since I never tried this setup, does it make sense? Do you have any additional suggestions to take into account in having an ideal Wordpress deployment on Kubernetes?
Separation strategy:
Furthermore, are there well-known strategy to separate the WP-Admin in a completely separated container?
WordPress was not designed for containers. Your strategy will break quickly.
Set up an NFS server in a container to store the entire configuration and files for Apache, PHP, Let's Encrypt, WordPress and logging.
Don't forget to create a separate instance for MySQL.
Basically, you want everything related to this WordPress instance stored on NFS file shares. You will want to hand install everything so that you know exactly where the files are being stored.
When you are finished you will have a container that only mounts NFS shares and launches services. The data/files for the services is on NFS shares.
MySQL provides the database. I recommend Cloud SQL to improve reliability and split the most critical service away from Kubernetes because backups and snapshots are much easier to create and schedule.
Furthermore, are there well-known strategy to separate the WP-Admin in a completely separated container?
Do not attempt that. You want the root and all subfolders of your WordPress website stored as an NFS share. Do not try to split the directories apart.
an NFS-based (Google Filestore) PVC for the user uploads: mount /var/www/html/wp-content/uploads
Make sure you double-check pricing. This is an expensive solution for storing WordPress. I recommend creating an NFS container connected to a persistent volume and using NFS to carve out the data. This does bring up a single point of failure for NFS. Depending on how reliable you want the setup to be, Filestore may be the correct solution. Otherwise, you can also look at Active/Passive NFS or even NFS clustering on multiple containers.