Posted on June 11, 2018
Kubernetes seems to be everywhere these days. It has become a bit of a buzzword in the software development industry. A day doesn't go by in the office without someone mentioning it but what is it?
Kubernetes is a container orchestrator that allows people take advantage of microservices architecture in a controlled way. It was originally developed in Google but was open-sourced in 2014 and now the CNCF (Cloud Native Computing Foundation) are taking good care of it. There are a number of reasons why you would benefit from learning about Kubernetes. It has become common to see Kubernetes listed as a desired or required skill in software job descriptions especially with roles relating to DevOps. I have also noticed a number of large tech vendors rushing to bring out there own enterprise-ready versions of Kubernetes like Red Hat Openshift and SUSE CaaS. It can only get more prevalent in the industry with these big vendors backing it.
Aiming to become a CKA (Certified Kubernetes Administrator) is a good way to start learning about this powerful orchestrator. The CKA exam is a 3 hour practical exam from the CNCF where you are asked to carry out admin tasks on a number of Kubernetes clusters that are all in different states. You have to get over 74% in the exam in order to receive the certification which can be difficult to achieve. I'd only recommend going for it if you already have a reasonable level of experience with Linux server environments.
This post isn't going to be a deep dive into the questions on the exam nor is it going to cover Kubernetes in any great detail. I'm just going to share how I prepared for the exam and what I felt worked well.
As its a practical exam, I figured the best way to study was by doing so I set about getting myself a cluster to play with. Luckily it doesn't require a massive amount of resources to get started unlike say an Openstack cluster. For my set-up at home I had a little Asus SFF PC (pretty small as you can see below) running Ubuntu 18.04 with an i3 4030U processor and 8GB of RAM - not a monster of a machine by any stretch of the imagination but it still ran everything very comfortably. From looking around to web, its even possible to deploy a cluster on Raspberry Pi3s. It takes no time at all to get a one node cluster up and running thanks to kubeadm:
1) Install Docker
apt-get install docker.io
2) Add the Kubernetes repo and install kubeadm, kubelet & kubectl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat </etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-get update
apt-get install -y kubelet kubeadm kubectl
3) Run kubeadm with the Pod network CIDR range for Flannel. I went with flannel as it was the first CNI (Container Network Interface) that I came across - there are many others you can chose from.
kubeadm init --pod-network-cidr=10.244.0.0/16
4) Create the flannel pod network
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.10.0/Documentation/kube-flannel.yml
5) Remove the taint from the master node to allow you to deploy pods on the node - only needed if you're running a one node cluster
kubectl taint nodes --all node-role.kubernetes.io/master-
A one node cluster is a good place to start and it will allow you to play with a lot of the resources within Kubernetes. There comes a stage however where the one node cluster doesn't cut the mustard any more. Tasks like scheduling pods onto specific nodes with labels, using taints or affiliation and anti-affiliation all need a couple of worker nodes. For this I had to turn to public cloud. Many cloud providers have offers or credits to attract new customers so a K8s playground shouldn't cost you an arm and a leg. My three node cluster didn't cost me a penny thanks to the folks at Google Cloud and their €250 worth of free credit for signing up.
Once you have a cluster up and running, it is important to try and deploy real applications in order to get a better idea of what all the resources do and how they interact with each other. I started off simple trying to deploy one of my own python flask applications that I had been working on. Once I had a good grip of that I went about trying to deploy a home media services like Plex and Radarr taking a lot of guidance from an article on how to deploy these services using docker compose.
Must not forget to mention the Kubernetes documentation - yes you are able to refer to docs during the exam. I found the documentation fantastic when I was trying out all the different deployments. Everything you need for the exam is in the documentation however I wouldn't recommend relying on it as searching through the docs can eat up valuable time in the exam. During my preparation, I had to turn to the documentation fairly often but this helped me get familiar with navigating my way through them and finding what I needed quickly which really helped me in the exam.
This approach worked for me and hopefully someone out there will find it helpful. Best of luck to anyone planning on sitting the CKA exam!