Kubernetes components made easy! - Part 1
Tags: docker, kubernetes, beginners, devops
Published: 2021-08-26 17:44:54

Kubernetes is an open-source container-orchestration system for automating computer application deployment, scaling, and management. This blog will help you know better about the main components of a Kubernetes Cluster.
Starting from the very basic unit of a Kubernetes Cluster:

<u>**Pod:**</u>
- smallest unit of a Kubernetes cluster 
- usually preferred to contain only a single container
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/whpc0pne1l7rqjdo1pn6.jpg)

<u>**Node:**</u>
- unit greater than pod
- consists of group of pods 

<u>**Cluster:**</u>
- Collection of Nodes

<u>**IP addresses**:</u> 
Let us suppose you have an application that connects to a Database. Now Both of these components your *application* and *Database* are pods. Both these pods make use of IP addresses to connect to each other for managing the application.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/260av070qghfek26hav3.jpg)
Now what if the IP address of one of the pods changes due to some reason like the container in the Pod could not get enough space allocation for it to work or simply any problem occurred and now the container is destroyed and along with it, it's IP address also gets lost which is used by your application to connect to the DB(Database). 
Now you create a new container and hence you need a new IP address and you now have to again change the configuration for managing IP addresses and much more. 

This costs a lot of time and effort due to this problem the concept of <u>**Services**</u> was introduced which replaces IP addresses or we can say it provides a permanent IP address which won't change even if your container gets destroyed. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k7uwpl9f176irad8apa0.jpg)

Your application is now working fine and you want to access your application on your system and for this you need to get it on local host and the *service* would provide the IP address somewhat like:
`https://124.89.101.2:8080` which u don't prefer to see in place of:
`https://my-app.com`
Here comes the role of <u>**Ingress**</u> which basically converts your not so good looking IP address to some preferred IP address which then forwards this IP address to services which is then used for communication between different dependent pods.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w6l9a5ne4s5qdtvgmhqq.jpg)

Now suppose your dependent pod URL that is the service URL which is used to interact with other pods changes or you change it due to any good reason then you will need to change it in all files, configuration files and many more to avoid any difficulties in the future. But this can be really tedious task to do, so this task is done by **Config-Map** which basically stores the URL of services that are used and are dependent and in this you can simply change the URL anytime without any stress of modifying all the files.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/91smss003ppgtmcrz5py.JPG)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/htbdrubuuwuq5ywswlwo.JPG)

Now there can be some confidential data as well that you don't want others to see, that data is stored in <u>**Secrets**</u> like user_id, user_password and much more confidential data. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j0b1rzwuii65e65x126p.JPG)

<u>**Deployments**</u>
Deployment for creating replicas is usually called a blueprint of pods and in actual we deal with deployments only and not actual pods. We connect multiple deployments through services which acts as a load balancer & when one pod/deployment/replica dies it(service) forwards the request of the user to another blueprint/deployment.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5v8e90jtald21ww078u5.JPG)

Now we can not create deployments for databases & that is because every Database has some state and and if we create deployments of Databases then we need to keep track of every pod like which pod is currently reading data from data storage and which one is writing data to that storage and all this mechanism needs to be synchronized, maintained among every replica to avoid data inconsistency which is not an easy task so here **StatefulSets** are used.

<u>**StatefulSets**</u> is used for creating replicas, working or 
managing applications like Databases to avoid data inconsistency.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fox5ryi7vdjifwmhe9c9.JPG)

Referred resources:
- [Docker & Kubernetes Tutorial series](https://youtu.be/Krpb44XR0bk)
- [Kubernetes Official website](https://kubernetes.io/)
- [Kubernetes GitHub](https://github.com/kubernetes/kubernetes)
- Images referred from [here](https://youtu.be/Krpb44XR0bk)

If you have come this far then I really appreciate your efforts and I hope you got a little idea about the main components of a Kubernetes cluster. Thanks for reading and have a great day! :)