Why should I mount a secret or configmap in Kubernetes Why should I mount a secret or configmap in Kubernetes kubernetes kubernetes

Why should I mount a secret or configmap in Kubernetes


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:

  1. You want to keep your nginx.conf decoupled from your docker image.
  2. Put your SSL Certs (cert + private keys) in secret to enable SSL on your web application