Kubernetes is now a buzzword in the cloud world. Everybody is talking about containers and kubernetes. In this article, we will try to get familiar with some of the basic concepts of kubernetes.
This article assumes that you have basic knowledge about docker.
Why Kubernetes ?
Let’s assume that you have an application which has a Web UI layer, an API layer and database. You want to containerize the application using docker. Each of these layer probably would be a container.
Assume that you need to have multiple containers running each of these layers. So you have 5 web front end containers, 5 API containers and 5 database containers.
Now, you do not want end users to get 5 different URLs to access the application. So you would want some load balancer to redirect request to appropriate web front end.
Everytime you restart containers IP address is changed. So you need to reconfigure load balancer or at least nee some mechanism who can take care of this.
Let’s say your application crashed. Now you need to spin new container. Do you want to do it manually ? Certainly not. Then what is the solution ?
There comes Kubernetes.
What is Kubernetes ?
Kubernetes is the orchestrator which manages containers to ensure high availability
Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation.
When you install kubernetes, you actually get a cluster. A cluster here is set of nodes, which can run containerized applications. Some of the nodes are worker nodes which run the application. There is one master node which takes care of managing all the other worker nodes.
Let’s have a look at basic components of the Kubernetes:
A master node is the orchestrator. It takes all the important decision about cluster. It also detects and responds to the cluster events.
Master node has
This is the control plane of kubernetes. The API server exposes the Restful Kubernetes APIs. The API server can also scale and can be load balanced.
It is a highly consistent, highly available, key value store, where kubernetes stores the data.
This component watches all newly created pods which do not have nodes assigned and assigns them the node to run on.
There are number of controllers and logically each one of them is a separate process. But they are bundled in the same process to reduce complexity. There is node controller to handle events when node goes down, replication controller to handle the correct number of replicas and there are other containers too.
Cloud Controller Manager
This piece let kubernetes interact with the cloud provider. These help cloud provider’s code and kubernetes code evolve independently. There are various controllers like route controller, node controller, volume controller, etc.
Worker Node (aka. Node or Minion)
This runs on every node in cluster and responsible for maintaining nodes and providing the kubernetes runtime environment.
Runs on each node of cluster. It ensures that all the pods are running. It only manages those pods which were created by kubernetes.
This is to maintain the networking part of the nodes.
The software that is responsible to run the containers.
Services are abstract way of representing a group of pods on network service. Let’s say you have 5 database replicas on pods. Pods have their own lifecycle, they are created and they die as well. Every time a POD is created it is new, with new IP address. Now, if there are any other pods interacting with these 5 database pods, how are they going to know new IP address ? Here is when services are of use. Services can work as load balancers.
Pod is the atomic component in kubernetes. It is responsible for running containers. Generally a pod runs a container, although you can choose to run multiple containers on a pod. Kubernetes is totally abstracted from container because of pod. Pod has its own life cycle, a pod can be in pending, running, succeeded, failed or unknown status.
Declarative way to specify the desired state of kubernetes cluster. You just specify the desired state in the deployment in form of YAML or JSON. You just declare what is required , but do not specify how to achieve it. The deployment controller takes care of bringing cluster to desired state and makes sure that the desired state is maintained.
There is one important component kubectl, which helps you to interact with the kubernetes. I hope this article covers all the important terms. Please let me know your thoughts.