<p>I am new to Kubernetes. I have a Kubernetes secret yaml file:</p>
<pre><code>apiVersion: v1
kind: Secret
metadata:
  name: my-secret
type: Opaque
data:
  API_KEY: 123409uhttt
  SECRET_KEY: yu676jfjehfuehfu02
</code></pre>
<p>that I have encoded using gpg encryption:</p>
<pre><code> gpg -a --symmetric --cipher-algo AES256 -o &quot;secrets.yaml.gpg&quot; &quot;secrets.yaml&quot;

</code></pre>
<p>and decrypting it in github action's workflow like this:</p>
<pre><code>gpg -q --batch --yes --decrypt --passphrase=$GPG_SECRET my/location/to/secrets.yaml.gpg | kubectl apply -n $NAMESPACE -f -

</code></pre>
<p>When I run:</p>
<pre><code>kubectl get secret my-secret -n my-namespace -o yaml

</code></pre>
<p>I get yaml showing correct values set for API_KEY and SECRET_KEY, like this:</p>
<pre><code>apiVersion: v1
data:
  API_KEY: 123409uhttt
  SECRET_KEY: yu676jfjehfuehfu02
kind: Secret
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {&quot;apiVersion&quot;:&quot;v1&quot;,&quot;data&quot;:{&quot;API_KEY&quot;:&quot;123409uhttt&quot;,&quot;SECRET_KEY&quot;:&quot;yu676jfjehfuehfu02&quot;},&quot;kind&quot;:&quot;Secret&quot;,&quot;metadata&quot;:{&quot;annotations&quot;:{},&quot;name&quot;:&quot;my-secret&quot;,&quot;namespace&quot;:&quot;my-namespace&quot;},&quot;type&quot;:&quot;Opaque&quot;}
  creationTimestamp: &quot;2021-07-12T23:28:56Z&quot;
  managedFields:
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:data:
        .: {}
        f:API_KEY: {}
        f:SECRET_KEY: {}
      f:metadata:
        f:annotations:
          .: {}
          f:kubectl.kubernetes.io/last-applied-configuration: {}
      f:type: {}
    manager: kubectl-client-side-apply
    operation: Update
    time: &quot;2021-07-10T23:28:56Z&quot;
  name: my-secret
  namespace: my-namespace
  resourceVersion: &quot;29813715&quot;
  uid: 89a34b6d-914eded509
type: Opaque
</code></pre>
<p>But when application requests using SECRET_KEY and API_KEY, it shows these values in broken encoding. I get these values printed When I log them:</p>
<pre><code>Api_Key -  á¶¹ï¿½ï¿½4yÖ·Ó­ï¿½Ó¯uï¿½ï¿8
Secret_Key - ï¿½Vï¿½sï¿½ï¿½Û[ï¶×¿zoï½9sï¿½ï¿½{ï¿½ï¿ 

</code></pre>
<p>When I don't use Api_Key and Secret_Key from secrets.yaml (as a hardcoded value in application) then it works as expected.</p>
<p>I need help to access secret data (Api_Key and Secret_Key) with correct values in container running node js application.</p>

devinmaking
<p>it appears as though the value of your secrets are not base64 encoded.
either change the type of data to &quot;stringData&quot; which does not need to be base64 encoded or encode the value of your secrets first.</p>
<p>e.g. <code>echo &quot;§SECRET_KEY&quot; | base64 </code> and use this value in your secrets.
the problem you describe happens as the values of the secret get injected base64 decoded into your pods.</p>
<p>However, when you try to decode the values you supplied by</p>
<p><code>echo &quot;123409uhttt&quot; | base64 -d</code>
you get the following output: <code>�m��ۡ��base64: invalid input</code></p>
