I'm having an issue right now when trying to create a PHP (Laravel) pod in my Kubernetes cluster. As php-fpm is a service run by the user www-data, he doesn't have access to the environments variables that Docker or Kubernetes sets up, which is the source of my problem.
We have beta and production pods, and previously, the only thing I did was setup an environment variable in my Kubernetes deployment which would tell the container if it had to use the beta or the prod configuration.
Sadly, since the php-fpm process can't access them, this is not possible. Is there a clean way to handle this? One way I can think of doing it right now is to put my two different .env files (config file for Laravel) in two different secrets in Kubernetes, then after that have a script as my Docker image's entrypoint that copies the right .env at the root of the project since the script will have access to the ENV variables.
If someone has a cleaner way in mind, I'm all ears!
I ended up using the solution I proposed in my original post, thanks for trying to help! It works fine, I was just looking for something a bit cleaner!
You could put the clear_env = no
in your php-fpm.conf or a file included from it, as discussed here.