Deep dive into Kubernetes 0x1
Tags: kubernetes, devops, microservices
Published: 2020-11-23 05:38:40

# __What is Kubernetes ?__
Kubernetes is a portable and extensible open source container orchestration tool used for managing container workloads . Initially developed by google in 2014 and later managed by cncf .

# __Lets understand the deployment methods :__

![Going back in time](https://d33wubrfki0l68.cloudfront.net/26a177ede4d7b032362289c6fccd448fc4a91174/eb693/images/docs/container_evolution.svg)

### __Traditional deployment era:__ 
In early ages we have to deploy our application in the physical servers . We can not define the resource boundaries means if two applications are running on a same host there is no way we can divide the resource among each other . As a result the application would underperform .

### __Virtualized deployment era:__ 
As a solution virtualization was introduced . It allows to run multiple virtual machines on top of your host machine . virtual machines allows application to run in a isolated environment so that they can run securely . Virtualization allows better resource management in a physical server which leads our applications to be scalable and loosely coupled . Each VM is a full machine running with it's own kernel with required binaries and libraries .

### __Container deployment era:__ 
Container are similar to VMs but they don't required the kernel to run the application which makes them lightweight . __for example :__ if you want deploy your application in __Linux__ so you have to download the Linux VM Image (1.9 GB) , besides all the configuration needed . we could do that in just 90 MB and we don't have to additionally configure our Machine . But similar to VM container also it's own file system , share CPU, memory , process space and more .  

# __Why we need Kubernetes ?__
Previously we saw that Containers are providing such functionalities and everybody is moving towards containerized applications so we need somebody to manage those containers to ensure that there is no application downtime . 

# __features of Kubernetes :__
* service discovery and load balancing .
* self healing and disaster recovery .
* Automated rollbacks and rollouts .
* Automated scheduling .

* Automated scheduling :
Kubernetes provides advanced scheduler to lunch container on cluster nodes .

* Self Healing Capabilities :
Rescheduling , replacing and restarting the containers which are died .

* Automated rollouts and rollbacks :
This is for the desired state of the containerized application .

* Horizontal scaling and load balancing :
Kubernetes can scale up and scale down the application as per the requirement .   

# __Components of Kubernetes :__

Kubernetes works on a master-slave architecture . Slave nodes holds the containers every cluster must have one worker node . 
 
__Here is a diagram of a k8s cluster with all components tied together :__
![components of Kubernetes](https://d33wubrfki0l68.cloudfront.net/2475489eaf20163ec0f54ddc1d92aa8d4c87c96b/e7c81/images/docs/components-of-kubernetes.svg)

## __Control plane components :__
Control plane holds the control for the worker node and mange containers .
* __API server :__
It exposes the K8s API , by this we can make sure the communication between pod to pod and master to slave .
* __etcd :__ 
It is a highly available key-value store used to store the current state of the cluster and also used as a back up service for k8s .
* __Scheduler :__
This watches for new crated __pods__ with no assigned __nodes__ and assigned a __node__ to run on them .
* __Control Manager :__
Controller Manager is a daemon that embeds controllers. It basically does namespace creation and garbage collection .

* These controllers include :
* __Node Controller__ Manages the status of the nodes(create , update , delete)
* __Replication Controller__ Maintains number of pods for every replication controller object in the system .
* __Service Account And Token Controller__ Create default accounts and API access tokens for the new namespaces .
* __Endpoint Controller__ Takes care of endpoint objects(like pods, join services etc)
   

## __Node Components :__
Node components run on every node and maintain the running pods . 

* __Kubelet :__
It is running in each node and the task to make sure that the containers are running in the pod . 
* __kubeproxy :__
It is a network proxy that runs on each node and mains the network rules .

* __Container runtime :__ 
This is responsible for running the containers .

# How is __Kubernetes__ different from __docker swarm__ :


![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/x0q69a5ghrp8wbp7s4u4.png)

[second part for Kubernetes](https://dev.to/rahulku48837211/deep-dive-into-kubernetes-part-ii-5hka)