Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

joaogl's avatar

Laravel on Kubernetes

Hello,

I've been trying to get laravel to run on kubernetes and to start up with I'm trying to get it up using this first: https://github.com/markhilton/larakube

With a few tweeks and so on I managed to get it to work except the environment variables...

I added a secret containing all the laravel variables from the env file and its actually partially working, when I enter the container and run echo $MYSQL_USER it prints out homestead (which is correct since its what I sent on the docker env variables) but if I then run php artisan migrate it fails to connect to the db using the forge user (default when no variables are found).

I read that in kubernetes laravel was actually capable of getting the env variables from the php and not from the .env file if required, do I have to do anything to enable this? How are you guys setting this up in kubernetes? I'm trying to avoid having an .env file since it makes me create an image for each environment I have.... Ideas?

Thank you, João Lourenço.

0 likes
1 reply
bosborne's avatar

Hey,

I have started working on a project called Larakube that allows you to define services and deploys them to a Kubernetes cluster.

It also takes care of your environment variables and stores them as K8 secrets.

The project is in active development but take a look.

https://github.com/larakube/larakube

Please or to participate in this conversation.