Building DevSecOps solutions using AWS, Terraform and Kubernetes

Kubernetes CKAD Exam Tips

  • 13th February 2022
Screenshot showing kubernetes ckad certification

Top 4 tips for passing the k8s CKAD exam

This week I passed the kubernetes CKAD exam with 91%.

The most important part to realise is that this is a time trial exam. So leave your best-practice declarative syntax at the door and embrace imperative commands.

1) Use the explain command

So you're sitting the exam and you're desperately trying to remember the name of that readiness probe field. You know it's probably under the containers section in the pod, so run this to list all fields:

kubectl explain job.spec.containers

Want to search even quicker? Pipe it to grep and search for part of the string "readi":

kubectl explain job.spec.containers | grep -i readi

Then to get the subfields needed you can just run:

kubectl explain pod.spec.containers.readinessProbe

While you have access to the documentation in the exam, I found it much quicker referring to native CLI commands.

2) Use imperative commands

Launching new pods is easy, you can just run:

kubectl run nginx --image nginx:latest

Can't remember the other parameters? No problem, write the part you know and add the --help suffix (or -h for short):

kubectl run nginx --image nginx:latest -h

This works with all resources:

kubectl run nginx --image nginx:latest -h
kubectl create secret generic my-secret -h
kubectl create configmap -h
#etc ...

Want to filter it down to specific CLI examples only? Again, use grep!

kubectl run nginx --image nginx:latest -h | grep kubectl

3) Create yaml files from imperitive commands

Sometimes you will need to use a declartive syntax to solve a problem. In these situations we can still use the imperitive command to bootstrap our yaml manfiest file generation.

Any time you would like to see the yaml that an imperative command would generate, just append --dry-run=client -o yaml to the end of a command:

# Create yaml file:
kubectl run nginx --image nginx:latest --dry-run=client -o yaml > my-pod.yaml

# Edit file manually:
vim my-pod.yaml 

# Launch changes:
kubectl apply -f my-pod.yaml

4) Backup existing pod manifest

You are not always given the original manfiest file. So always take a backup of a pod before editing it:

# First, get an overview of all resources:
kubectl get all

# Then download pod yaml
kubectl get pod some-existing-pod -o yaml > some-existing-pod.yaml

It's easy to make mistakes when you're racing against a clock, so having a backup means you edit resources without worry.

Summary

These 4 tips will speed up your k8s development and let you move faster.

Knowlegde of kubernetes isn't enough, you need to know how to work quickly with kubernetes if you are looking to pass the exam.

Rhuaridh

Please get in touch through my socials if you would like to ask any questions - I am always happy to speak tech!