yes cm is present in volumes section and its same cm
is the shared-files
volume an emptyDir
- yes
yup thanks lets check tomorrow.
I have found the question, which is called “Fix issue with volume mounts in kubernetes” - so the clue is in the question!!
The two containers need to have the same path for the web files, i.e. /var/www/html
so the mount path in the nginx container is incorrect.
Is the
shared-files
volume anemptyDir
? Could be in that case it should be mounted on/var/www/html
It is the case, so correct that, delete and recreate the pod, then copy the php file.
Press the webserver button and it works
Yup, i added the below volume mount in nginx container:
- mountPath: /var/www/html
name: shared-files
and then copied /home/thor/index.php to nginx-container
k cp /home/thor/index.php nginx-phpfpm:/var/www/html -c nginx-container
Website is now accessible.
Thank you so much Alistair.
I think you may need to explain this better. And possibly provide a step by step guide if you wish. The above is not easy to comprehend. Thank you.
kubectl get pod nginx-phpfpm -o yaml > pod.yaml
modify the pod.yaml file on the nginx-container volueMounts:
volumeMounts:
- mountPath: /usr/share/nginx/html
name: shared-files
now will be
volumeMounts:
- mountPath: /var/www/html
name: shared-files
delete the pod
kubectl delete pod nginx-phpfpm
recreate the pod
kubectl apply -f pod.yaml
copy the file
kubectl cp index.php default/nginx-phpfpm:/var/www/html/ --container=nginx-container