function cns() { kubectl config set-context --current --namespace=“$1” }
#1 is working but for some reason #2 is not.
As people say that there will be lot of questions where you have to work on different namespace
I was trying with cns function that help me change the namespace promptly
It is not working.
Is there any better way ? Are we allowed to install kubecnx something like that ?
Thanks
I don’t think that you want to put this stuff into .vimrc; that’s for vim settings. But I like to do a script (I call it mkenv.sh) that contains this sort of stuff. I then run it manually. If I used a utility like tmux during the exam (I don’t), then perhaps I’d modify ~/.bash_profile instead.
The following does work for me, in my script:
function cns {
kubectl config set-context --current --namespace "$1"
}
I personally don’t do this, though. I prefer to use the -n NAMESPACE flag, since the default namespace is often used, and I’d be afraid that I’d forget to reset the current namespace if I used your script. But if you drill using your script on all of your mock exams and you don’t find yourself getting into trouble, then by all means use it.
As for installing kubecnx – no, you can’t install that for the exam.