<p>I have a shell script <code>my-script.sh</code> like:</p>
<pre class="lang-bash prettyprint-override"><code>#!/bin/bash
while true; do
  echo '1'
done
</code></pre>
<p>I can deploy a bash pod in Kubernetes like:</p>
<pre class="lang-bash prettyprint-override"><code>kubectl run my-shell --rm -it --image bash -- bash
</code></pre>
<p>Now, I want to execute the script on bash. How can I pass <code>my-script.sh</code> as input to bash? Something like</p>
<pre class="lang-bash prettyprint-override"><code>kubectl run my-shell --rm -it --image bash -- /bin/bash -c &lt; my-script.sh
</code></pre>

Vahid
<p>Just drop the <code>-t</code> to <code>kubectl run</code> (because you're reading from stdin, not a terminal) and the <code>-c</code> from bash (because you're passing the script on stdin, not as an argument):</p>
<pre><code>$ kubectl run my-shell --rm -i --image docker.io/bash -- bash &lt; my-script.sh
If you don't see a command prompt, try pressing enter.
1
1
1
1
...
</code></pre>
