session

~/chopper

article

Kubernetes Components

Kubernetes orchestrates a high available cluster of connected computers that acts a single unit. Kubernetes manages distribution, scheduling and scaling of the application containers across the cluster. Kubernetes has two resources, control plane and nodes inside the cluster. Control plane coordinates the cluster by scheduling, scaling, maintaining the cluster’s desired state and rolling out new updates.

Node

A node is a physical or virtual machine that runs application container and serves as a worker inside the cluster. Each node has kubelet which is an agent that manages the node and communicates with the control plane through the APIs that control place exposed. Container runtime (containerd) and CRI-O are mandatory within the node in order to run the application containers. When we want to deploy the application containers, we tell the control place directly or through kubectl, control plane schedules the containers and deploy the applications on suitable nodes.

Etcd Cluster

Etcd is a distributed, reliable key-value store that stores data as key-value pairs. Clients can store, retrieve and watch data using keys through the etcd APIs, clients. In kubernetes, etcd is used to store the states of cluster, nodes and pods. EtcdCTL is a command line tool to interact with Etcd server.

Kube API Server

Kube Api server is a central control component inside the control plane that handles authentication, authorisation, validation and persisting cluster state in the etcd cluster. When we create a pod from kubectl, api server stores the desired state of pod in the etcd server. Kube scheduler watches the unassigned pod using kubernetes watch api and assign the pod onto the appropriate node which means assign the pod state the name of node appropriate for the deployment. Kubelet watches the api server and when it found the pod assignment onto its node, kubelet ensures the pod is running by interacting with the container run time. Then, kubelet responses back to the api server and api server update the state of the pod in the etcd cluster.

Kube Control Manager

kube control manager runs multiple controllers that implements controlled loop to maintain the desired state of the cluster. Controllers watches the resource changes through api server to reconcile the actual state with the desired state. Controllers like node controller tracks node health and handles the node failures while replication controller ensures the specific number of pod replicas are running by creating and deleting pods as needed.

Kube Scheduler

Kube scheduler is responsible for assigning pods onto the suitable node. It first filters the nodes that does not meet with the resource requirement and constraints to run the pods, then scores the remaining nodes to select the suitable one. Finally, it binds the pod onto the node through api server.

Kubelet

Kubelet is a node agent that watches for pods assigned to its node through API server. It interacts with the container runtime to pull the image and create the container through CRI. It also monitors the status of the node and reports back to the API server.

Kubeproxy

Pods across different nodes can communicate with each others. Pods are ephemeral so that kubernetes provides services which provides stable endpoint. A service is an API object that maps to a set of pod endpoints and provides virtual IP. Kubeproxy runs on each node and watches for services and changes of pod endpoints and install iptables or IPVS rules on each node to route the traffic to the appropriate pods.

Deployment

Deployment is an entity in the cluster that is responsible for creating and updating of the applications. When we created a deployment, control plane schedules the application instance inside that deployment to the node to run the instance. After application instance has created, deployment controller monitor the application on the node. If something goes wrong, controller re-schedule the instances onto the different node if the node that hosts the application instance went down.