Kubernetes Series (Part 1) : Basics of Kubernetes & Its Architecture
Tags: kubernetes
Published: 2022-07-12 17:55:41

It is a container orchestration which makes many servers act like one. It tuns on top of Docker(Generally) as a set of APIs in containers. It provides API/CLI to manage containers across servers. 



**So, what can we order Kubernetes to do?**

- First we can start 5 containers using image `atseashop/api:v1.3` and Place an internal load balancer in front of these containers

Note: atseashop/api:v1.3 is an image 
- Start 10 containers using image `atseashop/webfront:v1.3`
and place a public load balancer in front of these containers

- During a festival, the usage become higher and you need to add containers. You can do that too

- You have got a new release! Replace your containers with the new image `atseashop/webfront:v1.4`


Other works:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/at7l74r26qlu9rgqqdiq.png)
 

- Kubernetes can do "rolling updates"(New versions of containers are deployed progressively, rather than all the containers at a time).

**Some Terminology to know**

- K8s comes from the Kubernetes name as after "K" we have 8 letter and then a "s"

- Kubectl( Cube control) : CLI to configure Kubernetes and its apps.

- Node: Single server in the Kubernetes cluster.

Check out the official documentation of [nodes](https://kubernetes.io/docs/concepts/architecture/nodes/)

- Kubelet: Kubernetes agent running on nodes. 

- Control plane:set of containers which manage the cluster.


**In a master node, we have:**

APIs (This is how we contact with containers) , scheduler (controls how and where your nodes are placed) ,controller manager (it looks at the current situation and tries to figure our what to do to get your commands done), etcd (Distributed storage system for key values), Core DNS ( to control DNS) etc.

So, this is what a master node might look like

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z9u0xq7u6trcvzfwd9qx.png)
**
In a normal node:**
we have Kubelet ( Kubernetes agent running on nodes), kube proxy ( to control the network) and obviously they will run over Docker

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p98azcitfrb71d8bf3zg.png)
 

So, overall the Control Plane(set of containers which manage the cluster) might look like this

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c9dyzjnad90dby0nzsbu.png)
 
 and the nodes (node 1, node 2,.......)might be like this


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ay4csvp6x09rewhj407a.png)
 




**Distributions**
Distributions like Vanilla and many more are there:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m8qe01zjsrr7f3tlc0l5.png)




![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oghp5qyn5m029bj6ezuw.png)


**Kubernetes architecture**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s7wuvdek6nvvx5aabxxi.png)

 <img src="https://c.tenor.com/Tvd3VKwtse0AAAAC/cat-cute.gif">

Haha! Want to stop learning kubernetes after watching this diagram?
Hold on!


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t9m91r97g1iw1miw5ylb.png)
Look at this one....... not that complex , right?

So, we have the master node which controls the whole cluster. Lets learn about it

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g2x8lfaiy37bcl4a0270.png)
  
- It has etcd ( key value store or, the database which has all the information about your containers and how it should run)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vq4yy35ltd07eznmcq9z.png)
 
- API Servers( through this we contact containers and everything. one of the most important element of master. It also talks to Kubelet which actually controls nodes.)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tz0d56vfpcxeelmckoa5.png)
 
- Scheduler (controls how and where your nodes are placed) 



- Controller manager (it looks at the current situation and tries to figure our what to do to get your commands done)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j39dm5sj7gv8xl8idu1w.png)
 

But a node has Kubelet ( controls the node), Kube proxy ( controls the networking part of the node and provides IP address for the containers within the node).


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c116j5bfy2xxmei3of4z.png)

Container runtime ( anything that manages containers . example: Docker) , Operating system (Linux/ Windows). L[ist of container runtimes](https://kubernetes.io/docs/setup/production-environment/container-runtimes/)

You may also read [this blogs](https://kubernetes.io/blog/2016/12/container-runtime-interface-cri-in-kubernetes/) by Kubernetes about container runtimes
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6zwgfv0ys2lqox6lpp7b.png)
 

Check out the official documentation of the [architecture](https://kubernetes.io/docs/concepts/overview/components/)

**An example of architecture and how they contact ( 1 master & 3 nodes)**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v37cm6jokco0hcing6ee.png)

**More concepts **

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jyk7memha8v62zy1kye6.png)

You might be new to pods . Pods consists of 1 or multiple containers. Container runtimes usually don't know about them..It is managed by Kubernetes. Kubernetes manages pods and then container runtimes manages the containers. Pods also have IP addresses. Thus you can keep multiple containers in a pod and contact with them using the IP address.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vkidc6ksyp3e3yfj7qpk.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2409atmmi2jaqy2snht7.png)
  

Note : There might be several masters on a cluster . 
Cluster ( Combination of master node & nodes). Also a simple node can have this cluster in it......so , things can be way complex. 

We will learn other things in next blog. See you in the next blog

<img src="https://media0.giphy.com/media/Nfs5y1kzJKfu/giphy.gif?cid=ecf05e472d3w835ptrri5m1p6ifnwl9mi7ope9pifvhpcxf6&rid=giphy.gif&ct=g">