Monday, June 22, 2020

Kubernetes for beginners - Kubernetes and Container Orchestration Introduction



                             
     

In this series of posts you will learn all the important concepts of kubernetes starting with what container orchestration and kubernetes are.


 Let's say we are working on two different micro service applications Product Service and Coupon Service which use a Database server and the product service in turn uses the Coupon Service to get its work done. As a developer or a DevOps engineer the very first step to deploy these applications to test, staging or even production is to create an image or containerize these micro service applications using tools like docker .These images will be based off an operating system and depending on the kind of application you will have Java, NodeJs, etc on top of it. Then if it is a java web application you will have application server and finally your application layer itself. Once you have this image as a developer you can launch one or two containers on your local machine to test your micro services quickly. But for production deployment you will need hundreds and even thousands of these containers up and running.



 That is where container orchestration comes in . Container Orchestration is a process of launching multiple containers or a cluster of containers along with providing various services or non-functional requirements for these micro service applications starting with Fault Tolerance. If one of the containers goes down then there should be a backup or there  should be hundreds of backups for every container in the cluster so that the clients will never see errors coming back.

Second these containers should be automatically scaled based on that demand scale up and scale down. So if there is too much load or  incoming requests that are coming in for a particular micro service automatically that particular container should be scaled up, new instances or new containers should be launched and when the demand goes down those containers should be automatically cleaned up  or destroyed so that the resources are used optimally.

Once these micro services are present on the cluster they should be automatically able to
discover each other over the network and communicate with each other as required. In this case the product service will communicate with the coupon service and both these micro services will communicate with the DB server container as required. Also these applications should be able to access the world outside and other applications outside the cluster should also be able to access these micro services public access should be possible over the network.

 Last and very important piece Rolling updates and Rollbacks this is what makes kubernetes so popular rolling updates meaning if we have a new version of product service lets  say,  we have made some changes to the product service application and now we want to deploy the new version onto the cluster these container orchestration tools will allow us to do that using rolling updates .

That  means  while the applications are rolling we can do the updates so that the clients or the end users will see zero downtime. The way that is possible is - The older version containers will be still be up and running, some of the containers that have  the older version of the software will be still up and running as the new containers come up and slowly as the new containers come up all the traffic will be routed to those new containers and the old containers will be destroyed that is nothing but rolling updates. So that the end users will not see any downtime.

And Rollbacks is a very powerful feature. When a container orchestration tool says that it supports roll backs that means you can roll back to a certain version of the cluster. Every time you do an update to the cluster it will maintain all those versions for you and at some point if you think there is a problem with certain version of coupon service or product service or this DB server you can tell the container orchestration tool like Kubernetes  that I want to go back to a certain version and it will do that for you with a single command. Now that you know what container orchestration is kubernetes is one of the most popular container orchestration tools that gives all of these creating a cluster and all non-functional requirements right out-of-the-box.



 Kubernetes in Greek  means helmsmen or ship pilot. So kubernetes tells us as developers or devops engineers that you have done a great job in containerizing your applications and loading them on to the ship,  now hand them over to me and let me navigate that ship to whichever environment you want so it will create a cluster for our test environment taking all the containers that we give it or it can even create a Prod  cluster for us with simple steps. Kubernetes is also referred to as Kube or K8s because there are eight alphabets between K and eight in kubernetes K and S in kubernetes. And it is pronounced as Kates.  So you can either use Kube as a shortcut or Kates or K8s or Kubernetes, It's up to you.

 Kube makes CI and CD continuous integration and continuous deployment super easy in a way it reverses the entire process .Once you start using kubernetes in our organization the DevOps engineer can simply set up the cluster even for a production environment and just hand that cluster over to a Dev team and then the Dev team can do the production level deployments very easily. That's the power of kubernetes. If not production level deployments at least you can make sure that your application is production ready by deploying your applications or containerized applications onto a Dev cluster or test cluster.

The cloud native computer computing foundation CNCF is responsible for developing and licensing of  kubernetes. Kubernetes or K8s is so popular that all the cloud providers like Google cloud provider,  Azure  or AWS have in build support for kubernetes. Google kubernetes engine is kubernetes support in GCP google cloud. Similarly AWS elastic container service is AWS support for kubernetes .

And  Azure  kubernetes service is the inbuilt kubernetes service within Azure,  so we can use these services right out of the box from these clouds or we can install kubernetes on our laptops we can install kubernetes on the organization's bare-metal servers or we can use the instances  provided by
these cloud providers and install kubernetes from scratch on our own or you can use these ready to use services. So depending on the organization you are working for that will vary. I have seen organizations where they have their own on-premise  bare-metal servers. On top of it they will create their own kubernetes clusters and I have seen organizations which use these service providers and I have seen organizations where they use these cloud providers but they create their own kubernetes cluster on top of these cloud providers instead of using this ready to use services.

Summary:

You have learnt what container orchestration is : Container orchestration is a process of taking the images we create as Devops engineers or developers and launch hundreds and thousands of containers that are required for our production and while doing that while creating that cluster container orchestration process also gives us several non-functional services like
Fault Tolerance, on-demand scalability, these micro service automatically discovering each other they should be able to access the services outside and vice versa. Rolling  updates which is a very powerful feature with zero downtime our applications should be upgraded and if you want to go back to a certain version of the cluster that should be possible through Rollbacks. kubernetes is so popular because it provides all these cluster creation and all these services right out of the box .

 Kubernetes in Greek stands for Hellman which is ship pilot so it tells that you have done a great job loading all your containers onto the ship and that ship over to me and I can navigate it smoothly on to test stage production etc. You  have also learned that you can easily install kubernetes on your local machine to deploy your applications and test them . You can  install kubernetes on a bare-metal server on your organization or onto a cloud like google AWS  ,Azure you can also use inbuilt services available for kubernetes when you use these cloud providers .One important point you have learnt is you can even do production level deployments very easily.  The DevOps engineers will simply create a cluster for you and you as a developer can set up a CICD that will push your applications to that cluster.