Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent kubectl interactive shell from being closed after few minutes (increase timeout) / or terminal from dying?

I run this command:

kubectl run my-shell --rm -it --image alpine -- sh

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.

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

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

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

like image 878
Ilya Chernomordik Avatar asked Jan 25 '26 20:01

Ilya Chernomordik


1 Answers

Add the --generator flag:

kubectl run my-shell --rm -it --image alpine --generator=run-pod/v1 -- sh

I tried with no problem during more than 20min idle.

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

like image 58
wolmi Avatar answered Jan 27 '26 11:01

wolmi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!