Environment variables not available within pod/container when using "envFrom" and "configMapRef" (kustomize/kubernetes/laravel) Environment variables not available within pod/container when using "envFrom" and "configMapRef" (kustomize/kubernetes/laravel) kubernetes kubernetes

Environment variables not available within pod/container when using "envFrom" and "configMapRef" (kustomize/kubernetes/laravel)


Ok, I tried again to mount the confirmap as .env file within the project. But this time I also provided a subPath definition. Now it works and the "php artisan migrate" command runs successful.

  volumes:    - name: "env-volume"      configMap:        name: "configmap"  containers:    - name: "pre-install-job"      image: "registry.myamazingdomain.com/vendor/whatever/service:latest"      imagePullPolicy: "Always"      args:        - /bin/bash        - -c        - php artisan migrate --force -v;      volumeMounts:        - name: "env-volume"          mountPath: "/var/www/html/app/.env"          subPath: "env.properties"

The subPath definition is part of the configMapGenerator:

configMapGenerator:  - name: configmap    files:      - env.properties

E.g.:

$ kubectl -n mynamespace get configmap blablubb-configmap-8c4m97m94g -o yamlapiVersion: v1data:  env.properties: |    APP_NAME="vendor-service-whatever"    APP_ENV="production"    APP_KEY="base64:onKQb...LtU="    APP_DEBUG="false"