<p>I was following <a href="https://cloud.google.com/python/django/kubernetes-engine" rel="nofollow noreferrer">this</a> tutorial for deploying Django App to Kubernetes Cluster. I've created cloudsql credentials and exported them as in the tutorial</p>

<pre><code>export DATABASE_USER=&lt;your-database-user&gt;
export DATABASE_PASSWORD=&lt;your-database-password&gt;
</code></pre>

<p>However my password was generated by LastPass and contains special characters, which are striped out in Kubernetes Pod thus making the password incorrect.</p>

<p>This is my password (altered, just showing the special chars)
<code>5bb4&amp;sL!EB%e</code></p>

<p>So i've tried various ways of exporting this string, echoing it out always show correct password, however in Kubernetes Dashboard the password is always incorrect (Also altered in DevTools, but some chars are just stripped out)</p>

<p><a href="https://i.stack.imgur.com/yR5o9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yR5o9.png" alt="enter image description here"></a></p>

<p>Things I've tried</p>

<pre><code>export DATABASE_PASSWORD=$'5bb4&amp;sL\!EB\%e'
export DATABASE_PASSWORD='5bb4&amp;sL!EB%e'
</code></pre>

<p>Echoing is always good but kubernetes is always stripping it.</p>

<p>Deploying with <code>skaffold deploy</code></p>

<p>EDIT:</p>

<p>After hint I've tried to store the password in base64 encoding form, however I suspect it only applies to local scope, as the password in Kubernetes Dashboard is still the same, I suspect that I need to regenerate the certificate to make this work remotely on gke cluster?</p>

<p><a href="https://i.stack.imgur.com/VGjsJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VGjsJ.jpg" alt="enter image description here"></a></p>

<p>So the env variables are for local and credentials in cloud sql proxy are the ones that are being used and misinterpreted? Where are those files by the way?</p>

<p>EDIT2:</p>

<p>I've just found out that indeed the gke cluster in using the credentials json rather than the exported variables. The configuration json already contains the password in base64 encoded form, HOWEVER it is base64 encode of string which still is missing special characters. Looks like the only way out is to generate new credentials without specials characters, that looks like a bug, doesnt it?</p>

<p>You should <code>base64</code> encode your password before passing it into the pod so that special characters are encoded in a way that they can be preserved.</p>

<p>In bash you can do this with: </p>

<pre><code>export DATABASE_PASSWORD=`echo [ACTUAL_PASSWORD_HERE] | base64`
</code></pre>

<p>You'll then need to ensure that the Django app <code>settings.py</code> uses a base64 decode before applying the password to its internal variable.</p>

<p>So in the tutorial you linked to, the line</p>

<p><code>'PASSWORD': os.getenv('DATABASE_PASSWORD'),</code></p>

<p>would need to change to:</p>

<p><code>'PASSWORD': base64.b64decode(os.getenv('DATABASE_PASSWORD')),</code></p>
