<p>I'm trying to make my life easier and am coding a bash script. One of these allows me to kube into a pod with postgres access, get the credentials I need, and run the interactive psql shell. </p>

<p>However, upon running</p>

<pre><code>kubectl &lt;flags&gt; exec $podname -- bash -c ' get_credentials &amp;&amp; psql &lt;psql args&gt; -i -t
</code></pre>

<p>the terminal hangs. </p>

<p>I can't directly connect to the database, and the process to get the credentials is kinda cumbersome. Is there some bash concept I'm not understanding?</p>

Oliver
<blockquote>
  <p><code>kubectl &lt;flags&gt; exec $podname</code></p>
</blockquote>

<p>That <code>exec</code> is missing its <code>-i</code> and <code>-t</code> for <code>--stdin=true</code> and <code>--tty=true</code> to describe to kubernetes that you wish your terminal and the remote terminal to be associated with one another:</p>

<p><code>kubectl exec -it $podname -- etc etc</code></p>

<p>If you are intending the <code>-i</code> and <code>-t</code> present at the end of your cited example above to be passed to <code>exec</code>, be aware that the double dashes <em>explicitly</em> switch off argument parsing from <code>kubectl</code>, so there is no way it will see them</p>
