What is the Kubernetes Master Node?
The Kubernetes Master Node, also known as the Control Plane, is the brain of your Kubernetes cluster. It's responsible for maintaining the desired state of your cluster, managing workloads, and responding to cluster events.
The master node consists of several key components that work together to manage the cluster. In production environments, these components are often distributed across multiple machines for high availability.
Master Node Components
kube-apiserver
The kube-apiserver is the front-end for the Kubernetes control plane and the only component that directly interacts with etcd.
- Provides a REST interface for all operations
- Saves and retrieves cluster state from the datastore (etcd)
- All clients (users, nodes, controllers) interact with the cluster through the API server
- Validates and processes API requests
etcd
etcd is a consistent and highly-available key-value store used as Kubernetes' backing store for all cluster data.
- Acts as the cluster datastore for storing state
- Distributed key-value store
- Not a database for applications to use directly
- The single source of truth for the cluster
kube-scheduler
The kube-scheduler is responsible for placing pods onto nodes based on resource requirements and constraints.
- Watches for newly created pods with no assigned node
- Selects an optimal node for each pod to run on
- Considers factors like:
- Individual and collective resource requirements
- Hardware/software/policy constraints
- Affinity and anti-affinity specifications
- Data locality
kube-controller-manager
The kube-controller-manager runs controller processes that regulate the state of the cluster.
- Often called "the controller of controllers"
- Runs various controllers including:
- Node controller
- Replication controller
- Endpoints controller
- Service account & Token controllers
- Each controller is a separate process but compiled into a single binary
cloud-controller-manager
The cloud-controller-manager lets you link your cluster into your cloud provider's API.
- Interacts with the cloud provider's controllers
- Node controller: checks if nodes have been deleted in the cloud
- Route controller: sets up routes in the underlying cloud infrastructure
- Service controller: manages cloud provider load balancers
- Volume controller: orchestrates cloud storage volumes
Addons
Addons are pods and services that implement cluster features beyond the core components.
- DNS: provides DNS services to the cluster
- Web UI (Dashboard): web-based user interface
- Cluster-level logging: saves container logs to a central store
- Container resource monitoring: records metrics about containers
How Master Node Components Work Together
When you deploy an application to Kubernetes, here's what happens:
- You send a request to the kube-apiserver (e.g., to create a pod)
- The kube-apiserver validates the request and stores the information in etcd
- The kube-scheduler notices there's a pod with no assigned node and selects an appropriate node
- The kube-controller-manager ensures the desired state is maintained
- If running in a cloud environment, the cloud-controller-manager handles cloud-specific resources
This coordinated effort ensures your applications run reliably and can scale as needed.