Fix Issue with VolumeMounts in Kubernetes Kodekloud

 

Question: We deployed a Nginx and PHPFPM based setup on Kubernetes cluster last week and it had been working fine. This morning one of the team members made a change somewhere which caused some issues, and it stopped working. Please look into the issue and fix it:

The pod name is nginx-phpfpm and configmap name is nginx-config. Figure out the issue and fix the same.

Once issue is fixed, copy /home/thor/index.php file from jump host into nginx-container under nginx document root and you should be able to access the website using Website button on top bar.

Note: The kubectl utility on jump_host has been configured to work with the kubernetes cluster.


Solution:

At first check the configmap to know the url and port, and page location. Here it is /var/www/html

kubectl get cm

Then export the pod yaml using this command

kubectl get po nginx-phpfmp -o yaml > /tmp/nginx.yaml

Edit the nginx.yaml. Replace all /usr/share/nginx/html to /var/www/html

Then force apply or replace the yaml

kubectl replace -f /tmp/nginx.yaml --force

Copy the index.php to /var/www/html folder of container

kubectl cp index.php nginx-phpfpm:/var/www/html

At last, check the site

kubectl exec -it nginx-phpfpm bash

curl -I http://localhost:8099


Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment