feat: open terminal in the running container
What does this PR do?
The following changes request adds the ability to open a terminal in a container located in a Kubernetes pod.
Screenshot / video of UI
https://github.com/containers/podman-desktop/assets/1968177/eb5b498e-3e7b-4e85-bb38-e54b516849bf
What issues does this PR fix or reference?
partially: #4402
How to test this PR?
Create the pod in kubernetes(in our case sample app was deployed in OpenShift Local cluster), navigate to the deployed pod and open Terminal tab.
What is the expected behavior when multiple containers are in the pods ?
What is the expected behavior when multiple containers are in the pods ?
Was about to ask the same thing. We would have to implement an option / drop down menu to select which container to connect to.
This is absolutely awesome though @vzhukovs ! With edit / summary / logs and all, this was the last piece of the puzzle for Kubernetes support. Amazing work 🎉
Woo! So there IS a dropdown menu. That's awesome. Although for some reason it's not showing the terminals correctly? And I'm not getting any error / showing. @vzhukovs
What is the expected behavior when multiple containers are in the pods ?
Was about to ask the same thing. We would have to implement an option / drop down menu to select which container to connect to.
Yep, the logic of choosing the target container is the same as it implemented in OpenShift console. If pod has only one running container, then it will be automatically chosen as destination one, but if the pod has more then one container, then there will be a dropdown menu above the terminal to choose the right one container.
lthough for some reason it's not showing the terminals correctly? And I'm not getting any error / showing.
@cdrage you mean, that terminals don't switch after selecting the right one, am I right?
UPD: seems, I found the problematic place, taking a look on it
Looking really great @vzhukovs !
When I "exit" from the terminal, I'm not able to get a new connection. Could it be possible to respawn the connection, either automatically, or after some key pressed?
When connected, should say "Connected to:" ?
improved, now when terminal is connected, the label also shows information, that it is connected
When I "exit" from the terminal, I'm not able to get a new connection. Could it be possible to respawn the connection, either automatically, or after some key pressed?
@feloy fixed this issue, now reconnecting to the new terminal should work fine
When I try to connect to an image with neither bash nor sh, it is respawning the connection infinitely, without any delay. I don't know if you can detect this specific error, or at least make some temporization before retrying the connection (or canceling the retries after a few tries)
When I try to connect to an image with neither
bashnorsh, it is respawning the connection infinitely, without any delay. I don't know if you can detect this specific error, or at least make some temporization before retrying the connection (or canceling the retries after a few tries)
I suppose, there is should be the same behaviour, when user tries to open the terminal to a podman container, because the init command is the same as here: https://github.com/containers/podman-desktop/blob/main/packages/main/src/plugin/container-registry.ts#L1568
Resize for terminal is not working. I ma not sure is if it PR problem or kubernetes-client issue.
Screen.Recording.2024-03-06.at.7.56.44.PM.mov
Hi @dgolovin, fixed, now resize works fine:
@deboer-tim, green light to merge?
not clear to me why we're using special Transmitter
for other terminal usage it's just fitting with the terminal size so I don't see here why it would be different
Described general approach here in comment: https://github.com/containers/podman-desktop/pull/5975#discussion_r1530839772
In general, only fitting xterm addon doesn't apply resize on container side, environment variables $COLUMNS and $LINES still not modified, we need to implement ResizableStream from client-node library to be able to resize it correctly.
General approach in dockerode and client-node library are completely different to each other.

