Skip to content

Configure the Laravel application

Every Laravel application needs to be configured with environment variables. LaraKube provides a way to set these variables in the values.yml file and seperates between normal environment variables and secrets.

values.yml:

env:
# App
APP_NAME: "My application"
APP_ENV: "staging"
APP_DEBUG: "false"

More sensitive information, like database credentials or API keys, should be stored in Kubernetes secrets.

Terminal window
kubectl create secret generic my-app-env --namespace=my-namespace
Terminal window
kubectl modify-secret my-app-env -n my-namespace
APP_KEY: ""
DB_PASSWORD: ""
MAIL_USERNAME: ""
MAIL_PASSWORD: ""

Then pass the keys of the secret to the application with secretEnvs. Every entry sets one environment variable in all containers (web, workers, scheduler and jobs):

secretEnvs:
- name: APP_KEY
secretName: my-app-env
secretKey: APP_KEY
- name: DB_PASSWORD
secretName: my-app-env
secretKey: DB_PASSWORD

Generate the application key:

You can generate the application key locally with the following command:

Terminal window
php artisan key:generate --show

This command will output the key, which you can then copy into the APP_KEY variable in the secret. The key will not be in the terminal history and is not stored in any file.