Josh
02/08/2022, 11:42 PMconfigmaps
/ secrets
?
I'm looking to inject my set of vars at container start time, without fully relying on a populated .env
file.bdw429s
02/09/2022, 12:15 AMbdw429s
02/09/2022, 12:16 AMbdw429s
02/09/2022, 12:17 AMJosh
02/09/2022, 12:32 AMjclausen
02/09/2022, 1:08 AMJosh
02/09/2022, 1:10 AMjclausen
02/09/2022, 1:39 AMJosh
02/09/2022, 1:42 AM.env
file that I've injected, during container build, which is set to get vars from my configmaps.
So my .env file might have:
DB_DATABASE_1=${DB_01}
DB_DATABASE_2=${DB_02}
DB_DATABASE_3=${DB_03}
Then my configmap has the actual var
DB_01=firstdb
DB_02=anotherdb
DB_03=someotherdb
Josh
02/09/2022, 1:43 AM.cfconfig.json
"SomeDB": {
"host": "${DB_HOST}",
"dbdriver": "${DB_DRIVER}",
"database": "${DB_DATABASE_2}",
"dsn": "jdbc:mysql://{host}:{port}/{database}",
"custom": "useUnicode=true&characterEncoding=UTF8&autoReconnect=false&useSSL=false&useLegacyDatetimeCode=true",
"port": "${DB_PORT}",
"class": "${DB_CLASS}",
"username": "${DB_USER}",
"password": "${DB_PASSWORD}",
Josh
02/09/2022, 1:52 AMJosh
02/09/2022, 1:52 AMjclausen
02/09/2022, 2:20 AMJosh
02/09/2022, 2:25 AMkubectl create configmap my-app-env --from-file=my-app-env.txt --namespace my-app
Then directly getting my workload to load the config as env
envFrom:
- configMapRef:
name: my-app-env
- secretRef:
name: my-app-sec-env
Josh
02/09/2022, 2:26 AM.env
file would go? (/app/.env
)jclausen
02/09/2022, 2:54 PMmy-app-env.txt
is a simple properties file in the .env
format.
It would be easy enough to move it in by adjusting the command in your docker file or at the service level.
CMD cp [ config file path here ] /app/.env && $BUILD_DIR/run.sh
jclausen
02/09/2022, 2:55 PMconfigmap
would not work, if it’s YAML format.jclausen
02/09/2022, 2:56 PMjohnfarrar
02/09/2022, 3:31 PMJosh
02/09/2022, 6:58 PM.env
file to the app
volume... so I'll feedback to this thread later - Might not need to make that ticket after all.Josh
02/09/2022, 8:20 PMvolumeMount
then a key
and path
in the volume definition.
Thanks all, this is a big breakthrough for us! 🙂