Simplest explanation architecture of k8s.
What is Kubernetes/k8s?
- Open source container orchestrator tool by google used to multi environment and multi container deployment.
Why do we use k8s?
For production ready deployment of Mircro-services and small apps.
Having less failure and Downtimes.
Backups and restores.
Kubernetes Architecture :
let's understand each component of the k8s clusters.
We will start with the master node aka the control plane.
kube API-server:
- It is used to authenticate users, validate requests, retrieve data, update ETCD, communicate with other components of cluster.
ETCD:
it's kind of database in master node which carries the informations of nodes.
key value data stores.
ETCD ctl is cli tool used for interacting with ETCD server.
Scheduler:
The kube-scheduler uses a set of rules to determine which nodes in the cluster are best suited to run each pod.
The kube-scheduler continuously monitors the cluster and reschedules pods if necessary. For example, if a node becomes unavailable, the scheduler will look for another suitable node to run the pod on.
Controller-manager:
the kube-controller-manager is the brain of the Kubernetes cluster. It monitors the state of various resources and makes decisions to keep the desired state of the cluster.
It runs on the control plane nodes of the Kubernetes cluster.
It runs as a set of processes, each responsible for a different set of controllers, such as the node controller, the replication controller, and the endpoint controller.
It communicates with the API server to retrieve the current state of the resources and to apply changes to the desired state.
Now let's talk about Worker Node of the k8s cluster.
kubelet:
- kubelet is the "brain" of each node in the Kubernetes cluster, making sure that the right containers are running on each node.
kube-proxy:
Kube-proxy is a network proxy that runs on each worker node in a Kubernetes cluster. Its main purpose is to handle the network traffic between services within the cluster.
Kube-proxy maintains a network routing table that maps service IP addresses to their corresponding endpoint IP addresses. It then uses this table to forward incoming traffic to the appropriate endpoint.
There are several modes of operation for kube-proxy, including userspace, iptables, and IPVS. The most commonly used mode is iptables, which uses the Linux kernel's built-in firewall to perform the network routing.
Some other important terminologies :
CNI (Container Networking Interface):
- CNI is the plumbing that allows containers running in Kubernetes to talk to each other and the outside world. It ensures that each container has a unique IP address and can communicate with other containers and services, even if they are running on different nodes in the cluster.
CNI plugins include:
Bridge: creates a virtual bridge in the host network namespace and connects the container's network interface to it.
Calico: provides network policy and security features for Kubernetes clusters.
Flannel: provides a simple overlay network for container communication across nodes in a cluster.
Weave Net: creates a virtual network that allows containers to communicate across hosts and across different cloud providers.
CRI (Container Runtime Interface):
- Kubernetes uses CRI to create, start, stop, and manage containers within a cluster. CRI provides a standardized way for Kubernetes to communicate with different container runtimes, making it easier to switch between runtimes or use multiple runtimes within the same cluster.