Skip to content

Add ability to re-exec into shell when using tsh proxy kube.#40246

Merged
tigrato merged 3 commits intomasterfrom
tigrato/tsh-proxy-kube-headless
Apr 10, 2024
Merged

Add ability to re-exec into shell when using tsh proxy kube.#40246
tigrato merged 3 commits intomasterfrom
tigrato/tsh-proxy-kube-headless

Conversation

@tigrato
Copy link
Copy Markdown
Contributor

@tigrato tigrato commented Apr 5, 2024

This PR introduces the tsh proxy kube --exec mode which spawns the kube proxy in the background and re-execs the user shell with the configured kubeconfig file.

Changelog: Added tsh proxy kube --exec mode that spawns kube proxy in the background, re-executes user shell with the appropriate kubeconfig.

This PR introduces the `tsh proxy kube --exec` mode which spawns the
kube proxy in the background and re-execs the user shell with the
configured kubeconfig file.

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
@tigrato tigrato requested review from AntonAM and greedy52 April 8, 2024 10:24
@tigrato tigrato marked this pull request as ready for review April 8, 2024 10:25
@github-actions github-actions Bot added size/sm tsh tsh - Teleport's command line tool for logging into nodes running Teleport. labels Apr 8, 2024
Comment thread tool/tsh/common/kube_proxy.go Outdated
Comment thread tool/tsh/common/kube_proxy.go Outdated
@tigrato tigrato requested a review from AntonAM April 8, 2024 13:20
@taraspos
Copy link
Copy Markdown
Contributor

taraspos commented Apr 8, 2024

When using --exec following prompt still shows up:

Use the following config for your Kubernetes applications. For example:
export KUBECONFIG=/Users/username/.tsh/keys/...
kubectl version

Also, file mentioned in export KUBECONFIG doesn't exist, and the one in /var/folders/ used instead.

$ echo $KUBECONFIG
/var/folders/w3/njlgtc9j40z_0fkd3hrcz3bc0000gn/T/proxy-kubeconfig-113011939

So I would imagine we would want to remove the prompt if --exec mode is used.

@tigrato tigrato enabled auto-merge April 10, 2024 10:52
@tigrato
Copy link
Copy Markdown
Contributor Author

tigrato commented Apr 10, 2024

When using --exec following prompt still shows up:

Use the following config for your Kubernetes applications. For example:
export KUBECONFIG=/Users/username/.tsh/keys/...
kubectl version

Also, file mentioned in export KUBECONFIG doesn't exist, and the one in /var/folders/ used instead.

$ echo $KUBECONFIG
/var/folders/w3/njlgtc9j40z_0fkd3hrcz3bc0000gn/T/proxy-kubeconfig-113011939

So I would imagine we would want to remove the prompt if --exec mode is used.

I fixed the message. It was using the incorrect message. Now it prints:

Started local proxy for Kubernetes Access in the background.

Warning! Teleport will initiate a new shell configured with kubectl for local proxy access. 
To conclude the session, simply use the "exit" command. Upon exiting, your original shell will be restored, 
the local proxy will be closed, and future access through this headless session won't be possible.

 To work with different contexts use "kubectl --context", for example:
"kubectl --context='staging' get pods".
"kubectl --context='dev' get pods".

@tigrato tigrato added this pull request to the merge queue Apr 10, 2024
Merged via the queue into master with commit 58d4843 Apr 10, 2024
@tigrato tigrato deleted the tigrato/tsh-proxy-kube-headless branch April 10, 2024 11:27
@public-teleport-github-review-bot
Copy link
Copy Markdown

@tigrato See the table below for backport results.

Branch Result
branch/v13 Failed
branch/v14 Create PR
branch/v15 Create PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/sm tsh tsh - Teleport's command line tool for logging into nodes running Teleport.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants