Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for a profile specific kubeconfig file. #7840

Merged
merged 25 commits into from
Aug 24, 2021

Conversation

Joerger
Copy link
Contributor

@Joerger Joerger commented Aug 9, 2021

When a user logs in to a kube cluster with tsh login --kube-cluster=kube01 or tsh kube login kube02, in addition to updating their ~/.kube/config or $KUBECONFIG, a standalone kubeconfig for the given cluster will be generated in ~/.tsh/keys/${PROXY}/${USER}-kube/${TELE_CLUSTER}/kube01-kubeconfig. This kubeconfig has a single cluster (kube01) which is set as the context.

After logging in to a kube cluster, a user can then run tsh env to get and run export KUBECONFIG=~/.tsh/.../kube01-kubeconfig.

Example:

> tsh kube ls
Kube Cluster Name Selected 
----------------- -------- 
kube01            *        
kube02   

> eval $(tsh env)

> echo $KUBECONFIG
~/.tsh/keys/proxy.example.com/dev-kube/example.com/kube01-kubeconfig

> tsh kube login kube02
ERROR: profile specific kubeconfig is in use, run 'eval $(tsh env --unset)' to switch contexts to another kube cluster

#### Change windows/tabs

> tsh kube login kube02
Logged into kubernetes cluster "kube02"

> tsh kube ls
Kube Cluster Name Selected 
----------------- -------- 
kube01                     
kube02            *        

#### Change back to the first window

> tsh kube ls
Kube Cluster Name Selected 
----------------- -------- 
kube01            *        
kube02      

Closes #7202

@Joerger Joerger marked this pull request as ready for review August 9, 2021 23:12
@Joerger Joerger added the ux label Aug 10, 2021
tool/tsh/kube.go Outdated Show resolved Hide resolved
api/utils/keypaths/keypaths.go Outdated Show resolved Hide resolved
api/utils/keypaths/keypaths.go Show resolved Hide resolved
api/utils/keypaths/keypaths.go Show resolved Hide resolved
@Joerger Joerger force-pushed the joerger/handle-multiple-kubeconfigs branch from b353e9c to faf7af4 Compare August 13, 2021 18:24
@Joerger Joerger requested a review from russjones August 18, 2021 18:29
@Joerger
Copy link
Contributor Author

Joerger commented Aug 18, 2021

@klizhentas Please take a look when you can

@Joerger Joerger enabled auto-merge (squash) August 19, 2021 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Standalone Terminal / Terminal Locking For K8s on Different Teleport Clusters
5 participants