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

Kubernetes namespace fetching slow #237

Open
Guitarkalle opened this issue Feb 9, 2020 · 3 comments
Open

Kubernetes namespace fetching slow #237

Guitarkalle opened this issue Feb 9, 2020 · 3 comments

Comments

@Guitarkalle
Copy link

When enabling displaying the kubernetes context on the prompt the terminal really slows down.

I think it's because when displaying the namespace it uses kubectl which seems like a bad idea.

Since you already are reading the kubectl config file I think you could just parse it from there?
Or at least make displaying the namespace optional, now it feels unusable because it lags 2 seconds everytime the prompt line needs to be displayed.

@bobthecow
Copy link
Member

The namespace is optional (and defaults to off) as of #214

I'm happy to review pull requests making it faster when it is enabled :)

@garbelini
Copy link

@Guitarkalle

The hack below uses an external dependency and I'm not really sure how reliable it is but having said that...

I changed my __bobthefish_k8s_namespace function to use yq. The time spent on it reduced significantly.
Before:
36 54179 ---> __bobthefish_k8s_namespace
After
42 15665 ---> __bobthefish_k8s_namespace

function __bobthefish_k8s_namespace -S -d 'Get the current k8s namespace'
    yq eval '.contexts[] | select(.name == "'$context'") | .context.namespace' ~/.kube/config
end

And under the __bobthefish_prompt_k8s_context function I'm passing the context:

(...)
    [ "$theme_display_k8s_namespace" = 'yes' ]
    and set -l namespace (__bobthefish_k8s_namespace $context)
(...)

@bobthecow
Copy link
Member

@garbelini we could add that as an optional dependency, and have it fall back to the slow one? there are several other places we do a manual version of a thing that would otherwise slow everything down (e.g. finding hg project directories)

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

3 participants