<p>I run this command:</p>

<pre><code>kubectl run my-shell --rm -it --image alpine -- sh
</code></pre>

<p>It all works fine, but after a few minutes of inactivity the shell closes on it's own and my terminal hangs as well, so that kubectl does not remove the pod since it cannot complete.</p>

<p>So I am wondering, is it possible to increase the timeout before this happens, I have not found this in the documentation?</p>

<p>P.S. Help on preventing terminal hanging is appreciated as well, I am using ordinary windows command line.</p>

<p>P.P.S. This is happening in AKS, as @wolmi suggested it might be relevant.</p>

Ilya Chernomordik
<p>Add the <code>--generator</code> flag:</p>

<pre class="lang-sh prettyprint-override"><code>kubectl run my-shell --rm -it --image alpine --generator=run-pod/v1 -- sh
</code></pre>

<p>I tried with no problem during more than 20min idle.</p>

<p>By default the <code>run</code> command uses <code>--generator=deployment/apps.v1beta1</code> that is deprecated and generated a different yaml.</p>
