Micro-Blog 2 of 3: What I Wish I Knew Before I Took the CKAD: Bourne Again

What I Wish I Knew Before I Took the CKAD: Bourne Again

What I wish I knew before I took the CKAD: Bourne Again

You’re given two hours from the start of the exam to when you run out of time, or you request it to end. In my certification journey, I have never hit the time limit except when it came to the very first one I took. The CKAD is yet another exception in this journey.

That’s why it’s imperative that you complete your commands in as few keystrokes as possible and that your pinky is sore from going to the “Autocompletion Gym.”  That’s why this tip is all about setting up your bash profile so that when you get into the exam, you pound out the required completions, set up the right aliases, and save time throughout the exam.

Aliases

Try these aliases and commands out on your own before you commit to them, but they helped speed up my troubleshooting during the exam:

echo 'source <(kubectl completion bash)' >>~/.bashrc
kubectl completion bash >/etc/bash_completion.d/kubectl

This will set up your basic kubectl auto-completion. But, if you’re anything like me, we can get even lazier:

echo 'alias k=kubectl' >>~/.bashrc
echo 'complete -F __start_kubectl k' >>~/.bashrc

The first command sets up an alias for kubectl to be “k.” Yep, “k.” Why type seven letters when we could type one? The next command ensures that the autocompletion we set up previously works with that new alias. For example, if we wanted to see all of our pods across all namespaces for a bird’s-eye view, it would be:

k get po -A

This gets us pretty far in terms of speed. But you might have to generate some YAML with the --dry-run=client -o yaml command. How do we speed that up? Let’s add another alias:

echo 'alias kdr="kubectl --dry-run=client -o yaml" ' >>~/.bashrc
echo 'complete -F __start_kubectl kdr' >>~/.bashrc

Now, if we want to generate the base yaml for a pod that needs to be created, all we have to run is:

kdr run nginx --image=nginx > nginx.yaml

This will work for any resource you need to generate YAML for; all you’ll have to do is redirect it to a file that you want to edit if needed.

Make sure you use our previous tip to source tmux from the correct profile, so all of these new configurations stick. And one last thing, before entering the exam, commit these commands to muscle memory. That way, as soon as the exam starts, you’re already hammering away at your profile. Before I took the CKAD I made sure to practice them at least ten times before entering the exam.

That does it for this micro-blog. The next one focuses on a very easy-to-make mistake, so don’t miss it!

Cloud Academy