I have a node.js application which is accessing environment variables like so:
const pool = mysql.createPool({
host: process.env.MYSQL_HOST,
user: process.env.MYSQL_USER,
port: process.env.MYSQL_PORT,
password: process.env.MYSQL_PASSWORD,
database: process.env.MYSQL_DB
});
The deployment is done via Kubernetes. Some of the environment variables, such as MYSQL_HOST, MYSQL_DB are set in plain form, the MYSQL_PASSWORD, however, is set via a secret. And the problem is that the regular environment variables are read by my node.js application just fine while the MYSQL_PASSWORD is not. But the problem is that when I try to see the value of MYSQL_PASSWORD in the list of the environment variables in the container - it shows the correct value.
Here's how the environment variable in question is set in the deployment yaml:
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
key: MYSQL_PASSWORD
name: config-secret
And again - the value is visible when I run the env
command in the container, but for some reason the node.js application doesn't pick it up.
Does anybody have any clue why my app would read the regular environment variables without issues but fails to read the ones set as secrets?
Thanks.