Skip to main content

Chapter 2.6 - kubelet

Learning Objectives

By the end of this chapter, you will be able to:

  • Understand the role of kubelet
  • Explain how kubelet manages Pods
  • Understand health checks
  • Identify interactions with the Container Runtime

What is kubelet?

kubelet is the agent that runs on every Worker Node. It is responsible for:

  • Managing Pods on its node
  • Communicating with the API Server
  • Starting/stopping containers
  • Performing health checks

Roles of kubelet

1. Pod Management

kubelet monitors Pods assigned to its node:

2. Communication with API Server

kubelet:

  • Receives Pod specifications
  • Reports Pod status
  • Sends metrics and events

3. Health Checks

kubelet performs three types of probes:

  • Liveness Probe: Is the container alive?
  • Readiness Probe: Is the container ready?
  • Startup Probe: Has the container started?

Pod Lifecycle


Health Checks (Probes)

Liveness Probe

Determines if the container should be restarted:

livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 30
periodSeconds: 10

If the probe fails -> kubelet restarts the container.

Readiness Probe

Determines if the container is ready to receive traffic:

readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 5

If the probe fails -> the Pod is removed from Services.

Startup Probe

For applications that are slow to start:

startupProbe:
httpGet:
path: /startup
port: 8080
failureThreshold: 30
periodSeconds: 10

Interaction with Container Runtime

kubelet communicates with the Container Runtime via CRI (Container Runtime Interface):

Operations:

  • CreateContainer()
  • StartContainer()
  • StopContainer()
  • RemoveContainer()

Metrics and Events

kubelet collects and sends:

  • Metrics: CPU, memory, disk, network
  • Events: Creation, start, stop, errors
  • Status: State of Pods and containers

Security

kubelet:

  • Authenticates with the API Server (certificates)
  • Validates images before running them
  • Applies security policies (Pod Security Standards)

Useful Commands

# View kubelet logs (on the node)
journalctl -u kubelet

# View Pods on a specific node
kubectl get pods --field-selector spec.nodeName=<node-name>

# View events for a Pod
kubectl describe pod <pod-name>

Summary

In this chapter, you learned:

kubelet: Agent that manages Pods on each Worker Node
Management: Creation, start, stop of containers
Health Checks: Liveness, Readiness, Startup probes
Communication: With API Server and Container Runtime
Monitoring: Continuous metrics and events


Next Steps

Now that you understand kubelet:

Chapter 2.7: kube-proxy - Networking
Chapter 2.8: Container Runtime


Chapter created: December 2024