$ skip to content
devresurge

k8s-internals · chapter 9 of 22

08 — kubelet: the node babysitter

Chapters
  1. Kubernetes Internals — From Linux Up (Book Length)
  2. 01 — Linux processes: the real unit of work
  3. 02 — Namespaces: walls, not VMs
  4. 03 — cgroups: budgets, not walls
  5. 04 — Security primitives: least privilege at the kernel
  6. 05 — OCI images: suitcases of files + config
  7. 06 — containerd & CRI: who actually starts containers
  8. 07 — Pods: shared fate, shared network namespace
  9. 08 — kubelet: the node babysitter
  10. 09 — API server & etcd: the desired-state store
  11. 10 — Controllers: reconcile forever
  12. 11 — Scheduler: who goes where
  13. 12 — Networking: Pod IP → Service → world
  14. 13 — Ingress & Gateway: the L7 front door
  15. 14 — Storage: disks that outlive pods
  16. 15 — Cluster security: trust on the API and the wire
  17. 16 — Troubleshoot: debug like an owner
  18. 17 — etcd deep dive: the notebook behind the librarian
  19. 18 — Controllers deep dive: informers, workqueues, and level triggers
  20. 19 — CNI deep dive: plugging Pods into the network
  21. 20 — eBPF dataplane: services and policy in the kernel
  22. 21 — CSI deep dive: attach, mount, and the sidecar circus
08 — kubelet: the node babysitter

ELI5 hook

The kubelet is the babysitter on each machine. The control plane posts a chore chart (“these Pods should run here”). The kubelet checks the crib (CRI runtime) all day: start what’s missing, restart what crashed, report who’s hungry (metrics), and kick out kids if the house is out of milk (eviction).

Mental model

kubelet is the agent that makes local reality match assigned Pod specs.

flowchart TB
  api[API server] -->|"watch Pods bound to this node"| kubelet
  kubelet -->|"CRI"| runtime[containerd]
  kubelet -->|"status updates"| api
  kubelet -->|"probes"| containers[containers]
  kubelet -->|"eviction"| diskmem[node pressure]
LoopPurpose
SyncDesired Pods vs running sandboxes/containers
PLEGPod Lifecycle Event Generator — notice started/stopped
Probesliveness / readiness / startup
StatusReport phase, conditions, pod IP, restarts
EvictionFree node resources under pressure

What Linux + kubelet do

Probes (health checks)

ProbeFailure meaning
startupGive slow apps time before liveness starts
livenessRestart container (process unhealthy)
readinessRemove from Service endpoints (not ready for traffic)

Probes are executed by kubelet (HTTP GET, TCP socket, or exec in the container). Mis-tuned liveness = flapping restarts. Mis-tuned readiness = silent traffic blackhole.

Volume mounts

kubelet attaches/mounts volumes (CSI, emptyDir, configMap, secret) into the container mount namespace before start. Secrets often become tmpfs files.

cgroups

kubelet (with the runtime) places containers into the Pod’s cgroup hierarchy using requests/limits (chapter 03).

How Kubernetes uses it

Pod scheduled → spec.nodeName set → that kubelet owns it.

SymptomFirst suspect
ContainerCreating stuckImage pull, volume mount, CNI, CRI
CrashLoopBackOffProcess exits; check logs + describe
Ready=FalseReadiness probe / dependencies
Node NotReadykubelet down, runtime down, disk pressure, network to API

Static pods (manifests in /etc/kubernetes/manifests) are also kubelet-driven — how control-plane self-hosts on many clusters.

Lab

# Watch kubelet-ish signals via API
kubectl run probe-demo --image=nginx:1.25-alpine
kubectl describe pod probe-demo | sed -n '/Conditions/,/Volumes/p'
kubectl get pod probe-demo -o wide
kubectl delete pod probe-demo

# On a kind node — runtime view
./courses/k8s-internals/labs/08-crictl-inspect.sh

Gotchas

  • Liveness hitting a busy dependency — Restarts make overload worse; use readiness for deps, liveness for deadlocks.
  • Exec probes — Fork cost under load; prefer HTTP where possible.
  • Image GC / eviction — Disk pressure kills Pods and GC’s images; monitor node conditions.
  • Clock skew — Certificates and lease renewals get weird; keep NTP healthy.

Checkpoint

kubelet = node-local reconciler + probe runner + eviction officer.

Next: 09 — API server & etcd.


Quiz arc: after chapters 08–11 → /quizzes/k8s-node-control-plane/