Kubernetes Master Node
Kubernetes Master Node Overview
The Kubernetes master node, also known as the control plane, is the central control unit that manages the entire Kubernetes cluster. It is responsible for making global decisions about the cluster, such as scheduling, and for detecting and responding to cluster events (e.g., starting up new pods when a deployment's replicas field is unsatisfied). Below are the key components of the Kubernetes master node:
1. API Server (kube-apiserver)
Role:
The API server is the front end of the Kubernetes control plane. It exposes the Kubernetes API, which is the central interface for all interactions with the cluster. All the administrative tasks, such as scaling applications, deploying new applications, and managing cluster resources, are done via API calls to the API server.
Functions:
Handles RESTful calls to the API.
Authenticates and validates API requests.
Serves as the gateway for communication between different components of the control plane and the cluster.
Stores the state of the cluster in etcd.
2. etcd
Role:
etcd is a distributed key-value store that Kubernetes uses to store all its configuration data, state data, and metadata. It is the primary database for Kubernetes and serves as the single source of truth for the entire cluster.
Functions:
Stores the entire cluster state, including the configuration and status of the nodes, pods, deployments, and other resources.
Provides reliable data storage and retrieval, ensuring the consistency of data across the cluster.
Supports cluster leader election and other distributed consensus tasks.
3. Controller Manager (kube-controller-manager)
Role:
The controller manager is a daemon that runs the core control loops, which are known as controllers. Each controller tries to bring the current state of the cluster closer to the desired state by constantly monitoring the cluster and making adjustments as needed.
Functions:
Node Controller: Responsible for noticing and responding when nodes go down.
Replication Controller: Ensures that the correct number of pod replicas are running in the cluster.
Endpoints Controller: Manages the endpoints in the cluster, associating them with services for proper routing of traffic.
Service Account and Token Controllers: Create default accounts and API access tokens for new namespaces.
4. Scheduler (kube-scheduler)
Role:
The scheduler is responsible for assigning pods to nodes in the cluster. It takes into account the resource requirements of the pods, as well as any constraints (e.g., affinity rules, node taints) and available resources on the nodes.
Functions:
Watches for unassigned pods and assigns them to appropriate nodes.
Considers factors such as CPU, memory, network, and storage availability on nodes.
Evaluates the scheduling policies, such as taints, tolerations, and affinities, to ensure that pods are placed on nodes that meet their requirements.
5. Cloud Controller Manager
Role:
The cloud controller manager is responsible for managing cloud-specific controller logic, allowing Kubernetes to interact with the underlying cloud infrastructure. This component is especially useful in environments where Kubernetes is running on a cloud platform like AWS, Azure, or GCP.
Functions:
Node Controller: Checks the cloud provider to determine if a node has been deleted after it stops responding.
Route Controller: Responsible for configuring routes in the cloud provider’s network when using the Kubernetes cluster on a cloud platform.
Service Controller: Manages load balancers in the cloud to expose services externally.
6. Cluster State Store (etcd)
While etcd is a key component of the control plane, it deserves special mention because of its critical role in storing the state of the cluster. The health of the etcd store is vital for the operation of the Kubernetes cluster.
How the Master Node Components Work Together
Control Loop: The controllers managed by the controller manager are constantly monitoring the state of the cluster. For example, if a node fails, the node controller in the controller manager will detect this and attempt to bring the system back to the desired state, often by creating replacement pods on other nodes.
API Server as the Hub: The API server is the central hub of the control plane, interacting with etcd to retrieve the cluster state, interacting with the scheduler to place pods on nodes, and interacting with the controller manager to ensure the cluster is running as expected.
Scheduler Decisions: The scheduler is key in deciding where pods will run based on the resource availability and constraints defined by the user, ensuring efficient utilization of the cluster’s resources.
The master node controls the overall operation of the cluster, ensuring that the desired state (as defined by the user) is maintained across the worker nodes, regardless of failures or changes in the cluster environment. Without the master node, Kubernetes would not be able to manage the cluster autonomously.
Last updated