- 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
- Node (Master and Worker Nodes)
- API Server
- Scheduler
- etcd
- Controller Manager
- Container Runtime
- 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.
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:
Component | Control Plane (Master Node) | Worker Node | Description |
---|---|---|---|
API Server | ✓ | Exposes the Kubernetes API, handling cluster requests and communication with other components. | |
Scheduler | ✓ | Allocates unassigned pods to nodes based on resource needs and policy constraints. | |
etcd | ✓ | Stores all cluster data, including state, configuration, and metadata; critical for data consistency. | |
Controller Manager | ✓ | Maintains the desired state of the cluster (e.g., pod replicas, node health) by managing controllers. | |
Kubelet | ✓ | Node agent that ensures containers are running as specified on each worker node. | |
Container Runtime | ✓ | Manages container lifecycles on worker nodes (e.g., Docker, containerd, CRI-O). | |
Network Proxy | ✓ | Manages 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.
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.
Detailed Overview of Kubernetes Components
-
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. -
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. -
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. -
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. -
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. -
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. -
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.