0
0
KubernetesConceptBeginner · 3 min read

What is Kubelet in Kubernetes: Role and Usage Explained

Kubelet is an agent that runs on each node in a Kubernetes cluster. It ensures containers are running in pods as expected by communicating with the Kubernetes control plane and managing the node's workload.
⚙️

How It Works

Think of kubelet as a helper on each worker machine (node) in a Kubernetes cluster. It listens for instructions from the main Kubernetes brain (the control plane) about which containers to run. Once it gets these instructions, kubelet makes sure those containers are up and running properly on its node.

It regularly checks the health of the containers and reports back to the control plane. If a container crashes or stops, kubelet tries to restart it to keep the application running smoothly. This is similar to a caretaker who watches over machines in a factory, making sure each one is working and fixing problems quickly.

💻

Example

This example shows how kubelet runs on a node and manages pods. The command below checks the status of pods on the node using kubelet's API.

bash
curl -s --unix-socket /var/run/kubelet.sock http://localhost/pods | jq '.items[] | {name: .metadata.name, status: .status.phase}'
Output
{ "name": "nginx", "status": "Running" } { "name": "redis", "status": "Running" }
🎯

When to Use

You don't usually interact with kubelet directly because it runs automatically on every Kubernetes node. However, understanding kubelet is important when you manage or troubleshoot your cluster. For example, if pods are not starting or restarting properly, checking kubelet logs can help find the problem.

It is essential in scenarios where you want to ensure your applications are always running on the nodes, like in production environments or when running critical services that need high availability.

Key Points

  • Kubelet runs on every node and manages pod lifecycle.
  • It communicates with the Kubernetes control plane to get pod specs.
  • It monitors and reports pod and container health.
  • Automatically restarts containers if they fail.
  • Essential for node-level management and troubleshooting.

Key Takeaways

Kubelet is the node agent that ensures containers run as expected in Kubernetes pods.
It communicates with the control plane and manages container lifecycle on each node.
Kubelet monitors container health and restarts them if they fail.
You mainly troubleshoot kubelet when pods have issues starting or running.
It is critical for maintaining application availability on Kubernetes nodes.