2 min read

Understanding Containers and Kubernetes Architecture


  1. Docker containers share the kernel of the host: Docker containers run on a shared kernel but provide process and filesystem isolation. Each container has its own isolated filesystem, process space, and network stack while sharing the host machine's kernel.
  2. Image is a package or template used to create containers: Docker images are like templates that contain everything needed to run a container, including the application code, runtime, libraries, and environment variables.
  3. Containers are instances created from images, and they run in isolation with their own environment and set of processes.

Container Orchestration

The process of automatically deployment, scaling and managing containers in a clustered environment is known as container orchestration.

K8, docker swarm and mesos are container orchestration technology.

Kubernetes Architecture

Kubernetes clusters consist of three main components: nodes, the master, and the control plane.

Nodes are the worker machines where containers are launched by K8. They can be physical or virtual and provide the computing resources for running containerized applications.

Cluster is a group of nodes that work together. It provides high availability and load sharing for applications. If one node fails, other nodes can continue to serve the application.

Master node is the brain of the Kubernetes cluster. It manages the overall state of the cluster, handles API requests, and orchestrates the deployment of containers on worker nodes.

graph TD; subgraph Cluster; subgraph "Master Node" [Master Node]; M[Master] end subgraph "Worker Nodes" [Worker Nodes]; A1[Node 1] -->|Pods| S1[Pod 1] A2[Node 2] -->|Pods| S2[Pod 2] A3[Node 3] -->|Pods| S3[Pod 3] end end

Key Components of Kubernetes

Kubernetes relies on several key components to function efficiently:

Kube-apiserver serves as the front end for the Kubernetes control plane, and it is responsible for handling API requests from users, management devices, and CLIs.

etcd is a distributed key-value store used to store all configuration data used to manage the cluster. It helps maintain the cluster's desired state and ensures consistency.

Schedulers are responsible for distributing container workloads across worker nodes based on resource availability and constraints. They also look for newly created containers and assign them to nodes.

Controllers are the brain behind orchestration, they are responsible for noticing and responding when nodes, containers or endpoints go down. They make decisions to bring up new containers in such cases.

Container runtime is the underlying software that is used to run containers. While Docker is a popular choice, Kubernetes supports other container runtimes as well.

Kubelet is an agent that runs on each worker node in the cluster, they are responsible for making sure that containers are running on the nodes as expected.

graph TD; subgraph "Cluster"; subgraph "Master Node"; API[Kube-apiserver] -->|K8s API| etcd[etcd]; API -->|K8s API| Schedulers[Schedulers]; API -->|K8s API| Controllers[Controllers]; end subgraph "Worker Node"; Node1[Node 1] -->|Container Runtime| ContainerRuntime[Container Runtime]; Node2[Node 2] -->|Container Runtime| ContainerRuntime[Container Runtime]; Node3[Node 3] -->|Container Runtime| ContainerRuntime[Container Runtime]; ContainerRuntime -->|Kubelet| Kubelet[Kubelet]; end end

Kubelet agents are responsible for interacting with the master to provide health information of the worker nodes and carry out actions requested by the master on the worker nodes.

What are PODs?

Deploy apps in the form of containers in the worker nodes. K8 does not deploy apps directly in the worker nodes. The containers are encapsulated in a K8 object known as the pod. A pod is an instance of the application, it is the smallest object we can create in K8.