In this lesson, you will learn how the Kubelet acts as the primary local agent on each worker node to transform desired pod specifications into running containers.
The Heart of the Worker Node
If the Control Plane is the brain of your Kubernetes cluster, the Kubelet is the diligent worker on the ground. Every worker node in your cluster runs a Kubelet process. Its primary job is to ensure that the containers described in your PodSpec are actually running and healthy.
When the Scheduler assigns a Pod to a specific node, the Kubelet on that node receives the manifest. It doesn't just "start" the container and walk away; it actively manages the lifecycle of that workload.
How the Kubelet Maintains Reality
The Kubelet performs its job through a constant control loop:
- Syncing: It watches the
API Serverfor new Pod assignments. - Execution: It interacts with the container runtime (like
containerdorCRI-O) to pull images, create containers, and start them. - Monitoring: It keeps a constant eye on the status of these containers. If a container crashes or exits, the
Kubeletnotices the deviation from the desired state and attempts to restart it according to the Pod'srestartPolicy. - Health Probes: It executes
livenessandreadinessprobes. If a service becomes unresponsive, theKubeletwill kill and restart the container to restore health.
Think of the Kubelet as a meticulous supervisor:
# A typical Pod manifest that the Kubelet monitors
apiVersion: v1
kind: Pod
metadata:
name: web-server
spec:
containers:
- name: nginx
image: nginx:latest
livenessProbe:
httpGet:
path: /
port: 80
In this example, the Kubelet doesn't just start the Nginx container once. It continuously sends requests to port 80. If the web server stops responding to those requests, the Kubelet recognizes the failure and restarts the container to keep your application online without manual intervention. It effectively bridges the gap between the high-level instructions from the Control Plane and the actual container execution on your host.
Key Takeaway: The Kubelet is the local agent responsible for watching the desired state defined in your Pod specifications and continuously reconciling that state by managing the container runtime on its specific worker node.