<p>I am wondering if it is possible to have a byte array as kubernetes secret.
I created a byte array and a base64-encoded string as below</p>

<pre><code>    SecureRandom random = new SecureRandom();
    byte bytes[] = new byte[32];

    random.nextBytes(bytes);
    for (int i = 0; i &lt; bytes.length; i++) {
        System.out.print(bytes[i] + ",");
    }

    String token = Base64.getEncoder().withoutPadding().encodeToString(bytes);
</code></pre>

<p>Then I used the resulting string in a kubernetes secret. The secret gets created successfully.
Now I would like my Spring Boot application, that is running in kubernetes, to read and decode that value.
However, I get an IllegalArgumentException (Illegal base64 character)
When running the application locally reading the same token from a properties file, it can be decoded.</p>

<p>So my question again: Is it possible to use a byte array as kubernetes secret?</p>

Martin Baeumer
<p>You don't need to encode it manually. Just supply plain text to secret and it will be base64 encoded by k8s. Otherwise it is encoded twice.</p>

<pre><code>kind: Secret
apiVersion: v1
stringData: # allows to add plain text (will be encoded by k8s and kept in Base64 encoded format under data) 
  foo: plain text
data:
</code></pre>
