How I scored a perfect 100% on the Certified Kubernetes Admin (CKA) Exam
— DevOps — 7 min read
In the final year of my Undergraduate degree, I was working on a project which had "High Availability" as a requirement. After a lot of deliberation and watching a ton of videos on YouTube about System Design and Architecture (my YT playlist), I came to a conclusion that the "Docker and Kubernetes" combination would best suit the microservices nature of the project - considering that I had a budget of zero and the project had to be agnostic of any cloud platform.
I began learning the very basic aspects of these 2 technologies from Udemy. This course allowed me to build my application and deploy it on Google Kubernetes Engine (GKE) but it was just sufficient for the instructor's project. My project required some more heavy lifting relating to environment variables, secrets, and deployment of a database in cluster mode (made easy thanks to Helm). Most of the time I was just googling stuff and copy-and-paste from StackOverflow without understanding the implications of it. The idea behind Kubernetes was intriguing enough for me to go for Kubernetes certification (I hadn't decided between CKA or CKAD yet) after finishing my degree.
Contemplation - CKA or CKAD?
I had to decide between CKA or CKAD - since each exam costs 300 USD and I live in India, the exam is pretty expensive. After reading articles about "CKA vs CKAD" on medium, reddit and Linux Foundation's own faq, and knowing that I have loved studying the architecture of different companies, I opted for CKA.
Luckily, it was Cyber Monday around this time and The Linux Foundation was giving a discount on the CKA Exam + LFS258: Kubernetes Fundamentals course - both costing only 189 USD together. I grabbed the deal without a second thought. Saved me quite a bit of money.
I registered for the exam on January 2020 for 7th Feb 2020 - giving me a full month to prepare. I considered that I had to work during the day for 8 hours (excluding travel time) and study at least 2 - 3 hours on weekdays (pushing myself to the limit) and at least 6 - 8 hours on weekends and keep time for friends and family.
As I was searching for some good and value-for-money courses all over the internet, I found the best one on Udemy which was on sale and includes Practice Tests and Mock Exams!
Initially, when I started I was making notes in a Notebook (force of habit due to college). Eventually, I moved to Microsoft OneNote and it is awesome! It has all content from the course neatly laid out to quickly go over if I would ever want to re-certify myself in 3 years (which probably I will). The Udemy course covered all content required for the exam in detail.
3 hours, 24 questions - seems like a long time for an exam right?
- I rely heavily on solid muscle memory for all commands. The most atomic part of a cluster is a Pod so creating one through
kubectl run --generator=run-pod/v1 nginx --image nginxshould be out under 10 seconds or so.
- Even though the exam allows you to copy-paste content from the official documentation, it has a limit of 2-3 lines so I had to be prepared to
--dry-run -o yaml > q2.yamleach time and edit the file as per the question.
- On my laptop, I can type around up to 60 Words Per Minute (thanks to Dota 2 back in High School). So by being comfortable with the keyboard, I saved a lot of time.
Before I began with CKA preparation, I had hardly ever used Vim. I relied heavily on Nano. The exam has both editors pre-installed so getting good at either one was a must. In my office, I was using Vim for some basic editing on the servers so I decided to go all out and become 100x better at Vim.
I browse HackerNews each day. On one fine day, I came across this website to learn Vim. I did all the exercises twice and I loved its awesome semantics which are easy to grasp.
I also learned the basic configuration of Vim. This helped me a lot during the exam as the default tab length is much different than the YAMLs generated by Kubernetes (which is 2 spaces).
echo "set ts=2 sts=2 sw=2 et number" >> ~/.vimrcsource ~/.vimrc
These stand for:
- ts - tabstop to indent using 2 spaces on pressing the tab key
- sts - softtabstop to move 2 cursor spaces on pressing the tab key
- sw - shiftwidth to shift by 2 spaces on pressing the tab key
- et - expandtab to insert a space character instead of the tab on pressing the tab key
- number for line numbers while editing
- There is one additional useful config -
aito allow auto-indent on pressing the return key (but this messes when copy-pasting text)
Autocompletion and Aliases
I had the following alias set on the terminal as soon as the exam began and the auto-complete was set up.
1$ alias k=kubectl2$ alias kaf='k apply -f'3$ alias kdf='k delete -f'4$ alias kdp='k delete po'5$ alias kgp='k get po'
I had bookmarked the cheatsheet from the official documentation. Since the exam allows you to have one additional tab open for documentation, etc. I opened the cheatsheet in a new tab soon after the exam began and enabled the auto-complete feature in the bash shell after setting the aliases:
complete -F __start_kubectl k.
Additionally, if you're sure that the Pod that you're deleting has no Persistent Volumes attached to it (or other resources external to the Pod), then you can do
k delete po --grace-period=0 --force to instantly delete a Pod. Saves some time.
- There is no way to add environment variables from a Secret or ConfigMap imperatively from CLI. So use the
--env SOMETHING=this --dry-run -o yamlto generate a quick template then
vimedit it to match the desired configuration. This is very useful considering you cannot copy-paste a whole YAML from documentation to the exam terminal.
- The other template to remember is that of a Pod. It is especially useful for creating Static Pods on other Nodes.
Know how to read the Documentation
The exam allows for one additional tab, apart from the main exam portal for viewing official Kubernetes documentation. Use it to its maximum potential.
- "Learn to Google" is a skill right? It is the same here for the search box on the documentation page
- The query will lead to different results - know which link will go to the desired content and which will lead you outside (which will lead to early "exam over!")
- The exam allows one water bottle which is transparent on your desk. Stay hydrated during the exam!
- The most important thing is to be calm and not be afraid to skip questions. Come back to them if time is left towards the end.
- If time is left, go over the questions once again - check for correct context, correct filenames, correct states of Objects, etc.
- Read the Candiate Handbook before exam.
- Do the practice tests and Mock Exams from the Udemy course at least 2 - 3 times before the exam day to develop good muscle memory and fluency in performing tasks.
- Do not skip the part about jsonpath thinking that it is too easy to come in for the exam. Remember that jsonpath is required for sorting output and custom columns.
Preparing in the way stated above, I completed my exam in around 2 hours. I had an hour left to go over the questions again. I received the certification with a perfect 100% score, and that too on my very first attempt!
I will refer to this blog post in my future re-certification CKA exams to know how I had prepared previously!