Comments (9)
@jwhitcraft I just hacked a kubens
tool. Can you try check out this branch, add it to your PATH and try kubens
? https://github.com/ahmetb/kubectx/tree/wip-kubens I appreciate feedback.
from kubectx.
@jwhitcraft Interesting idea. I donβt have a lot of daily experience with namespaces. It looks like if you want to associate a namespace with a context entry, you need to create a new context entry (or modify the existing context entry).
Please correct me if I'm wrong, but in your example, my-cluster
would always be associated with the test-namespace
. I can think of refactoring the kubectx alias functionality to accept a namespace argument like this:
kubectx prod=my-cluster
kubectx test=my-cluster:test-namespace
because there's no way to do kubectl config use-namespace
today. What do you think of this?
from kubectx.
@ahmetb, that works for me. Currently I do this in my bash script which allows me to keep the same context but change the active namespace at will.
function k8sns() {
ctx=`kubectl config current-context`
ns=$1
// verify that the namespace exists
ns=`kubectl get namespace $1 --no-headers --output=go-template={{.metadata.name}} 2>/dev/null`
if [ -z "${ns}" ]; then
echo "Namespace (${1}) not found, using default"
ns="default"
fi
kubectl config set-context ${ctx} --namespace="${ns}"
}
from kubectx.
@jwhitcraft I see, that's essentially modifying your context. But it should be fine. I have an alternative proposal:
We can ship an additional kubens
script, just like kubectx
it can list/auto-complete the namespaces active in the current context and modify the current context to use the namespace, like your script does. It would also provide switching back and forth between namespaces using kubens β
.
Which solution do you like better, a separate tool, or aliasing feature charged with namespaces?
from kubectx.
@ahmetb a seperate tool would be best the more and more i think about it.
from kubectx.
@ahmetb I just got back to work and i'll get this setup today.
Thanks!
from kubectx.
@jwhitcraft have you got any feedback?
from kubectx.
@ahmetb, so far working well. nice job π
from kubectx.
This can now be installed brew update && brew install kubectx --HEAD
from kubectx.
Related Issues (20)
- Are go versions still considered not stable? HOT 2
- kubie and kubens mixed cause kubeconfig syntax error HOT 12
- Canβt use `--height` in fzf options on Windows HOT 2
- blank issue HOT 1
- Add --selector option to kubens HOT 1
- Feature Request: Use kubectx to use right version of kubectl binary for a given K8s cluster HOT 1
- `kubens` fails with `invalid apiVersion "client.authentication.k8s.io/v1"` but `kubectl` works normally HOT 2
- Vulnerability of dependency "golang.org/x/net" HOT 1
- Add completions for Nushell
- Add kubectl plugin installation to Homebrew formula HOT 4
- [Go] kubens not working with in-cluster config HOT 1
- show all of NAME, CLUSTER and AUTHINFO in cluster selection list HOT 2
- Allow customizing path to KUBECTX and KUBENS_DIR
- Homebrew install makes kubectx slow HOT 6
- Shell completions (for zsh) fail for kubectx if its binary is renamed to kx HOT 1
- Autocomplete does not work when installed as Krew plugin HOT 2
- Autocomplete breaks when multiple longer contexts match HOT 2
- kubectl ctx outputs code lines start with plus sign + HOT 1
- error: open /home/myuser/.kube/config: permission denied HOT 1
- Consider open up internal packages HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kubectx.