podman-desktop icon indicating copy to clipboard operation
podman-desktop copied to clipboard

feat: open terminal in the running container

Open vzhukovs opened this issue 1 year ago • 12 comments

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.

vzhukovs avatar Feb 13 '24 11:02 vzhukovs

What is the expected behavior when multiple containers are in the pods ?

axel7083 avatar Feb 13 '24 12:02 axel7083

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.

cdrage avatar Feb 13 '24 13:02 cdrage

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 🎉

cdrage avatar Feb 13 '24 13:02 cdrage

Screenshot 2024-02-13 at 8 50 32 AM

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

cdrage avatar Feb 13 '24 13:02 cdrage

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

vzhukovs avatar Feb 13 '24 14:02 vzhukovs

Looking really great @vzhukovs !

slemeur avatar Feb 22 '24 15:02 slemeur

terminal-exit

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 avatar Feb 27 '24 15:02 feloy

Screenshot 2024-03-01 at 3 35 23 PM

When connected, should say "Connected to:" ?

improved, now when terminal is connected, the label also shows information, that it is connected

vzhukovs avatar Mar 05 '24 16:03 vzhukovs

terminal-exit

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

vzhukovs avatar Mar 05 '24 16:03 vzhukovs

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)

feloy avatar Mar 06 '24 17:03 feloy

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)

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

vzhukovs avatar Mar 07 '24 10:03 vzhukovs

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:

Снимок экрана 2024-03-07 в 12 56 23 Снимок экрана 2024-03-07 в 12 56 36

vzhukovs avatar Mar 07 '24 10:03 vzhukovs

@deboer-tim, green light to merge?

vzhukovs avatar Mar 19 '24 12:03 vzhukovs

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.

vzhukovs avatar Mar 19 '24 17:03 vzhukovs