Mae:
hello! are you allowed to download something like kubectx for the exam to help switch contexts and namespaces? Or should I be focusing on learning how to do that manually with the kubectl config set-context
command syntax?
Mohamed Ayman:
I think to be in a safe side, focus on learning how to do it manually.
Mae:
ok but you don’t know if additional tooling is an option?
runlevl4:
You’re provided the necessary commands to use the right cluster.
SM:
I had this link bookmarked - https://kubernetes.io/docs/tasks/tools/install-kubectl/#enable-kubectl-autocompletion
SM:
and then I ran these 3 commands right from that page, copy and pasted:
echo 'source <(kubectl completion bash)' >>~/.bashrc
echo 'alias k=kubectl' >>~/.bashrc
echo 'complete -F __start_kubectl k' >>~/.bashrc
SM:
and then I changed the 2nd command to create two more aliases:
echo 'alias kn="kubectl config set-context --current --namespace"' >>~/.bashrc
echo 'alias kg="kubectl config get-contexts"' >>~/.bashrc
SM:
and then last I reloaded bashrc with exec bash
SM:
so I could use k instead of kubectl and I get autocomplete (WHICH IS A LIFE SAVER) and I can do kg to see which cluster is set and kn <namespace> to quickly lock into a namespace
SM:
i did this for cka and it worked great. you can also do this in the kodekloud lab environment, I do this for every lab so it’s muscle memory now. I am planning to use it again for ckad
Tej_Singh_Rana:
There is no requirement to use third party tools.
You can refer this page to switch/set contexts.
https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#config
Mae:
yes! thanks all, I know how to set alias’, just wondering about the ability to use 3rd party tools. I know there is not a requirement, I’m simply asking because people use this tool in the real world
SM:
I didn’t try to install any 3rd party tools but it should technically allow you to do it
SM:
i only did alias commands, auto complete and tmux to make my life easier
SM:
kubectx shouldn’t be needed as they give you the command to copy and paste to change clusters before each question
SM:
if you try it on the exam, come and give us feedback, would be interesting to see if that works
runlevl4:
Stick to the basics. A couple of simple aliases and maybe a quick vimrc edit and you should be gtg. It’s not how you’re likely to work in the real world, but this isn’t the real world. It’s an exam. Tailor your approach with that in mind. The more simple you keep things the less you have to worry about remembering under the stress of the exam.
Mae:
well kubectx makes it extra simple And yep! I know it’s an exam and not the real world, which is why I was asking the question in the first place!