<p>I'm trying to put a Service Account into a secret - I did it previously a year ago and it works but now - no matter how I approach it, the application doesn't see it right and says there is <code>Input byte array has incorrect ending byte</code> - When creating normal secret I know you've gotta do it with a new line so</p>
<pre class="lang-sh prettyprint-override"><code>echo -n &quot;secret&quot; | base64
</code></pre>
<p>and put that value in secret and apply, but my multiline file</p>
<pre class="lang-sh prettyprint-override"><code>cat secret.json
{
  &quot;type&quot;: &quot;service_account&quot;,
  &quot;project_id&quot;: &quot;smth-smth&quot;,
  &quot;private_key_id&quot;: &quot;blabla&quot;
...
}
</code></pre>
<p>No matter how I approach - whether put it by hand like in the first example, or do it with</p>
<pre class="lang-sh prettyprint-override"><code>cat secret.json | base64

# or 

base64 &lt; secret.json
</code></pre>
<p>the secret is created but application throws</p>
<pre class="lang-sh prettyprint-override"><code>Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Input byte array has incorrect ending byte at 3104
</code></pre>
<p>When I compare the new secret to the last one of the service account the difference is how the output looks like</p>
<p>The working one is smth like this - when I try to decrypt the base64</p>
<pre class="lang-sh prettyprint-override"><code>echo -n &quot;&lt;long string of base64 encrypred sa&gt; | base64 -D
    { &quot;type&quot;: &quot;service_account&quot;, &quot;project_id&quot;: &quot;blabla&quot;... }
</code></pre>
<p>so it's in one line, and the new SA I try to decrypt is outputed in the format as in the file - so each part of json in new line - I tried manually putting it all in one line but without success</p>
<p>Anyone know ? how to put a multiline file in a secret (base64) properly?</p>

potatopotato
<p>The easiest way to create a secret from a file is to use <code>kubectl create secret generic</code>.</p>
<p>Put your file <code>secret.json</code> in a folder <code>config</code> and then run:</p>
<pre><code>kubectl create secret generic my-secret --from-file=config
</code></pre>
<p>You will get a secret <code>my-secret</code> with one key <code>secret.json</code> containing your file (which you can then mount to a pod volume).</p>
