<p>I am new to Kubernetes.</p>
<p>I found some errors while using google-cloud-storage.</p>
<p>The problem is,
when I specify GCLOUD_PRIVATE_KEY directly in .yaml file,
I work nicely.</p>
<pre><code> - name: GCLOUD_PRIVATE_KEY
   value: &quot;-----BEGIN PRIVATE KEY-----\n(...)\n-----END PRIVATE KEY-----\n&quot;
</code></pre>
<p>However, when I inject the variable to cluster.</p>
<p>AT terminal</p>
<pre><code>kubectl create secret generic gcloud-private-key --from-literal=GCLOUD_PRIVATE_KEY=&quot;-----BEGIN PRIVATE KEY-----\n(...)\n-----END PRIVATE KEY-----\n&quot;
</code></pre>
<p>AT .yaml</p>
<pre><code>- name: GCLOUD_PRIVATE_KEY
  valueFrom: 
    secretKeyRef:
       name: gcloud-private-key
       key: GCLOUD_PRIVATE_KEY
</code></pre>
<p>The error related to key occurs.
I even tried for escape notation just in case,</p>
<p>AT terminal</p>
<pre><code>kubectl create secret generic gcloud-private-key --from-literal=GCLOUD_PRIVATE_KEY='&quot;-----BEGIN PRIVATE KEY-----\n(...)\n-----END PRIVATE KEY-----\n&quot;'
</code></pre>
<p>However, it doesn't work as well! Can you let me know how I can fix it??</p>

Jun
<p><code>kubectl create secret generic gcloud-private-key --from-literal=GCLOUD_PRIVATE_KEY='&quot;...\n...</code></p>
<p>'\n', '&quot;' are invalid character for TLS key when create from literal. You can load the key directly from the original file as-is:</p>
<p><code>kubectl create secret generic gcloud-private-key --from-literal GCLOUD_PRIVATE_KEY=&quot;$(cat &lt;file&gt;)&quot;</code></p>
