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

When using a context with a namespace that is not default, pod completion is for default namespace #13

Open
cgilling opened this issue Sep 22, 2017 · 6 comments

Comments

@cgilling
Copy link

cgilling commented Sep 22, 2017

First off, thanks for writing this tool, it looks like it should be pretty helpful. Excited to start using it more.

This is for version 1.0.1:

As you can see below my context is registered to use the seu namespace by default, but the completions are from the default namespace. But then when the actual command is run it uses the proper namespace, and therefore can't find my auto completed pod.

>>> get pods --all-namespaces
NAMESPACE     NAME                                                                READY     STATUS             RESTARTS   AGE
...
default       canopy-2965694291-f5f6c                                             1/1       Running            0          1d
default       canopy-2965694291-kjbqq                                             1/1       Running            0          1d
...
seu           hello-world-v13-1574404032-4hzxd                                    1/1       Running            0          62d
...
>>> describe pod 
                  ...
                  canopy-2965694291-f5f6c        Running 
                  canopy-2965694291-kjbqq        Running 

>>> describe pod canopy-2965694291-f5f6c
Error from server (NotFound): pods "canopy-2965694291-f5f6c" not found
Got error: exit status 1

>>> describe pod hello-world-v13-1574404032-4hzx
Name:		hello-world-v13-1574404032-4hzxd
Namespace:	seu
...
@c-bata
Copy link
Owner

c-bata commented Sep 24, 2017

Thanks for using kube-prompt.

kube-prompt just wraps kubectl like:
https://github.com/c-bata/kube-prompt/blob/master/kube/executor.go#L20-L27

So It looks that your problem is no relevant to namespace. And your problem is also occurred when just executed following command directly.
Can you try this?

$ kubectl describe pod canopy-2965694291-f5f6c

@cgilling
Copy link
Author

cgilling commented Oct 12, 2017

I looked into the code a bit and it seems like the issue is that the completer always uses the default namespace when looking pods (see here)

Where as since the executor is shelling out to kubectl it will use the default namespace as setup by the current context that is being used.

@carolynvs
Copy link

Looks like this was fixed in 49b6437.

@jroberts235
Copy link

@cgilling - I agree that when working outside of the default context, some of the features provided by kube-prompt break. ex. ">>> -n myNamespace get po" Normally cube-prompt would allow me to tab complete the 'get' verb, and then suggest po, then provide a list of pods, but it doesn't recognize the -n.

I've gotten around this by simply setting the default namespace in my context using: kubectl config set-context $(kubectl config current-context) --namespace=<insert-namespace-name-here> OR in the kube-prompt paradigm, 'config set-context $(kubectl config current-context) --namespace='

Then I can work in my most used namespace and enjoy the creature comforts provided by this very handy tool ;)

It sounds like several people here, like me, need to work in multiple namespaces, and this workaround doesn't solve for rapid namespace changes, so I think better namespace support in kube-prompt would be a worth while improvement.

Keep up the good work @c-bata !

Cheers

@c-bata c-bata self-assigned this Feb 14, 2018
@c-bata
Copy link
Owner

c-bata commented Feb 22, 2018

Hi there! As @carolynvs says, this problem has already fixed at master branch.
But there are some important changes I want to like:

So please wait until few weeks later. I promised kube-prompt will be really better from the next release.

@cgilling
Copy link
Author

great thanks

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

No branches or pull requests

4 participants