Issue summary:
I’m working on the nginx-phpfpm Kubernetes lab. The pod is running, but the Website button shows 404.
Pod has two containers:
nginx-containerphp-fpm-container
From kubectl describe pod nginx-phpfpm:
-
nginx-containermounts shared volume at:
/usr/share/nginx/html
-
php-fpm-containermounts same shared volume at:
/var/www/html
But the mounted Nginx config still shows:
root /var/www/html;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;fastcgi_pass 127.0.0.1:9000;
So Nginx is looking for files under /var/www/html, but inside the Nginx container the document root should be /usr/share/nginx/html.
Expected config should probably be:
root /usr/share/nginx/html;fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;fastcgi_pass 127.0.0.1:9000;
Also, /etc/nginx/nginx.conf is mounted from ConfigMap using subPath, so direct sed -i inside the container fails with:
sed: cannot rename /etc/nginx/xxxx: Device or resource busy
Even after editing/patching the ConfigMap, the running container still shows old settings via:
kubectl exec nginx-phpfpm -c nginx-container -- nginx -T | grep -E "root|fastcgi_pass|SCRIPT_FILENAME"
Question: Since the pod appears to be standalone and deleting it removes it permanently, what is the correct way to make the updated ConfigMap take effect without losing the pod?