DEV Community

Cover image for Understanding Kubernetes: The Roles of Master and Worker Nodes and Their Relationship
matiar Rahman
matiar Rahman

Posted on

Understanding Kubernetes: The Roles of Master and Worker Nodes and Their Relationship

In a Kubernetes cluster, there are two main types of nodes that form the core of the cluster's architecture: Master Nodes (also called Control Plane nodes) and Worker Nodes. They have distinct roles and responsibilities, but they work together to orchestrate and run containerized applications efficiently. Here's a breakdown of each:

1. Master Node (Control Plane)
The Master Node is responsible for managing and controlling the entire Kubernetes cluster. It handles the scheduling of pods, managing cluster state, and overseeing the health and availability of applications running within the cluster. The Master Node runs several critical components, which form the Control Plane:

Key Components of the Master Node:
API Server:

The API server (kube-apiserver) acts as the front-end for the Kubernetes Control Plane. All administrative tasks are submitted to the API server, which is the central point for communication between users (or automation systems) and the cluster.
It processes REST API calls and directs them to the appropriate components (scheduler, controller manager, etc.).
Controller Manager:

The controller manager (kube-controller-manager) runs several key controllers that handle various tasks in the cluster, such as node management, replication control, and managing endpoints for services. It ensures the desired state of the cluster is maintained.
Scheduler:

The scheduler (kube-scheduler) is responsible for assigning new pods to the appropriate worker nodes. It takes into account resource requirements (CPU, memory), policy constraints, and the current state of the cluster to make scheduling decisions.
etcd:

etcd is a distributed key-value store that Kubernetes uses to store all cluster state and configuration data. This includes information about the nodes, pods, services, secrets, and much more.
etcd ensures that all data is available consistently across the cluster.
Cloud Controller Manager:

This component interacts with the cloud provider (if any) for managing services like load balancers, storage, and networking. It abstracts cloud-specific details from the rest of the Control Plane.
2. Worker Node
The Worker Node is where the actual workloads, in the form of pods (which contain containers), are deployed and run. The Worker Nodes are responsible for running and managing the containerized applications, and they interact with the Master Node to receive instructions.

Each Worker Node runs the following critical components:

Key Components of the Worker Node:
kubelet:

The kubelet is the agent that runs on each Worker Node and communicates with the Master Node. It ensures that the containers (inside pods) are running as expected according to the instructions from the API Server.
It reports the status of the node and the pods back to the Master Node.
kube-proxy:

The kube-proxy is responsible for managing network traffic in and out of the worker nodes. It implements Kubernetes networking rules that allow communication between pods, services, and the outside world. It handles service discovery and load balancing within the cluster.
Container Runtime:

The container runtime is the software responsible for running containers on a node. Kubernetes supports different container runtimes such as Docker, containerd, or CRI-O. The runtime ensures that containers are properly executed and managed on the worker node.

  1. Relationship Between Master Node and Worker Nodes The Master Node and Worker Nodes work in close collaboration to maintain the health, availability, and scalability of applications running in the cluster. Here’s how they interact:

Control Plane (Master Node) controls the cluster: The Master Node schedules applications (in the form of pods) onto Worker Nodes, maintains the desired state of the cluster, and handles changes, such as scaling, upgrading, or failure recovery.

**Worker Nodes execute workloads: **The Worker Nodes are where containers are run. The Master Node instructs the Worker Nodes on what to run and manages how they should behave (e.g., replicas, resource constraints).

API Server communication: Worker Nodes use the kubelet to continuously communicate with the API Server in the Master Node. This ensures that the Master Node is aware of the status of the nodes and the workloads running on them.

Scheduling and orchestration: When new pods need to be created, the scheduler on the Master Node finds the best Worker Node to run them on based on resource availability, affinity rules, and other constraints.

Health monitoring: The Master Node continuously monitors the state of the cluster and can reschedule workloads if a Worker Node becomes unavailable or unhealthy. The Worker Nodes send regular status updates about the state of their pods and the resources they use.

Networking and load balancing: Worker Nodes rely on the network setup (through kube-proxy and other components) to communicate with each other and route traffic between pods, services, and external users. The Master Node controls the network policies and routing behavior across the cluster.

In Summary:
Master Node: Responsible for managing the entire cluster. It makes scheduling decisions, controls the cluster's state, and oversees orchestration.
Worker Node: Executes the application workloads (pods/containers). Each Worker Node reports back to the Master Node and runs the containers as instructed.
Relationship: The Master Node manages and directs the Worker Nodes, while Worker Nodes perform the actual execution of workloads, maintaining the distributed and scalable nature of the cluster.

Top comments (0)