<p>Does anyone know what am I doing wrong with my kubernetes secret yaml and why its not able to successfully create one programatically?</p>
<p>I am trying to programmatically create a secret in Kubernetes cluster with credentials to pull an image from a private registry but it is failing with the following:</p>
<pre><code>&quot;Secret &quot;secrettest&quot; is invalid: data[.dockerconfigjson]: Invalid value: &quot;&lt;secret contents redacted&gt;&quot;: invalid character 'e' looking for beginning of value&quot;
</code></pre>
<p>This is the yaml I tried to use to create the secret with. It is yaml output from a secret previously created in my kubernetes cluster using the command line except without a few unnecessary properties. So I know this is valid yaml:</p>
<pre><code>apiVersion: v1
data:
  .dockerconfigjson: eyJhdXRocyI6eyJoZWxsb3dvcmxkLmF6dXJlY3IuaW8iOnsidXNlcm5hbWUiOiJoZWxsbyIsInBhc3N3b3JkIjoid29ybGQiLCJhdXRoIjoiYUdWc2JHODZkMjl5YkdRPSJ9fX0=
kind: Secret
metadata:
  name: secrettest
  namespace: default
type: kubernetes.io/dockerconfigjson
</code></pre>
<p>This is the decoded value of the &quot;.dockerconfigjson&quot; property which seems to be throwing the error but not sure why if the value is supposed to be encoded per documentation:</p>
<pre><code>{&quot;auths&quot;:{&quot;helloworld.azurecr.io&quot;:{&quot;username&quot;:&quot;hello&quot;,&quot;password&quot;:&quot;world&quot;,&quot;auth&quot;:&quot;aGVsbG86d29ybGQ=&quot;}}}
</code></pre>
<p>According to the documentation, my yaml is valid so Im not sure whats the issue:
<a href="https://i.stack.imgur.com/Cdl2H.png" rel="nofollow noreferrer">Customize secret yaml</a></p>
<p><strong>Note: I tried creating the Secret using the Kubernetes client and &quot;PatchNamespacedSecretWithHttpMessagesAsync&quot; in C#</strong></p>
<p>Referenced documentaion: <a href="https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/</a></p>

jorgeavelar98
<p>I was getting similar error when I was trying to create secret using client-go.
The error actually tells that the encoded string has invalid e at the beginning of the value (so may be it's expecting '{' this at the beginning ).To solve this, the value should not be encoded into base64. Just use it as it is and that will be encoded later.</p>
