Preparing for the Kubernetes CKAD Certification

I’ve been preparing for the Kubernetes CKAD certification exam from the Linux Foundation. It has been a fun learning process. I’ve learned a lot about k8s and quite a bit about general command line tricks that I have re-learned (or remembered). To prepare for the CKAD (Certified Kubernetes Application Developer) exam, I’ve been using both a minikube install with a 2-node cluster on my MBP and the Desktop Docker Kubernetes one-node cluster. I’ve learned quite a bit and I hope you find this post helpful if you are also preparing for the examination.

Basic K8s Setup and Configuration

I’ll be using the same MBP as usual. As of the time of writing this, I’m on macOS 10.14.6 (Mojave). I definitely recommend getting everything up to date as described in the above linked post using your package manager of choice, like brew. (homebrew)

Depending on how you are going to create clusters you will need to get some software that allows you to create virtual machines. I signed up for the CKAD training and decided to use Parallels to create locally running Ubuntu VMs. This is optional. You could do all of this stuff in the cloud using AWS or GCP, but I wanted to have full control, be able to work offline, and be able to debug and see everything happening. I have Parallels Pro 15.1.2 installed so that I can do this.

With Desktop Docker, you need to have VirtualBox installed for it to create the single-node cluster. I have VirtualBox V. 6.0.14 r133895 installed along with Desktop Docker 2.0.1.5.

Working with the CKAD Certification Training and Kubernetes Setup

The Linux Foundation training requires quite a bit of pre-work to get the installation working smoothly. You can use whatever mechanism you want to get VMs. You need to configure a 2-node cluster to complete the exercises. I decided to use Parallels with Ubuntu 18.0.4 and do everything locally. It’s more work, but I think I’ll learn more. Prior to starting, I highly recommend checking out Kubernetes the Hard Way because all the moving parts and pieces can become quite confusing at first. This set of documentation will ground you on many of the steps required to get Kubernetes running.

Parallels Configuration

The CKAD training comes with a couple of shell scripts to create the master node and the minion node. Starting with Parallels, create a Ubuntu (18.0.4 at the time of writing) VM. Allow it to startup and hang around for a while. Allow it to pull updates for all the latest stuff as well as install the Parallels Toolbox. Shut down the VM. In Parallels open the VM’;s configuration panel. Give the node a unique name (ex. “master”) and then go to the hardware tab. Configure the node for at least 4 GB of RAM because this will allow you to turn swap off later. 4GB seems to be the minimum RAM to allocate to turn off swapping which is required to run kubernetes.

Start the VM back up again. We need to permanently disable swap. To do this, open up a terminal and enter sudo nano /etc/fstab. Rem out the swap line and save the file. The next thing I recommend is to shorten up the terminal prompt. To do this edit ~/.bashrc. Look in the file for where it is setting PS1 and replace that line with something simpler, for exmaple:

set PS1="\u:\w\$ "

The next thing you need to do is explicitly set your hostname to something unique:

sudo hostnamectl set-hostname XYZ

I would suggest the same name you gave it previously in the Parallels configuration panel, in my case this is “master” or for the minion VM, “minion”. Restart the VM.

Installing Required and Suggested Software for Working with Kubernetes CKAD Certification Training

There’s a few packages that will make life easier. Use apt from the command line:

sudo apt install curl
sudo apt -y install python
sudo apt install python-pip
VSC Python Configuration

Next grab MS VS Code (VSC) using the GUI installer. Open VSC and create a test.py file and save it. You will get an error. VSC will prompt you to install Python plugins and linters. Down near the gear wheel in the lower left corner you can change the default location of Python to be correct. Click on the Python version. Be sure to pick the version of Pyhton you installed, not the system default. It should be located in: /usr/local/bin/python.

I also suggest installing the RedHat YAML plugin. Very handy. While I mention YAML, to work with Kubernetes effectively you really need to get a handle on YAML indenting and the syntax. It might sound trivial, but you can spend a lot of time debugging YAML files. It can be quite frustrating.

