Skip to content

ability to expose kubeswitch context #166

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

Open
fenio opened this issue Mar 6, 2025 · 1 comment
Open

ability to expose kubeswitch context #166

fenio opened this issue Mar 6, 2025 · 1 comment

Comments

@fenio
Copy link

fenio commented Mar 6, 2025

Hello,

First of all thanks for this lovely project. It's a life changer for me.

But I'd love to make it even more lovely for my personal needs and for that I need ability to somehow rename k8s context based on information from kubeswitch and its context.

switch list-contexts shows something like this:

us-ord-alpha/lke236266-ctx
us-ord-beta/lke236267-ctx

These us-ord-xxx are let's say userfriendly names of my clusters while lkeXXXXX is actual context name listed in kubeconfig. So relevant part of kubeconfig looks like this:

current-context: lke236266-ctx
kubeswitch-context: us-ord-alpha/lke236266-ctx

I'd like to get "us-ord-alpha" into my shell prompt somehow but that information is not exposed so currently if I switch to "us-ord-alpha" I'm getting the following in my prompt:

[☸ lke236266:default]
❯ ~

I'm looking for a way to replace that real context name with us-ord-alpha in this case. Any hints how to do that?

@fenio
Copy link
Author

fenio commented Mar 6, 2025

As a workaround I'm using context instead of cluster name in my prompt and the following snippet:

kubectl config rename-context $(kubectl config current-context) $(grep kubeswitch $KUBECONFIG | awk -F/ '{ print $1 }' | awk '{ print $2 }')

So I'm kinda all but leaving ticket open as exposing such info might be useful for other purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant