kubernetes : How to deattach from an attached pod

Viewed 1494

I have a running pod and I use kubectl attach -ti mypod to give him input.

But then, I would like to "deattach" from my pod and return back to my terminal without terminating my pod. How can I do that?

2 Answers

From the kubernetes docs:

To detach from the container, you can type the escape sequence Ctrl+P followed by Ctrl+Q.


Update:

Based on feedback from @Abdelghani:

For the record, this does not work if tty is set to false in the container. I didnt find another way to detach other than killing the pod/container.

You can kill the kubectl attach -it .. process without killing the pod:

host$ kubectl attach -it podname
pod$ do something in pod

Open the other terminal and find your kubectl attach command and then kill it, something like:

host$ ps x | grep "kubectl attach"
> 1234 pts/22   Sl+    0:00 kubectl attach -it podname
host$ kill 1234
Related