In kubernetes POD I have an option to mount a secret or a configmap as a volume mounted to the POD. It would be difficult to access these files as environment variables. So why should I be doing it instead of using them as environment variables?
In kubernetes POD I have an option to mount a secret or a configmap as a volume mounted to the POD. It would be difficult to access these files as environment variables. So why should I be doing it instead of using them as environment variables?
This depends on how the application expect to load the secret.
E.g. if the application expect to load an SSL certificate file, it is possible to have the certificated as a file in a Secret and mount the Secret so that the application can read it as file.
You don't have to always mount the secret or configmap. You can use them too set the environment variables as shown below
envFrom: - configMapRef: name: env-configmap - secretRef: name: env-secrets
However, there are situations when you might want to mount them as files. For example: