<p>I am trying do deploy PostgreSQL on AKS from the following Bitnami chart: <a href="https://github.com/bitnami/charts/tree/master/upstreamed/postgresql/#installing-the-chart" rel="nofollow noreferrer">https://github.com/bitnami/charts/tree/master/upstreamed/postgresql/#installing-the-chart</a></p>

<p>During deployment, I have been invited to use the following command (once installed) to make sure I will be able to access postgres outside the cluster (e.g. some local DBMS)</p>

<pre><code>kubectl port-forward --namespace default svc/dozing-coral-postgresql 5432:5432 &amp; PGPASSWORD="$POSTGRES_PASSWORD" psql --host 127.0.0.1 -U postgres -p 5432
</code></pre>

<p>This results with a syntax error:</p>

<pre><code>At line:1 char:80
+ ... d --namespace default svc/dozing-coral-postgresql 5432:5432 &amp; PGPASSW 
...
+                                                                 ~
The ampersand (&amp;) character is not allowed. The &amp; operator is reserved for 
future use; wrap an ampersand in double quotation marks ("&amp;") to pass it as 
part of a string.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : AmpersandNotAllowed
</code></pre>

<p>What would be the correct command to unclock the ports?</p>

user2530062
<p>The output you should see is something like</p>

<pre class="lang-sh prettyprint-override"><code>To connect to your database from outside the cluster execute the following commands:

    kubectl port-forward --namespace default svc/jolly-raccoon-postgresql 5432:5432 &amp;
    PGPASSWORD="$POSTGRES_PASSWORD" psql --host 127.0.0.1 -U postgres -p 5432
</code></pre>

<p>There are two different commands. The first one is to forward the ports, and the final <code>&amp;</code> is to send this command to the background so you are able to continue using the shell</p>

<pre class="lang-sh prettyprint-override"><code>$ kubectl port-forward --namespace default svc/jolly-raccoon-postgresql 5432:5432 &amp;
[1] 62447
Forwarding from 127.0.0.1:5432 -&gt; 5432
</code></pre>

<p>The second command allows you to connect to the database using the forwarded port from another host where you have installed the <code>psql</code> client</p>

<pre><code>$ PGPASSWORD="$POSTGRES_PASSWORD" psql --host 127.0.0.1 -U postgres -p 5432
psql (11.3)
Type "help" for help.

postgres=#
</code></pre>
