<p>My goal is to create an environment variable for the pod out of a mounted secret volume. I want to skip the intermediate step with creating Kubernetes secret (and refer the k8s secret for the env) so nothing is stored on the etcd storage.</p>
<p>I am using the CSI Driver to mount the secrets of my Azure Key Vault. The volume is working correctly.</p>
<p>Deployment.yaml:</p>
<pre><code>...
spec:
  volumes:
    - name: keyvault-secrets
      csi:
        driver: secrets-store.csi.k8s.io
        readOnly: true
        volumeAttributes:
          secretProviderClass: kevault-secrets
  containers:
    - name: busybox
      image: k8s.gcr.io/e2e-test-images/busybox:1.29
      command:
        - /bin/sh
      args:
        - '-c'
        - &gt;-
          SECRET1=$(cat /mnt/keyvault-secrets/secret1); export SECRET1;echo
          $SECRET1; sleep 1d;
      volumeMounts:
        - name: keyvault-secrets
          readOnly: true
          mountPath: /mnt/keyvault-secrets
</code></pre>
<p>On startup the Pod is able to populate the environment variable and even prints its value correctly on the console. If I log into the Pod the environment variable is gone.</p>
<p>Any ideas why the environment variable vanishes?</p>

<p>Environment set in a shell session (like the one in your command) is local to that session only.</p>
