-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Option to unset the namespace for the current context #348
Comments
I have created a crude PR for implementing this behavior. However, now that the feature is here, I am wondering what is the concrete benefit of this for you over setting it to "default"? |
Wow, thanks a lot @Akaame! The problem:Applications like k9s will use the namespace set for a particular context by default every time you start them but won't adjust the namespace for that context even when you switch between namespaces (probably because it's a change to the kube config file and I guess that's something tools like k9s and Lens don't wanna touch). K9s always used to go to the last used namespace on open (which is stored in its config file), but now always goes to the namespace specified in the kube config file (which was set by The benefit:Having the option to just unset the namespace for a context with |
Okay. I also had the same problem when I was switching over from k9s to kubectx+kubens+fzf. I tested the solution with k9s and
Also results in the same behavior that Also confirms this. So your options are:
Cheers |
Yes I can confirm that after running If the last namespace was I am using k9s version |
So let's say you executed What is the NS you see in |
TL;DRJust calling Calling k9s with a context (like Detailed explanation with examplesOk, so lets assume you run
If you now call
(The The next step is important and might have caused confusion, because you have two options which have a different behavior. 1. Just call k9s:
|
Okay, unknowingly I was on a super old version of k9s. So the process you have described was not the case for me and sorry for taking your time. Will test the PR branch following the steps you have laid out and ping the repo owner for a review if everything works expectedly. Thanks and cheers |
Test Steps:
Result: Shows pods from Then:
Result: Shows pods from all namespace under Sorry for not checking my k9s version and dragging the discussion. I think the results cover your scenario. @ahmetb Abi merhaba, Would it be possible for you take a quick look at the PR? |
@Akaame No worries at all! It also helped me to understand the logic behind namespace handling of kubectl, kubens and k9s better. And yes, your test steps and expected results are concise and accurate. |
Feature Request
The
kubectx
command has the flag-u
/--unset
to unset the current context.This is currently not possible with the
kubens
command.Please add a flag like
-u
(for unset) or-x
(for delete / reset) to thekubens
command to unset the namespace configured withkubens
.ATM this is only possible with the following kubectl command:
Reproduce
kubens demo-namespace CURRENT NAME CLUSTER AUTHINFO NAMESPACE * example example admin@example demo-namespace
Now it's impossible to reset the set namespace. Setting it to "default" also won't unset it but just set it to the "default" namespace.
The only option to reset the namespace is to unset it with the following kubectl command:
kubectl config unset contexts.example.namespace
The text was updated successfully, but these errors were encountered: