Skip links

Kubernetes: Our Favourite Features and How to Use Them.

by Zac Sarion

Kubernetes is currently one of the hottest technologies to hit the IT landscape today. Every forum you search and even on video streaming sites like YouTube, you see tons of tutorials that are practically weeks old. But what in the world is it? And how does it really tie into the System Administrator / Dev Ops landscape? I’m Zac, a Cloud Consultant for Mobilise.Cloud. Step inside with me and discover some of the benefits of this exciting technology.

What is Kubernetes?

Kubernetes is an awesome orchestration engine used to manage containers like Docker (or Rkt). It first came from Google’s Borg project (all those moons ago). From this, portions of the Borg code for small scale applications, were passed on to the Open Source community via the Linux Foundation. Since then, Kubernetes has come into its own, with bags of businesses implementing the technology and seeing great benefits from it.

What do I think are the really cool features?

Here are three things that I think make Kubernetes compelling!

Setting up Deployments in the Cloud Becomes A Breeze

One of the cool things about Kubernetes is how easy it really is to set up a deployment. Let’s say you have a task assigned to you that you need to deploy a shed-load of nginx instances for your web application and you need to distribute the load across all your servers (hopefully running Docker or some container engine). Sure, it is easy to do a Docker run command or maybe use the compose feature, but to properly allocate your nginx instances to your servers can be a bit tricky. With Kubernetes, it becomes almost effortless to do.

See my example below

OK, so I got my master node and three worker nodes ready to rock and roll! My first task is to create a deployment of a bunch of nginx containers and the challenge now to determine how to manage them and assign them to specific nodes in my cluster. Not a problem! In Kubernetes, this is something that you do not even have to worry about. Kubernetes does this by itself.

In the example below, I ran the kubectl command: kubectl run my-shedload-of-nginx-instances –image=nginx –replicas=35

You can see in the picture beneath how Kubernetes has automatically assigned my 35 nginx pods to my three available worker nodes in the cluster:

Ease of Upgrades and Maintenance

One of the things that I found about this technology is how easy it is to upgrade or take down a node for maintenance. Before, when running a regular machine running a container engine like Docker for example, you need to go through hoops and workarounds to move your docker container to another machine.

Let’s say I am getting a disk alarm regarding my node ip-172-31-46-78, or for some reason, I have to take it offline and/or replace it with a new instance. On a system without any container orchestration in place, it becomes a bit of a challenge for me to move all my running containers and services out of the node. I will need to devise some scripting to start another container in another server, pull the correct image and configure everything. Not so with K8s.

However, with Kubernetes, the process becomes much simpler. See my example below: So in my little K8s cluster running somewhere in the cloud, I have a master node and three worker nodes. Master node: ip-172-31-34-203 Worker nodes: ip-172-31-41-1 , ip-172-31-45-118 & ip-172-31-46-78

The three worker nodes are currently running quite a bit of nginx instances. 35 of them to be exact.

Now let’s say for some reason, I will need to take down one of the nodes for maintenance. In this example, I’ll take ip-172-31-46-78 offline.
A one-liner command issued using kubectl will automatically evict all of the running containers out of the node. It also cordons the node to ensure that no pods will get assigned to it during its maintenance down time.

Without running any special commands, except for the one above telling kubernetes that the node is going offline, Kubernetes now automatically assigns the other pods to other nodes.

How cool is that!!??

Rollout and Rollback to my Heart’s content!!

One of the things that I’m finding really cool with Kubernetes is the simplicity of rollout or rollback deployments.

It is a recurring theme in almost every workplace I’ve worked for where the Dev team would roll-out something into production and find that it is not working as expected – and it takes a good few hours for them to roll back to a previous deployment. With Kubernetes, I truly suspect that the devs working this engine have made it a point to ensure that rolling out and/or rolling back releases becomes a pleasureable experience.

Taking my example of my awesome 35 pod nginx. These pods are running the latest nginx image

Now for some reason, I needed to change my nginx image to something else, say nginx:1.14.0-alpine, all I need to do really is to edit the deployment and make the change.
Getting my deployment name:

and running this command:
kubectl edit deployment my-shedload-of-nginx-instances
will bring up the edit deployment page
Now all I need to do is to change this:
to this:

and save the document, and Kubernetes does the whole rollout for you! In the picture below, you can see the engine terminating old pods running nginx:latest and replacing it with nginx:1.14.0-alpine.
Now for some reason, let’s say after this rollout, something goes wrong and I need to roll back to the previous deployment.

First, I can check the rollout history of this particular deployment by typing in kubectl rollout history deployment/my-shedload-of-nginx-instances

The results of the command show that there have been two revisions so far

Now if I key in this simple command:
kubectl rollout undo deployment/my-shedload-of-nginx-instances –to-revision=1
Kubernetes will then automatically roll back all my deployments to nginx:latest

If you would like more information about Kubernetes, you can go to the K8s website https://kubernetes.io/ . It has tons of information about the application. Another place to visit is Linux Foundation https://www.linuxfoundation.org. The website offers good training for you to grasp Kubernetes concepts.

I also recommend watching Youtube videos from Janakiram & Associates as they provide really good video tutorials on the subject.

Leave a comment

Name*

Website

Comment