KUBERNETES & DOCKER
Kubernetes the orchestration world
If you belong to IT industry then you have heard this buzz word and must have given a though “what the heck is this Kubernetes?”
Believe me I have been through the same situation and then I researched about kubernetes and got to know that it really deserves to be buzzed about.
So in this article I will explain you about the extreme basics of Kubernetes , just the terminology so that you at least get to know about this giant.
O WAIT… before diving into the world of kubernetes I want to explain docker as to understand the terminology and concepts of kubernetes you need to know the concept of docker and containers .
I will try to keep this as simple as possible if you know or do not know docker I’ll to make you understand with simple examples.
Docker and Containers :
Problem 1 — So think of a developer who has built an application and that application runs perfectly fine on his machine and in his local environment, now a new developer has joined and he has been asked to work on it, so he has to configure the same setup (installation of OS using virtual box,server config,application dependencies e.g., java,maven,proxy settings..etc etc) which becomes a tedious job because he has to download all the dependencies of that application in order to make that application run(without any documentation).
Problem 2- Suppose today you are using AWS and you want to use some other environment to explore its capabilities and make use of the other environment, so it will be difficult for you because you need to configure that environment according with application specific dependencies and configuration.
This is where Docker comes into the picture. So docker is build ship and run, you can build your application libraries and dependencies and package it inside a image. You can ship that image to any of the environment and you run that image as a container.
So for that application the developer will dockerize the application, he will make the image out of it and that image is nothing but having the base OS , the app itself and the dependencies related to that application also. Everything will be packaged, image will be stored in some repository like DockerHub (hub.docker.com) and then you can ship it. Ship in the sense you you can get the image in any environment , any system where docker is installed and then you can run it as containers.
So running docker image is called containers. This was just a brief overview of what a docker container is.
This basically resolves the above stated problems:
First the Environment built will be friendly that means you can easily run one application on any environment very quickly and very easily.
Second thing if the application is running on my machine it can run in any machine. So no more the problem of application running in test environment will not run in production environment.
So you just need to have docker installed, if docker is installed in any system, the app will definitely run.
So moving onto what containers are.
Containers are not the virtual machines. Virtual Machine is having infrastructure on top of it Operating System, then you have hypervisor layer and on top of it you install your guest OS to deploy the application on that.
I’ll give you a traditional example. You have laptop on top of that you have windows 10 and then u have virtual box and then on virtual box you again install an OS called Ubuntu and in Ubuntu you need to download the dependencies and run the application.
Suppose you want to run the another application in cent OS, so right now you have loaded your machine with windows , then cent OS, Ubuntu, then you are running the application.
So docker actually eliminates this problem as well . You install docker on windows machine or any other machine and once you have docker engine installed there is no need of hypervisor layer , on top of docker engine you will be running docker images, like I told you earlier docker images will be having the application and its dependencies. So just we need to pull the image , need to run it as containers.
So there are pull push commands, that we are not going to discuss as this post is for Kubernetes Terminology.
Also just to give you a little deep dive in containers we have infrastructure , windows OS,docker installed you can run multiple applications in different environment, one in cent os, ubuntu etc without downloading the complete OS. You just get the docker image and that image will have full OS that is the bare minimum OS means it very light OS, only required for that specific purpose with only specific set of tools and software configuration. But when we install on windows the complete OS with full configuration will be installed and we wont be using it and if that application is not fully using that OS then the space and memory will be wasted. But here in docker memory and space can be saved as it shares the kernel.
ORCHESTRATION SYSTEM : World of KUBERNETES
Running 1 or 2 containers is simple, it is easily manageable. But imagine a production environment where you want to run more than thousands of containers as nobody will be running only 2 containers, it becomes very difficult to manage those containers to orchestrate those containers .This is where the orchestration systems comes into the picture.
It takes care of the scheduling , resource needed , replication, machine failures and discovery. These are the benefits of the orchestration systems.
There are multiple orchestration systems like mesos, docker swarm, kuberbetes, normad etc.
So why kubernetes?? => It is developed in Google. It has been used in google since many years, everything was running as a borg and borg was eventually converted to kubernetes and donated to CNCF. Now it is managed by Linux fondation CNCF.
So kubernetes is the orchestration system and also docker has the native support for kubernetes from 2018, which shows they want orchestration system to be powerful and leave it to kubernetes . So docker is focusing on enhancing the tools for containerization technology and kubernetes is focusing to enhance the orchestration technology.
Kubernetes by definition is an open source system for automating deployment, scaling and management of containerized applications.
Kubernetes (k8s) coordinates a highly available cluster of instances that are connected to work together as a single unit.
The cluster will be having nodes , nodes are just different servers different machines in cloud .
Application needs to be packaged in a way that decouples them from individual hosts:means like I told u application needs to be containerized.
Containerized applications can be any docker, rocket etc..,but mostly docker is used.
In kubernetes we have master and worker.
Worker are nothing but just the nodes where the actual application runs and master is nothing but which manages where and what to run.
In kubernetes everything happens via a API call, so all the calls first go to kube API server then it runs the check what needs to be done and other components of kubernetes cluster include:
etcd -it servers as a data storage for the cluster. All the pods running information , cluster state are stored here.
kube-controller manager -it has several components that runs in the background for the cluster.
kube-scheduler-it is responsible to making thins run on the node. basically what and where to run .
kubelet-its running as a service which interacts with the APIserver and then runs the pod on node if request comes.
kube-proxy- runs on all the nodes to handle the pod to pod or node to node communication .
Lets see how these components work together :
So we will issue a command via kubectl that will hit the api server , api server will ask the scheduler for the node where to run it, this is then taken to the node via kublet of that node , kubelet after taking the request from the api server runs the container inside a pod and pulls the required images from registry and kubeproxy makes the pod accessible to internet.
I hope Kubernetes and Docker is not a buzzword anymore .