<p>I'm currently working on a Kubernetes deployment file and I need to set the environment variables that the container will have.</p>
<p>Is there a way to set Kubernetes secrets as environment variables in the deployment file?</p>
<p>Here is a dummy file to help explain:</p>
<p><a href="https://i.stack.imgur.com/mv4Rr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mv4Rr.png" alt="dummy deployment file" /></a></p>

Lumberjack
<p>Yes, of course, you can mount env variables from config maps or secrets with</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata: ...
spec:
  ...
  template:
    ...
    spec:
      containers:
        - name: app
          image: ...
          envFrom:
          - configMapRef:
              name: env-configmap
          - secretRef:
              name: env-secrets
</code></pre>
<p>See more in the official doc: <a href="https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets-as-environment-variables" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets-as-environment-variables</a></p>
