Search code examples
pythonkuberneteskubectl

kubectl hangs when running python with restart=Never


I am running the command:

kubectl run testbox -it --rm --restart=Never --image=python:buster -- python3

which will launch a python session and then I input exit() to quit the session. But the session hangs forever there. If I do kubectl get po testbox I can see the pod is already completed.

Then if I hit enter key the console will then output:

E0826 22:43:38.790348 1551782 v2.go:105] EOF

I noticed that this will not happen if I set --restart=Always. Not sure if it is expected?

Thanks!


Solution

  • There is a similar issue posted on kubectl GtiHub page (run commands don't return when using kubectl 1.22.x #1098), created 3 days ago. Currently awaiting triage.

    This is most probably a bug in 1.22 version of kubectl. If this issue causes you problems, I suggest downgrading to 1.21, as this bug does not occurs in older versions.