<p>I have created a kubernetes secret from a file (secret.txt):</p>
<pre><code>k1=v1
k2=v2
k3=v3
</code></pre>
<p>It looks like this secret-:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
metadata:
  name: secret007
data:
  secret.txt: bWFza1NhbHQ9InRlc3RzYWx0IgpzM1
</code></pre>
<p>I am using it as environment variable in the pod like this:</p>
<pre class="lang-yaml prettyprint-override"><code> - name: KEY1
   valueFrom:
     secretKeyRef:
       key: k1
       name: secret007
       optional: false
</code></pre>
<p><strong>Problem</strong>
Problem since the data has a value as a single base64 value. I am not able to refer it in the pod and getting this error.</p>
<pre><code>  Warning  Failed     6s (x2 over 6s)  kubelet, Error: couldn't find key k1 in Secret kube-system/secret007
</code></pre>
<p>Please suggest how to do this without changing the secret format i.e Secret would be a single key value of filename and all secret.txt values as a single base64 value. Is it possible?</p>

Alok Kumar Singh
<p>You can create secret entries from environment file</p>
<pre><code>kubectl create secret generic test --from-env-file=secret.txt
</code></pre>
<p>and the output will have distinct values in your secret</p>
<pre><code>apiVersion: v1
data:
  k1: djE=
  k2: djI=
  k3: djM=
kind: Secret
metadata:
  creationTimestamp: null
  name: test
</code></pre>
