Kubernetes also known as K8s was built by Google. It is a Container Orchestration tool.
What is Container Orchestration ?
Let us say that we have our application packaged into a Docker Container. How do we run it in Production ? What if the application depends on other containers that run on a different host ? How do you scale up or scale down depending on the load ? How will the container be recovered when there is an issue with the application running inside them or the container itself crashes ?. To enable these functions, you need a tool enable orchestration between different containers. This whole process of automatically deploying & managing hundreds & thousands of containers across multiple hosts is known as container Orchestration ? There are different container Orchestration tools such as Docker Swarm, Mesos & Kubernetes. Out of all these, Kubernetes is the most popular one. Kubernetes is now supported on all the major public cloud providers.
Basic Architecture of Kubernetes & Important Terminology:
Node: Node is a physical or Virtual Machine where Kubernetes is installed. It is also a worker machine where containers are launched. Nodes sometimes are also called as Minions.
Cluster: A cluster is a group of multiple nodes so that even if a node fails, we have redundancy. It also helps in sharing the load.
Master: The master is a node with Kubernetes installed on it & is configured as the master. The watches over the nodes in the cluster and is responsible for the orchestration of the worker nodes.
Components: When you install Kubernetes on a system, it actually contains the below components
- API Server
- etcd service
- Kubelet service
- container runtime
- controllers
- schedulers
API Server: The API Server acts as the front end for Kubernetes, The users, management devices etc.. talk to the API server to interact with the Kubernetes cluster.
etcd: The etcd key store, is a distributed Key-Value store used by Kubernetes to store all the data about the cluster. When you have multiple nodes & multiple masters in a cluster, etcd stores all the information on all the nodes in a distributed manner. etcd is responsible for implementing logs within the cluster to ensure there is no conflicts between the masters.
scheduler: The scheduler is responsible for distributing work or containers across nodes. it looks for newly created containers & assigns them to nodes.
Controller: The controller is like the brain behind the operation. They are responsible for processing & responding when the nodes or containers go down. The controller makes decision whether to bring up new container or not.
Container Runtime: it is the underlying software used to run containers. It can be docker or something else.
kubelet: kubelet is the agent that runs on each node. They are responsible for making sure that the containers are running on the node as expected.
Below are some of the difference between Master & Worker Nodes.
Master Node | Worker Node |
---|---|
The etcd stores all the information as key-value store. | This is where containers are hosted |
The master also holds the controller & Scheduler. | They have the container runtime installed |
They have the Kube API-server installed & that is what makes it a master | The worker Nodes have the kubelet agent that is responsible for providing health information etc to the master node |
Kubectl : The kubectl tool is a command line utility & used to deploy & manage applications on a Kubernetes cluster.
Command | Pupose |
---|---|
kubectl run | This command is used to deploy an application on the cluster |
kubectl cluster-info | This command is used to get information about the cluster |
kubectl get nodes | This command is used to list all the nodes in a cluster. |
kubectl get nodes -o wide | This command give more information about the OS etc.. |
kubectl delete pod {Pod-name} | This command is used to delete a POD. |
kubectl edit {resource-type} {resource-name} | This command is used to edit the Yaml file. when we don’t know the path of Yaml file. |
kubectl get {resource-type} {resource-name } -o yaml | This command will be used to get the yaml output of replicaset or pod |