<p>I am new to Kubernetes and I followed this tutorial for deploying WordPress application with k8s <a href="https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/" rel="nofollow noreferrer">Deploying WordPress</a>.</p>

<p>Let's say I have 3 pods with WordPress:4.8-apache image and I have a shared volume that mounts to each pod with the code of WordPress 4.8.
and let's say I want to update my WordPress to 4.9 without downtime.
So it has to be a point in time when there are some pods that have the code of WordPress 4.8 and some have the code of WordPress 4.9 but all the pods use the same Volume so how is it possible?
Are the new pods going to overwrite the code in the shared folder?</p>

<p>Potentially, this could happen. In this sense, it looks to me that this is not the proper way to deploy WordPress following the immutability principles (<a href="https://engineering.bitnami.com/articles/why-your-next-web-service-should-be-immutable.html" rel="nofollow noreferrer">https://engineering.bitnami.com/articles/why-your-next-web-service-should-be-immutable.html</a>). In order to avoid this kind of issues, my advice would be:</p>

<ul>
<li>Use environment variables for instead of persisting the wp-config.php configuration</li>
<li>Store all assets in a service like S3. There are plugins for this (<a href="https://deliciousbrains.com/wp-offload-s3/" rel="nofollow noreferrer">https://deliciousbrains.com/wp-offload-s3/</a>).</li>
<li>If you want to use plugins, build an image that bundles all of them (this may be a bit more difficult, but it would save you from the pain of having inconsistencies between the pods).</li>
</ul>

<p>There could be issues if the newer version implies changes in the database. In that case, I would add some kind of readiness check in the pod definition so, in case the old version fails, it gets removed from the service and only the newer WordPress pods are available. In this case, doing a database backup prior to upgrading would be a good choice as well.</p>
