Kubernetes Fundamentals
Container Orchestration
-
After packaging applications into containers, the next step is running them in production. This involves managing dependencies on other containers (such as databases or messaging services), scaling up to handle increased user load, and scaling down when demand decreases. To achieve this, you need a platform that orchestrates connectivity between containers and automatically adjusts scaling based on load. This automated process of deploying and managing containers is known as container orchestration.
-
Common Tools:
- Kubernetes
- Docker Swarm
- Mesos
- Hashicorp Nomad
Kubernetes Architecture
-
API Server: The API server acts as the front-end for kubernetes. The users, management devices, Command line interfaces all talk to the API server to interact with the kubernetes cluster. Kubeadm deploys
api-serveras a pod inkube-systemnamespace$ kubectl get pods -A | egrep -i 'namespace|apiserver' NAMESPACE NAME READY STATUS RESTARTS AGE kube-system kube-apiserver-k8s-cp-1 1/1 Running 0 2d6h -
etcd: ETCD is a distributed reliable key-value store used by kubernetes to store all data used to manage the cluster. Think of it this way, when you have multiple nodes and multiple masters in your cluster, etcd stores all that information on all the nodes in the cluster in a distributed manner. ETCD is responsible for implementing locks within the cluster to ensure there are no conflicts between the Masters.
-
Scheduler: The scheduler is responsible for distributing work or containers across multiple nodes. It looks for newly created containers and assigns them to Nodes.
$ kubectl get pods -A | egrep -i 'namespace|scheduler' NAMESPACE NAME READY STATUS RESTARTS AGE kube-system kube-scheduler-k8s-cp-1 1/1 Running 0 2d21h -
Controllers: The controllers are the brain behind orchestration. They are responsible for noticing and responding when nodes, containers or endpoints goes down. The controllers makes decisions to bring up new containers in such cases.There are different controllers , some of the default controllers are listed below
- Node-Controller
- Replication-Controller
- Deployment-Controller
- Namespace-Controller
- Endpoint-Controller
- Job-COntroller
-
Kube Controller Manager: All Kubernetes Controllers are packaged into a single process known as the Kubernetes Controller Manager.
$ kubectl get pods -A | egrep -i 'namespace|controller' NAMESPACE NAME READY STATUS RESTARTS AGE kube-system kube-controller-manager-k8s-cp-1 1/1 Running 0 2d6h -
Container Runtime: The container runtime is the underlying software that is used to run containers.containerd is one of the most common runtimes used in Kubernetes clusters.
-
kubelet: kubelet is the agent that runs on each node in the cluster. The agent is responsible for making sure that the containers are running on the nodes as expected.
-
Container Runtime Interface - CRI :
- The CRI is a plugin interface which enables the kubelet to use a wide variety of container runtimes, without having a need to recompile the cluster components.
- You need a working container runtime on each Node in your cluster, so that the kubelet can launch Pods and their containers.The Container Runtime Interface (CRI) is the main protocol for the communication between the kubelet and Container Runtime.
- The Kubernetes Container Runtime Interface (CRI) defines the main gRPC protocol for the communication between the node components kubelet and container runtime.
crictlis the K8S CRI command line utility that works on all worker nodes irrespective of the container runtimes like containerd,cri-o etc.
