<p>Part of our orchestration uses envsubst to update a YAML template file with our desired values.</p>

<pre><code>envsubst &lt; "${SECRET_TEMPLATE}" | kubectl apply -f -
</code></pre>

<p>The value for our keyword config is a JSON string:</p>

<pre><code>data=$(jq -c . ${JSON_FILE})
</code></pre>

<p>This results in YAML that looks like this (trimmed for brevity):</p>

<pre><code>apiVersion: v1
kind: Secret
metadata:
  name: reporting-config
type: Opaque
data:
  config: {"database": "foo"}
</code></pre>

<p>This apparently worked in some earlier versions of Kube, I wanna say 1.8. Anyways, we are running 1.15 and now kubectl interprets this as a map type and complains:</p>

<pre><code>error: error validating "STDIN": error validating data: ValidationError(Secret.data.config): invalid type for io.k8s.api.core.v1.Secret.data: got "map", expected "string"; if you choose to ignore these errors, turn validation off with --validate=false
</code></pre>

<p>Is there a trick to doing this now. I've played around with quoting and various places, escaping quotes, and all that jazz and nada.</p>

<p><strong>* update 1 *</strong>  </p>

<p>Using stringData still results in the same error:</p>

<pre><code>apiVersion: v1
kind: Secret
metadata:
  name: monsoon-storage-reporting-config
type: Opaque
stringData:
  config: {"database": "foo"}
</code></pre>

<pre><code>error: error validating "STDIN": error validating data: ValidationError(Secret.stringData.config): invalid type for io.k8s.api.core.v1.Secret.stringData: got "map", expected "string"; if you choose to ignore these errors, turn validation off with --validate=false
</code></pre>

<p>You may use stringData as below. Note the pipe after stringData:</p>
<pre><code>apiVersion: v1
kind: Secret
metadata:
  name: monsoon-storage-reporting-config
type: Opaque
stringData: |
  config: {&quot;database&quot;: &quot;foo&quot;}
</code></pre>
