Skip to content

Feature Request: detach-keys option/setting for pod terminal #1011

@Nuru

Description

@Nuru

This is a revival of #693 which was sort of duplicated by #878 but both went stale before being addressed. #878 labeled this behavior a bug and put it on the backlog. I consider it a feature request, but am happy to let SIGCLI decide.

See Update 2023-04-04 below

kubectl run -it, kubectl exec -it, and kubectl attach -it connect to a Docker container in a manner parallel to docker run -it and docker attach. All these commands by default listen for the key sequence ctrl-p,ctrl-q to cause the command to detach from the container. However, unlike kubectl, the docker commands have a [--detach-keys option] and configuration property to allow you to specify an alternate key sequence to use instead of the default. kubectl is missing this option. Please implement it.

The default is problematic with bash because by default, ctrl-p on the bash command line brings up the previous command from the history list. Users typing ctrl-p once expect to see the previous command, but get nothing until they type another character, because the ctrl-p (being the first character in a potential 2-character command) is held back until the next character is sent. If the next character is ctrl-q the connection is closed and the container never sees the ctrl-p. If the next character is something else, then the ctrl-p and the next character are sent as soon as the second character is typed. If that character is ctrl-p, then the user will get the to see the command before the previous command, as they have just typed ctrl-p,ctrl-p. So getting to the immediately previous command requires typing ctrl-p followed by some other character that will not alter the command line. This is annoying at best.

Whatever issues people may have with the default detach key sequence in docker are alleviated by the presence of the --detach-keys option and the detachKeys property of the docker configuration. However kubectl does not have this option.

Please add a --detach-keys option that operates the same way as docker --detach-keys does.

Update 2023-04-04

Although the latest (v1.26) documentation still says you can detach using Ctrl+P,Ctrl+Q, this no longer seems to be the case. It seems you have to kill the attached process or close the connection with Ctrl+D. Why this is or what changed is not documented. So this is now also a request to update the documentation to reflect current behavior and to show the recommended way to end a session.

See also:

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.kind/featureCategorizes issue or PR as related to a new feature.lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.priority/backlogHigher priority than priority/awaiting-more-evidence.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions