Kubernetes Cheat Sheet and Aliases

  • 28 February 2021

Userlevel 7
Badge +22


Are you tired of typing kubectl over and over again?

Hi Folks,

If any of you are planning on taking the CKA or CKAD certification exams bear in mind that effective use of your time is very important for passing because they are both hands on practical exams with no multiple choice questions. I completed the last question of the CKA in the final minute of the exam!

You can save a lot of time by creating aliases. So instead of having to type constantly kubectl you can create an alias k and type this instead. 

It is up to you how many you want to create during the exam but for daily work life these aliases are also huge time savers.

Ahmet Alp Balkan has a great script to create many aliases for your home labs or work. If you are like me can just pick and choose a few and create them. https://github.com/ahmetb/kubectl-aliases

Here is a simple example to create a k alias for kubectl:

open the .bashrc file in your home directory with your favourite editor


Type in the alias (I normally put mine right after some of the pre-existing ones that are in there with the default installation) 


For autocompletion to continue working you can also add “complete -F __start_kubectl k”

and run this command once from the terminal:

source <(kubectl completion bash)
echo "source <(kubectl completion bash)" >> ~/.bashrc # add autocomplete permanently to your bash shell.

You need to logout and log back in for the new aliases to start working.

Good luck and hope this helps shorten your typing. 





Userlevel 7
Badge +17

Good hints. Time saving is very important in hands on exams.

Userlevel 4

Super simple but super helpful! CKA is next on my list, so this is perfect.

Userlevel 7
Badge +6

Awesome stuff Geoff, keep them coming