Published on

⚙️ Kubernetes Architecture Explained

Kubernetes (K8s) architecture consists of several essential components that operate across either a single node or multiple nodes in a cluster setup. Here’s a breakdown of these components:

Key Kubernetes Components

  1. Node (Master and Worker Nodes)
  2. API Server
  3. Scheduler
  4. etcd
  5. Controller Manager
  6. Container Runtime
  7. Kubelet

Single-Node vs. Multi-Node Setup

When setting up Kubernetes, you can choose between a single-node setup (using tools like Minikube, K3s, or MicroK8s) or a multi-node cluster:

  • Single-Node: These setups are lightweight, ideal for development or testing, and allow quick experimentation with Kubernetes commands. However, single-node configurations don’t provide the scalability, high availability, and resilience required for production environments.

  • Multi-Node Cluster: In production, a multi-node cluster distributes components across several nodes to improve redundancy, avoid single points of failure, and enable flexible resource allocation. This setup is essential for large-scale deployments and high availability.

Image

Placement of Components in a Multi-Node Cluster

In a multi-node Kubernetes setup, components are typically separated between Control Plane (Master) nodes and * Worker* nodes as follows:

ComponentControl Plane (Master Node)Worker NodeDescription
API ServerExposes the Kubernetes API, handling cluster requests and communication with other components.
SchedulerAllocates unassigned pods to nodes based on resource needs and policy constraints.
etcdStores all cluster data, including state, configuration, and metadata; critical for data consistency.
Controller ManagerMaintains the desired state of the cluster (e.g., pod replicas, node health) by managing controllers.
KubeletNode agent that ensures containers are running as specified on each worker node.
Container RuntimeManages container lifecycles on worker nodes (e.g., Docker, containerd, CRI-O).
Network ProxyManages network communication for containers within and between nodes.

The Control Plane (Master Node) manages the cluster state, schedules resources, and coordinates components. Worker Nodes execute application workloads, managing containers with Kubelet and the container runtime.

 How Kubernetes Control Plane Manages Cluster Interactions?

In Kubernetes, actors (such as administrators, developers, or automated tools) interact with the cluster through the Control Plane, specifically via the API Server. The API Server acts as the central access point to the Kubernetes control plane, allowing actors to send requests and commands to the cluster.

Once a request is received, the Control Plane processes it and, if it requires action on a specific node, communicates with the Kubelet—an agent running on each worker node. The Kubelet then carries out the instructions, such as deploying or managing containers, ensuring the desired state of applications on that node.

In essence:

  • Actors interact with the cluster through the API Server.
  • The API Server coordinates requests and, when necessary, directs Kubelet agents on individual nodes to execute actions.
Image

Detailed Overview of Kubernetes Components

  1. Node (Master and Worker Nodes)
    Nodes are the underlying physical or virtual machines where Kubernetes runs. The Master node (Control Plane) manages the cluster, while Worker nodes handle the deployment and management of application workloads. Scaling nodes in a multi-node setup improves availability, scalability, and resilience.

  2. API Server
    Acting as the front end of the Kubernetes control plane, the API server exposes the Kubernetes API and serves as the gateway for cluster communications. It authenticates and validates requests from administrators, developers, and other Kubernetes components, enforcing security and ensuring smooth interactions across the cluster.

  3. Scheduler
    The Scheduler allocates unassigned pods to nodes based on resource requirements, policy constraints, and cluster health. By optimizing resource allocation, the Scheduler ensures balanced workloads and efficient use of cluster resources.

  4. etcd
    etcd is a distributed key-value store that provides persistent storage for cluster data, including configuration, state, and metadata. It’s crucial for data consistency and reliability in multi-node setups, as it maintains cluster state across nodes and is designed for high availability and fault tolerance.

  5. Controller Manager
    The Controller Manager oversees various Kubernetes controllers, each responsible for managing different resources. For example, the Replication Controller ensures a specified number of pod replicas, while the Node Controller monitors node health. By maintaining the cluster’s desired state, the Controller Manager keeps it stable and responsive.

  6. Container Runtime
    This software runs containers on each node. Kubernetes supports various container runtimes, including Docker, containerd, and CRI-O. The runtime pulls images from registries, runs containers, and manages their lifecycle, ensuring applications run smoothly on the underlying infrastructure.

  7. Kubelet
    Running on each worker node, the Kubelet is an agent that communicates with the API server to manage pod and container lifecycles. It monitors container health, executes workload specifications, performs health checks, and provides status updates to the control plane, ensuring proper management of applications on each node.