<p>I'm using Secrets as an environmental variable and I was wondering how you would call the secret in the client side of my application? I'm running a Node.js application and want to use the Secrets environmental variable. I would normally call my environment variables by doing <code>process.env.VARIABLE_NAME</code> locally since I have an env file, but I know that it's not the same for a secret as environmental variable when deployed onto Kubernetes.</p>

<p>Could anybody help me with this? Thanks!</p>

<p>The environment variable created by secret will read as eny other environment variable passed to pod.</p>

<p>So if you create a secret, for example:</p>

<pre><code>kubectl create secret generic user --from-literal=username=xyz
</code></pre>

<p>and pass it to the pod:</p>

<pre><code>env:
- name: USERNAME
  valueFrom:
    secretKeyRef:
      name: user
      key: username
</code></pre>

<p>It will be passed to the pod as environment variable. You can check it by executing <code>printenv USERNAME</code> in the pod and output will be similar to this:</p>

<pre><code>kubectl exec -it secret-env -- printenv USERNAME
xyz
</code></pre>

<p><a href="https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure/#define-container-environment-variables-with-data-from-multiple-secrets" rel="noreferrer">Multiple secrets</a> can be passed to the pod as environment variables.</p>
