Where WordPress install is located on Google Cloud Kubernetes Cluster Where WordPress install is located on Google Cloud Kubernetes Cluster kubernetes kubernetes

Where WordPress install is located on Google Cloud Kubernetes Cluster


As you described, your application is crashing because of a change you have made in the code. This is making your website to fail and your pod is configured to check if the website is running fine and if not, the container will be restarted. The configuration that makes it happen is the LivenessProbe and the ReadinessProbe.

The problem here is that prevents you from fixing the problem.

The good news is that your data is saved under /var/www/html and this directory is on a external storage.

So, the easiest solution is to create a new pod and attach this storage to this pod. Problem is that this storage cannot be mounted on more than one container at the same time.

Creating this new pod, requires you to temporarily remove your wordpress pod. I know, it may be scary but we will recreate it after.

I reproduced your scenario and tested these steps. So Let's start. (All steps as mandatory)

Before we start, let's save your market-engine-wordpress manifest:

$ kubectl get statefulsets market-engine-wordpress -o yaml > market-engine-wordpress.yaml

Delete your wordpress statefulset:

$ kubectl delete statefulsets market-engine-wordpress

This commands delete the instruction that creates your wordpress pod.

Now, let's create a new pod using the following manifest:

apiVersion: v1kind: Podmetadata:  name: fenix   namespace: kalm-system  spec:  volumes:  - name: market-engine-wordpress-pvc    persistentVolumeClaim:      claimName: market-engine-wordpress-pvc-market-engine-wordpress-0      containers:  - name: ubuntu    image: ubuntu    command: ['sh', '-c', "sleep 36000"]    volumeMounts:    - mountPath: /var/www/html      name: market-engine-wordpress-pvc      subPath: wp

To create this pod, save this content in a file as fenix.yaml and run the following command:

$ kubectl apply -f fenix.yaml

Check if the pod is ready:

$ kubectl get pods fenixNAME         READY   STATUS    RESTARTS   AGEfenix        1/1     Running   0          5m

From this point, you can connect to this pod and fix your functions.php file:

$ kubectl exec -ti fenix -- bashroot@fenix:/# cd /var/www/html/wp-includes/root@fenix:/var/www/html/wp-includes# 

When you are done fixing your code, we can delete this pod and re-create your wordpress pod.

$ kubectl delete pod fenix pod "fenix" deleted
$ kubectl apply -f market-engine-wordpress.yaml statefulset.apps/market-engine-wordpress created

Check if the pod is ready:

$ kubectl get pod market-engine-wordpress-0 NAME                        READY   STATUS    RESTARTS   AGEmarket-engine-wordpress-0   2/2     Running   0          97s

If you need to exec into the wordpress container, your application uses the concept of multi-container pod and connecting to the right container requires you to indicate what container you want to connect.

To check how many containers and the name of which one you can run kubectl get pod mypod -o yaml or run kubectl describe pod mypod.

To finally exec into it, use the following command:

$ kubectl exec -ti market-engine-wordpress-0 -c wordpress -- bashroot@market-engine-wordpress-0:/var/www/html#