3 weeks, 1 CKA

How to rock the k8s certification in no time

Kube & the CKA

k8s logo

Kube, k8s or Kubernetes is the industry leader when you need to orchestrate some containers at scale. The containers war is over : Swarm, Mesos and all other alternatives are dead (except Nomad under some circonstances).

The Certified Kubernetes Administror (CKA) is a certification delivered by the Cloud Native Coputing Fundation (CNCF) and the Linux Fundation that will ensure that the certified peoples have the skills and knowledge to operate as cluster administrators.

As a certified kube nerd, I can now confirm that this certification is much more than a cool line on your CV.

My CKA story

My certification was funded (price is around 300$) by my previous job (a year ago). At that time, I was working as a DevOps/CI guy on a SaaS product based on Gitlab, Gitlab-CI and Docker. Containers at a high or low-level was part of my day to day job 1.

For various reasons I quit and I am now working as a fullstack dev (Rails/React) so I just use containers to spin up my dev env. Due to this change I did almost have no time to dig on kube and the deadline to pass my exam was getting closer and closer 🚨

On October I kicked myself in the ass to rush out the CKA and pass my exam ASAP.

3 weeks later I am now certified ! YAY ! (with a 85% score)

Enough about me, now I will share with you everything you need to know to prepare and pass your’s !

Course Material

When looking for learning materials, I focused my search on courses labelled as CKA courses only (other ones do not go deep enough). The best one out there is Certified Kubernetes Administrator (CKA) with Practice Tests by Mumshad Mannambeth on Udemy (reddit agrees with me so, it should the truth 🤷).

The awesomeness of this course comes from on how the content is balanced between videos on theory and concepts around kube (architectures, entities and so on) followed by hands on-labs. Directly from your browser, you will be able to practice and get your hands dirty by typing some “kube cuddle” commands on a multi-nodes cluster setup. Tasks in each labs is clear enough for you to get the solution by yourself or by the official kube docs. Of course, you can always take a look at the associated video if you are stuck or want to confirm that your way of doing things is the right one.

If you want to rush out, you should be able to finish the course by a week or two, the rest of the time will be labs, labs, labs and labs. This certification is a practical one and you need to practice a lot.

Exam Prep Materials

When you starting to feel that you can control some kube powers with your hands it’s time to go on practice tests. Starts with the one in the course by Mumshad. In order to pass the CKA you need to be efficient on a bunch of various tasks. Practice pratice practice in order to become fluent in a least :

  • cluster upgrades using kubeadm
  • etcd back/restore
  • pods scheduling (with PV and PVC)
  • deployments and scheduling (with PV and PVC)
  • roles setup (users, Role/RoleBinding, ClusterRole/ClusterRoleBinding)
  • troubleshooting pods
  • troubleshooting cluster components

in order to sharpen your skills, use the labs on killer.sh. You will have two “free sessions” attached to your Linux Fundation profile. Be careful, those exams are way more difficult that the real ones. Hopefully this will give you a very accurate feeling of your capabilities when times maters. Take time to review the answers as they will give you deep explanations on the how and why. Killer.sh interface is quite the same as the one you will use in the real exam so take time to check the setup and customize it the way you like.

Now you are ready, go for the exam day !

Exam Day

On the exam day, prepare yourself and your environment well. You can access the session 30 minutes before the exam starts. Use this time to setup your desk and your room. You need to be a in quiet and empty room with nothing on your desk to speed up the check-in. The exam proctor will first ask you for your ID. After that you will go for a room tour, an usb connected webcam is prefered since your need to turn it in all directions for the proctor to verified you’re not cheating.

During the exam, the only online resource accessible is the kubernetes documentation. No worry, this is the only thing you need. I can recommend enough to use it why you are learning to be very comfortable with it on the exam day.

Do not stress out, take your time, at least you have a free retake if you miss the first one !

Tricks and Tips

CKA is about speed and efficiency, here are some usefull tips.

UTFD : Use The Fucking Documentation

k8s documentation is a gem, everything is already there but you have to know some shortcuts to quckly access the examples or articles your need. USE THE SEARCH to quickly find yaml manifests for things like PV, PVC. Just type PV and rush the first link!

Another usefull page in the documentation is the kubectl cheat sheet, as usual, just type “cheat sheet” and you are good to go!

kubectl : be imperative first

k8s is about carefully handcrafted yaml manifest, right ? That’s too slow in our case. You need to be fast. Hopefully, kubectl can do 90% of the job for you.

Always use the imperative approach as a first intention. Let’s imagine you need to run an ngnix POD:

kubectl run nginx --image=nginx

or if you need to create a service :

kubectl create service clusterip my-service --tcp=5678:8080

Sometimes, some of the options are not configurable using the cli, no worry, kubectl have your back too ! You can generate a yaml manifest directly from the cli :

kubectl run nginx --image=nginx --labels tier=frontend --dry-run=client -o yaml > pod.yaml

By redirecting it to a new text file, you will then be able to add the missing specs from a vim session followed by a kubectl apply -f to apply your changes.

There is also a lot of examples in help messages from the cli ! Before loosing time changing windows from terminal to browser, append -h to your command ! 2

Extra tip! If you need to generate a DaemonSet or StatefulSet, you can not do it directly from the cli but since thoose specs are similar to a deployment one, generate a deployment and edit it afterward.

Finally practice some jsonpath stuff and play with it to output data from pods, nodes, the way you want.

Take the time to setup your env

The vitual machine you will be working on is a simple Ubuntu with a stock XFCE config. Base setup for the shell/ssh and VIM (colors etc) will be applied by default. Here is the things I think is worth it to add in the bash config :

# optional, should already be setup
alias k='kubectl'
# for fast apply
alias kaf='kubectl apply -f'
# old habit..
alias vi='vim'

# save tedious typos
export do='--dry-run=client -o yaml'
# we are in a hurry, we do not want to wait for things to terminate gracefully
export now='--force --grace-period 0'

# just to organize things, useful while reviewing our answers
function mkcd {
	cd $HOME && mkdir -p $1 && cd $1
}

Known your VIM

Due to the time constraint, I did not recommend working outside the terminal, except for Firefox and navigating the docs (since you are in a remote desktop, everything feels a little bit slow).

Some efficiency with VIM will be a great plus for the overall exam. At least knowing the basic on how to edit/navigate/save the file is a must have. I also recommend getting confortable with :

  • basic moves: h,j,k,l,b,w,e
  • visual mode
  • copy/paste
  • advanced moves : t/T, f/F
  • search/replace
  • :N to jump to line N

Shell basics

Some shell basics are also a great plus, the most important one is Ctrl+R for reverse searching a command in your history. Add to that some stuff like !$ to recall the last arg from your previous command, you should be able to have a flow like this :

vi somestuff.yaml
kaf !$

Sometime, you may need to filter/modify output provided by a command, some shell basic like grep, cut, tail, head may help you. If you already know some shit about AWK, be sure to also review it a little bit, this tool is dope and can archive very impressive stuff.

Now, it’s your turn.

kubectl apply -f goodluck.yaml

  1. Kudos @athoune ↩︎

  2. Another shell tip ! !! -h to recall your last command with the extra -h ↩︎