CKAD Training Configuration

With all that done you can now run the CKAD training shell script on the master node – the training includes all the instructions you will need. Once you done with that and you look at the output you will see an error about systemd. You will need to edit the docker daemon.json file to set systemd as the default. Edit /etc/docker/daemon.json cgroupdriver to:

{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2"
}

Restart the VM again. When it restarts go to the terminal and try a basic command like: kubectl describe node or kubectl get nodes. You should get a bunch of data back about the node. The latter command should list off the active nodes (there should be just one if you are following along).

Be sure to scroll back thru the script’s output and save the “join command”, because you will need this later to add nodes to the cluster.

kubectl describe nodes

Start configuring the minion node by following all the steps above to prepare the Ubuntu image before running the CKAD script for the minion node. If you mess something up you can start over:

sudo kubeadm reset

Then re-run the k8smaster script.

kubectl get nodes

Once you have the master and minion nodes installed and working, unless you are super handy with VI, I would suggest setting the default KUBEDITOR to nano.

To do this add the following line to your ~/.bashrc file:

export KUBE_EDITOR="nano"

One of the best reasons to use Parallels is the snapshot feature. I made extensive use of this to roll-back to earlier states. One of the challenges with this configuration is the changing IP addressing. Things seemed to get messed up, in particular the local docker registry installation on the master node.

Additional Learning to Prepare for the CKAD Certification

Desktop Docker Kubernetes Panel

Once I completed the training, I looked around for additional training and challenges to make sure I really know how to do things that might be expected on the certification test. I found a lot of really good tutorials and resources. Most of these do not need a multi-node cluster. Running Docker and its single-node configuration is much more convenient and less resource intensive. Switching between clusters is pretty simple.

To see what contexts are available use:

kubectl config get-contexts

To change to docker-desktop use:

kubectl config use-context docker-desktop

Interesting Kubernetes Projects

  • Ambassador is an “open source, Kubernetes-native API gateway for microservices built on Enjoy”.
  • Prometheus –> centralized logging services
  • Grafana –> visualization and dashboards
  • Fluentd –> data collection for logging
    • https://kubernetes.io/docs/tasks/debug-application-cluster/logging-elasticsearch-kibana/
    • https://kubernetes.io/docs/concepts/cluster-administration/logging/
  • Sonobuoy –> diagnostics on your cluster and its current state

Troubleshooting Kubernetes

  • https://kubernetes.io/docs/tasks/debug-application-cluster/troubleshooting/
  • https://kubernetes.io/docs/tasks/debug-application-cluster/debug-application/
  • https://kubernetes.io/docs/tasks/debug-application-cluster/debug-cluster/
  • https://kubernetes.io/docs/tasks/debug-application-cluster/debug-pod-replication-controller/
  • https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/

Additional CKAD Certification Training

  • https://www.udemy.com/course/certified-kubernetes-application-developer/
  • https://blog.codonomics.com/2019/09/essential-vim-for-ckad-or-cka-exam.html
  • https://blog.codonomics.com/2019/09/essential-tmux-for-ckad-or-cka-exam.html
  • https://thecustomizewindows.com/2014/11/use-tmux-mac/
  • https://github.com/dgkanatsios/CKAD-exercises
  • https://medium.com/chotot/tips-tricks-to-pass-certified-kubernetes-application-developer-ckad-exam-67c9e1b32e6e
  • https://github.com/bmuschko/ckad-prep
  • https://www.oreilly.com/learning-paths/learning-path-certified/9781492061021/9781492061045-video325787

CKAD Certification Next Steps

Practice, practice, and more practice! There’s a ton of things to learn and know, so practicing on the command line is key. Next up for me is the exam. I’ll be practicing over the Christmas holidays with a goal of attempting the exam in late January 2020. I think I have a reasonable shot if I focus and practice.

Leave a Reply

%d bloggers like this: