1

I have a weird issue with envFrom:

 - name: template-api
 envFrom:
   - secretRef:
     name: common-secrets
   - secretRef:
     name: template-api

in common-secrets I have variables like this:

MAILHOST=smtp.gmail.com
MAILPORT=587

And template-api is like:

MAIL_HOST=$MAILHOST
MAIL_PORT=$MAILPORT

This is like that, because pods have different variables names for same info. But when the container is running the variables are replaced with literal $VAR instead of var value. Maybe Im using the wrong solution for this. Did somebody face the same issue?

Harsh Manvar
  • 27,020
  • 6
  • 48
  • 102

1 Answers1

1

Kubernetes won't update it that way, if you are running that approach with any code or script it will work inside the code. like process.env($MAILHOST)

Whatever you have mentioned in secret it will get injected into the OS environment now if the same values are there it will get overwritten.

Kubernetes inject the secret based on the YAML configuration either to the file system or either inside the OS.

Kubernetes simply inject the values into the POD as set in secret. it won't check whether anything is already set in the environment and replaces it with values.

Harsh Manvar
  • 27,020
  • 6
  • 48
  • 102
  • OK, I was affraid of that! So there is no way to use common variables? From k8s , i mean, i know i can do something with docker entrypoint, – Francisco Rebolledo Jul 29 '21 at 20:13
  • yes, it might could be possible using the dockerentrypoint and running the shell script inside the docker or passing argument. but gain you have to set and manage docker file that way regarding same you didn't mention anything using CMD or entrypoint etc. – Harsh Manvar Jul 30 '21 at 07:42