---
title: "Kubelet and Container Runtimes: How Kubernetes Runs Pods"
description: "How the kubelet runs Pods: the sync loop, CRI, containerd and runc, probes, CrashLoopBackOff and eviction, and how to debug a Pod stuck on its node."
url: "https://opsfolk.com/blog/kubelet-and-container-runtimes-how-kubernetes-runs-pods"
author: "admin"
published: "2026-11-27T20:16:18.084Z"
updated: "2026-12-03T22:30:16.472Z"
category: "Kubernetes"
series: "Kubernetes Internals: How a Cluster Really Works"
series_part: 3
series_parts: 9
series_url: "https://opsfolk.com/blog/series/kubernetes-internals-how-a-cluster-really-works"
reading_minutes: 33
image: "https://media.opsfolk.com/2026/11/99520059d1820f6a3d4b636b-2400x1350.webp"
---

# Kubelet and Container Runtimes: How Kubernetes Runs Pods

The scheduler has done its job. It picked a node, wrote a binding, and the API server set `spec.nodeName: worker-2` on your Pod. Nothing is running yet. No process has started, no image has been pulled, no IP address has been given out. Everything from here happens on `worker-2`, and it is driven by one agent: the **kubelet**.

In the first two parts of *Kubernetes Internals: How a Cluster Really Works*, we followed a request through the API server and watched the scheduler place a Pod. This part follows the Pod onto its node. You will see how the kubelet notices the Pod, how it talks to the container runtime through the CRI, what containerd and runc actually do, and how probes, restarts and evictions work. Then we turn it around: given a Pod stuck in `ContainerCreating`, `ImagePullBackOff` or `CrashLoopBackOff`, how to find the cause on the node.

*New to the series? Start with [Kubernetes API Server Explained: The Life of a Request](https://opsfolk.com/blog/kubernetes-api-server-explained-the-life-of-a-request), then [How the Kubernetes Scheduler Works](https://opsfolk.com/blog/kubernetes-scheduler-explained-why-pods-stay-pending).*

## What Is the Kubelet?

> **Definition:** The kubelet is the agent that runs on every Kubernetes node. It watches the API server for Pods bound to its node, asks the container runtime to create their containers, keeps them running with probes and restarts, and reports the Pods' and the node's status back to the API server.

Three facts frame the rest of this article:

- **It manages containers, but never runs them itself.** The kubelet does not fork processes or unpack images. It calls a **container runtime**, such as containerd or CRI-O, through a gRPC API called the **Container Runtime Interface (CRI)**. The runtime, and a low-level runtime such as runc under it, do the Linux work.
- **It is a reconciler.** For each Pod, the kubelet compares what the spec asks for with what the runtime reports, and acts on the difference: start a missing container, restart a dead one, kill one that should be gone. It does this over and over, not once.
- **It is local.** The kubelet only knows about its own node. When the API server is unreachable, the containers it started keep running, and it keeps restarting the ones that crash. It just cannot learn about new Pods or report what happened until the connection comes back.

The kubelet is not a Pod. It runs as a systemd service on the host (`kubelet.service`), because it is the component that starts Pods in the first place. On most clusters it listens on port 10250 for the API server's calls (logs, exec, port-forward) and authenticates to the API server as `system:node:<node-name>`, an identity the Node authorizer limits to the Pods, Secrets and ConfigMaps of its own node.

### Where the Kubelet Gets Its Pods

The kubelet merges Pods from two sources:

- **The API server.** It watches Pods with a field selector, `spec.nodeName=<its node>`, so it only ever receives its own. This is how almost every Pod arrives: the scheduler's binding from part two lands here as a watch event.
- **Static Pod manifests.** YAML files in a directory on the node, set by `staticPodPath` (`/etc/kubernetes/manifests` on kubeadm clusters), checked every 20 seconds by default. The kubelet runs these without asking anyone. This is how a kubeadm control plane starts: the API server, etcd, the scheduler and the controller manager are static Pods, run by the kubelet before there is any API server to talk to.

For each static Pod, the kubelet creates a **mirror Pod** in the API server, so that `kubectl get pods` shows it. The mirror is read-only: deleting it does nothing, and editing it is refused. To change or remove a static Pod, you change or remove its file on the node.

## How the Kubelet Runs a Pod, at a Glance

**How a bound Pod becomes running containers, step by step:**

1. The kubelet's watch delivers a Pod with `spec.nodeName` set to this node.
2. **Admit:** the kubelet checks it can run the Pod here: resources, node affinity, ports. A Pod that fails is rejected and marked `Failed`.
3. **Cgroups:** it creates the Pod's cgroup, under the one for its QoS class, and sets its limits.
4. **Volumes:** the volume manager attaches and mounts every volume the Pod uses: Secrets, ConfigMaps, `emptyDir`, PersistentVolumes.
5. **Sandbox:** it calls the runtime's `RunPodSandbox`. The runtime creates the Pod's namespaces and its pause container, and calls the CNI plugin, which gives the Pod its IP address.
6. **Init containers:** for each one, in order, it pulls the image if needed, creates and starts the container, and waits for it to exit successfully. Sidecars, init containers with `restartPolicy: Always`, start in this order too but keep running.
7. **App containers:** it pulls their images, creates and starts them.
8. **Probes:** startup, liveness and readiness probes begin. When every container is ready, the Pod's `Ready` condition becomes `True`, and the Pod's IP is added to its Services' EndpointSlices.
9. **Status:** throughout, the kubelet writes the Pod's phase, conditions and container states back to the API server.

![The kubelet admits a Pod, sets its cgroups and mounts volumes, then through the CRI makes its sandbox, runs init containers, pulls images and starts containers; probes make it Ready.](https://media.opsfolk.com/2026/11/c553bda1ce612554fd59f7d3-1344x980.webp)

## The Kubelet's Architecture

The kubelet is a single binary, but it is made of managers that each own one concern. Knowing their names helps when you read its logs.

![The kubelet watches the API server for its Pods and calls containerd or CRI-O over the CRI; the runtime pulls images, calls CNI, and a shim with runc starts the Pod's containers.](https://media.opsfolk.com/2026/11/45d1ce49a24a4605cb5974ac-1344x1320.webp)

- **The sync loop** (`syncLoop`) is the heart. It waits on several channels at once: Pod updates from its sources, lifecycle events from the runtime, probe results, and a timer. Each event names a Pod, and the loop hands that Pod to its worker.
- **Pod workers** give each Pod its own goroutine, so a Pod that is slow to start does not hold up the others. A worker runs `SyncPod`: compute what should be running, compare it with the runtime's state, and make the calls that close the gap. Every Pod is also synced periodically, once a minute by default (`syncFrequency`), even when nothing changed.
- **The PLEG**, the Pod Lifecycle Event Generator, is how the kubelet learns that a container died. By default it **relists**: about once a second, it asks the runtime for every Pod and container on the node, compares the answer with the previous one, and turns each difference into an event (`ContainerStarted`, `ContainerDied`). The **Evented PLEG** gets those events pushed from the runtime over a CRI stream instead. It is beta but still off by default, behind the `EventedPLEG` feature gate.
- **The status manager** writes Pod status to the API server, and only when it changes.
- **The probe manager** runs a worker per probe, per container.
- **The volume manager** attaches, mounts, unmounts and detaches volumes, and holds a container's start until its volumes are ready.
- **The eviction manager** watches memory, disk and PIDs, and evicts Pods when the node runs short.
- **The image manager** and the container garbage collector remove unused images and dead containers.
- **cAdvisor**, built into the kubelet, collects the CPU, memory and filesystem usage of each container. It is what `kubectl top` reads, through the metrics server.

### "PLEG Is Not Healthy"

If a relist does not complete within three minutes, the kubelet considers the PLEG unhealthy and reports the node `NotReady`, with the message `PLEG is not healthy` in its logs and in the node's `Ready` condition. The cause is almost never the kubelet: it is a runtime that answers slowly or not at all, often because of a hung container, a full disk, or a node with too many containers. Check the runtime first (`systemctl status containerd`, `crictl ps`).

## Admission on the Node: The Kubelet Has the Last Word

The scheduler placed the Pod from its own cache, which can be a moment out of date, and some Pods never went through the scheduler at all: static Pods, and Pods with `spec.nodeName` set by hand. So before running a Pod, the kubelet checks it again with its own **admission handlers**:

- **Resources:** do the requests of the Pods on the node plus this one fit in the node's allocatable? If not, the Pod fails with the reason `OutOfcpu`, `OutOfmemory` or `OutOfpods`.
- **Node affinity and selectors:** a Pod pinned with `nodeName` to a node whose labels do not match fails with `NodeAffinity`.
- **Host ports**, the node's OS and architecture, and **taints** with the `NoExecute` effect.
- **Device plugins and resource managers:** a Pod that asks for a GPU the device plugin cannot give, or for exclusive CPUs the CPU manager cannot find, fails with `UnexpectedAdmissionError` or a similar reason.

A Pod rejected here is not retried: its phase becomes `Failed`. A Deployment's ReplicaSet will replace it with a new Pod, which goes back through the scheduler. You will see this mostly when people set `nodeName` by hand, which skips the scheduler's checks and leaves only these ones.

## The Container Runtime Interface (CRI)

The kubelet talks to the runtime through the **Container Runtime Interface**, a gRPC API over a Unix socket. The kubelet is the client; the runtime is the server. The kubelet's `containerRuntimeEndpoint` setting names the socket:

| Runtime | Default socket |
| --- | --- |
| containerd | `unix:///run/containerd/containerd.sock` |
| CRI-O | `unix:///var/run/crio/crio.sock` |
| Docker Engine, through cri-dockerd | `unix:///run/cri-dockerd.sock` |

The CRI has two services:

- **`RuntimeService`** manages sandboxes and containers: `RunPodSandbox`, `StopPodSandbox`, `RemovePodSandbox`, `CreateContainer`, `StartContainer`, `StopContainer`, `RemoveContainer`, `ListContainers`, `ContainerStatus`, `ExecSync`, `Exec`, `Attach`, `PortForward`, and stats.
- **`ImageService`** manages images: `PullImage`, `ListImages`, `ImageStatus`, `RemoveImage`, `ImageFsInfo`.

The calls are deliberately small. The kubelet decides *what* should run: which containers, with which image, command, environment, mounts and resource limits. The runtime decides *how*: where the image layers go on disk, which snapshotter mounts them, which low-level runtime starts the process. That split is what lets Kubernetes run on containerd, CRI-O or anything else that implements the API.

### Talking CRI Yourself: crictl

`crictl` is a command-line client for the CRI, the same API the kubelet uses. On a node, it shows exactly what the runtime has, whatever the API server thinks:

```bash
# Tell crictl where the runtime listens (once, in /etc/crictl.yaml)
cat <<'EOF' | sudo tee /etc/crictl.yaml
runtime-endpoint: unix:///run/containerd/containerd.sock
image-endpoint: unix:///run/containerd/containerd.sock
EOF

sudo crictl pods                     # Pod sandboxes on this node
sudo crictl ps -a                    # containers, including exited ones
sudo crictl images                   # images the runtime has
sudo crictl inspect <container-id>   # full status, exit code, mounts
sudo crictl logs <container-id>      # a container's logs, even if the API server is down
```

`crictl` replaces `docker ps` on a modern node. It sees the containers of every Pod, and of nothing else: containers started by `nerdctl` or `ctr` in another containerd namespace are not listed.

## Container Runtimes: containerd, CRI-O and the OCI Runtimes

"Container runtime" means two different layers, and most confusion about Docker and Kubernetes comes from mixing them up.

- A **high-level runtime** (containerd, CRI-O) implements the CRI. It pulls and stores images, manages snapshots of their layers, sets up the sandbox, calls CNI, and keeps track of every container. It does not create Linux namespaces itself.
- A **low-level runtime**, or **OCI runtime** (runc, crun, gVisor's runsc, Kata Containers), takes a directory with the container's root filesystem and a `config.json` in the OCI runtime format, and starts the process: it creates the namespaces, joins the cgroup, sets capabilities, seccomp and AppArmor or SELinux, pivots to the root filesystem and executes the entrypoint.

| | containerd | CRI-O |
| --- | --- | --- |
| Scope | General container runtime; CRI is a built-in plugin | Built only for Kubernetes and the CRI |
| Used by | Most managed clusters (GKE, EKS, AKS), kubeadm, k3s | OpenShift, many Fedora and RHEL based clusters |
| Default OCI runtime | runc | crun or runc, by distribution |
| Versioning | Its own releases | Follows Kubernetes minor versions |

Both are solid choices. Pick the one your distribution or provider supports; the kubelet does not care.

### What Happened to Docker?

Until Kubernetes 1.24, the kubelet had built-in code, the **dockershim**, that translated CRI calls into Docker Engine API calls, because Docker did not implement the CRI. That code was removed in 1.24. Docker Engine still uses containerd underneath, so most clusters simply switched the kubelet to that containerd directly.

Two things did not change. **Images built with Docker run everywhere**: they are OCI images, and containerd and CRI-O pull them like any other. And if you really need the Docker Engine on a node, Mirantis' **cri-dockerd** is an adapter that implements the CRI in front of it.

### The Shim: Why Containers Survive a Restart

Between containerd and runc sits one small process per Pod: the **shim**, `containerd-shim-runc-v2`. containerd starts the shim, the shim calls runc to create the container, and runc exits once the process is running. The shim stays: it is the container's parent process, it holds its standard input and output, and it collects its exit code.

This design has a practical effect. You can restart the kubelet, or upgrade and restart containerd, and **the containers keep running**: their parent is the shim, not either daemon. When containerd comes back, it reconnects to the shims; when the kubelet comes back, it relists and finds the same containers. Only a reboot, or killing the shim, stops them.

### Images, Layers and Snapshotters

When the kubelet calls `PullImage`, containerd fetches the image's manifest for the node's architecture, downloads every layer it does not have yet, and unpacks them through a **snapshotter**. The default, `overlayfs`, stacks the read-only layers and adds a writable one per container. Layers are shared: ten Pods of the same image use the image's layers once on disk.

containerd keeps the CRI's images in its own namespace, `k8s.io`. That is why `ctr images ls` shows nothing until you add `-n k8s.io`, and why an image loaded with `docker load` on the same machine is not visible to the kubelet.

### RuntimeClass: More Than One OCI Runtime

A node can offer several low-level runtimes, for example runc for ordinary Pods and gVisor or Kata Containers for untrusted code. A **RuntimeClass** gives each one a name the Pod can ask for:

```yaml
apiVersion: node.k8s.io/v1
kind: RuntimeClass
metadata:
  name: gvisor
handler: runsc          # the name configured in containerd or CRI-O
---
apiVersion: v1
kind: Pod
metadata:
  name: untrusted-job
spec:
  runtimeClassName: gvisor
  containers:
  - name: job
    image: registry.example.com/job:1.4
```

The kubelet passes the handler's name in `RunPodSandbox`, and the runtime starts the sandbox with the matching OCI runtime. A Pod that names a handler the node does not have fails to create its sandbox. A RuntimeClass can also carry a `scheduling` section with a node selector and tolerations, so such Pods only go to nodes that have it, and an `overhead`, the extra CPU and memory a VM-based sandbox costs, which the scheduler and the kubelet add to the Pod's requests.

## The Pod Sandbox and the Pause Container

Containers in a Pod share a network namespace: they reach each other on `localhost` and share one IP address. Something has to own that namespace before the first container starts and after the last one exits. That is the **sandbox**.

For runc-based runtimes, the sandbox is a tiny container running the **pause** image (`registry.k8s.io/pause:3.10` in recent runtime configurations). Its process does nothing but sleep and reap zombie processes. The runtime creates the Pod's network, IPC and UTS namespaces with it, and every container of the Pod joins them. A VM-based runtime such as Kata makes the sandbox a lightweight virtual machine instead.

**`RunPodSandbox`, step by step:**

1. The runtime creates the Pod's namespaces and starts the pause container in them.
2. It calls the **CNI** plugin named in `/etc/cni/net.d/` with the command `ADD`, the Pod's name and its network namespace.
3. The plugin (Calico, Cilium, Flannel and others) creates the Pod's interface, gives it an IP address from the node's range, and sets up routes.
4. The runtime returns the sandbox's ID and IP. The kubelet records the IP in the Pod's `status.podIP`.

The IP belongs to the sandbox, not to any container. A container that crashes and restarts keeps the Pod's IP; only a new sandbox, which means a new Pod or a sandbox the runtime had to recreate, gets a new one. When the Pod is deleted, the runtime calls CNI with `DEL` to give the address back.

When this step fails, the Pod stays in `ContainerCreating` with a `FailedCreatePodSandBox` event, and the message usually names the CNI plugin: `failed to setup network for sandbox`, `no IP addresses available in range`. The fix is on the network side, not in the Pod.

Once the sandbox and its network are ready, the kubelet sets the Pod's `PodReadyToStartContainers` condition to `True`.

What the CNI plugin does with that namespace, from the veth pair to the Pod's address, is in [Kubernetes Networking Deep Dive](https://opsfolk.com/blog/kubernetes-networking-cni-overlays-ebpf#cni-the-container-network-interface).

## From Pod to Running: The Startup Sequence

With the sandbox up, the kubelet starts the containers, one kind at a time.

### Pulling Images

For each container, just before starting it, the kubelet asks the image manager to make sure its image is there. Whether it pulls depends on `imagePullPolicy`:

| `imagePullPolicy` | The kubelet pulls… | Default when… |
| --- | --- | --- |
| `IfNotPresent` | only if the node does not have the image | the tag is anything but `latest` |
| `Always` | every time, though unchanged layers are not downloaded again | the tag is `latest` or there is no tag |
| `Never` | never: the image must already be on the node | never the default |

Two defaults surprise people. First, the kubelet pulls **one image at a time** (`serializeImagePulls: true`), so a large image for one Pod can make the others on the node wait. Setting it to `false` allows parallel pulls, optionally capped by `maxParallelImagePulls`. Second, the image is pulled when its container is about to start, not when the Pod arrives: an app container's image is only pulled once the init containers have finished.

A failed pull shows up as `ErrImagePull`. The kubelet then retries with an exponential back-off, starting at 10 seconds and capped at five minutes, and while it waits the container's reason is `ImagePullBackOff`.

### Init Containers, Sidecars and App Containers

- **Init containers** run one at a time, in the order they are listed. Each must exit with code 0 before the next starts. One that fails is restarted, with back-off, unless the Pod's `restartPolicy` is `Never`, in which case the whole Pod fails. Until they are all done, the Pod's status shows `Init:0/2`, `Init:1/2`, and the `Initialized` condition is `False`.
- **Sidecar containers** are init containers with `restartPolicy: Always`, stable since Kubernetes 1.33. They start in their place in the init order, but the kubelet does not wait for them to exit: it waits for them to *start*, or to pass their startup probe if they have one, and moves on. They keep running beside the app containers, are restarted if they crash, and are stopped after the app containers when the Pod terminates. This is the right way to run a log shipper or a service-mesh proxy that must be up before the app.
- **App containers** start next. The kubelet creates and starts them one after another without waiting for any to be ready; they start in the order listed, but in practice at about the same time. A `postStart` hook runs right after a container starts, and the container is not marked `Running` until it returns.

Each start is two CRI calls: `CreateContainer`, which gives the runtime the full container config (image, command, environment, mounts, security context, resource limits as cgroup settings) and returns an ID, then `StartContainer`. When both succeed, the container's state is `Running` and the Pod's phase becomes `Running` too. **Running is not Ready**: readiness comes from the probes.

The canvas below plays a Pod's start on a node. Switch off the image cache or add an init container, and see how each changes the moment the Pod is Running, and the later moment it is Ready.

**A Pod starting on a node.** One Pod's first 25 seconds on its node, a row per step: admission and volumes, the sandbox and its IP, the init container's image and run, the app's image, then the app. Illustrative times: pulls of 3 s and 5 s, an init container of 2 s, and an app that listens 2 s after it starts; the readiness probe runs every 10 s. By default the Pod is Running at 11.8 s but Ready only at 21.8 s: the first probe came too early and failed. A 2 s delay makes it Ready at 13.8 s; cached images make it Running at 3.8 s. The controls set the cache, the init container and the delay.

The times in it are illustrative, but the order is the kubelet's. With the defaults, the Pod is Running at 11.8 seconds and Ready only at 21.8: the readiness probe ran the moment the container started, before the app was listening, and the next try came a full period later. An `initialDelaySeconds` of 2 makes it Ready at 13.8. Notice also that the app's image is pulled only after the init container has finished, so an init container does not warm the cache for the app. With both images already on the node, the same Pod is Running at 3.8 seconds.

## Resources and cgroups

Requests helped the scheduler choose a node. On the node, **limits** become real: the kubelet turns them into **cgroup** settings, and the Linux kernel enforces them.

### The cgroup Hierarchy

The kubelet puts every Pod in a cgroup under `kubepods`, grouped by the Pod's **QoS class**:

| QoS class | When | cgroup (systemd driver) |
| --- | --- | --- |
| **Guaranteed** | Every container has CPU and memory limits equal to its requests | `kubepods.slice/kubepods-pod<uid>.slice` |
| **Burstable** | At least one request or limit, but not Guaranteed | `kubepods.slice/kubepods-burstable.slice/…` |
| **BestEffort** | No requests or limits at all | `kubepods.slice/kubepods-besteffort.slice/…` |

Each container gets its own cgroup inside its Pod's. The CPU request becomes a CPU **weight** (`cpu.weight` on cgroup v2): under contention, the kernel shares CPU in proportion to requests. The CPU limit becomes a **quota** (`cpu.max`): a container that uses its quota within a 100 ms period is **throttled** until the next one, even if the node's CPUs are idle. The memory limit becomes `memory.max`: a container that goes over it is killed by the kernel's OOM killer.

That last one is the most common crash on a node. The container's last state shows it:

```text
    Last State:     Terminated
      Reason:       OOMKilled
      Exit Code:    137
```

Exit code 137 is 128 + 9: the process was killed by `SIGKILL`. `OOMKilled` means the kernel did it because the container went over its memory limit. The fix is a higher limit, or less memory used; restarting the Pod only delays the next kill.

### cgroup v2 and the cgroup Driver

Kubernetes is moving to **cgroup v2**. cgroup v1 support is deprecated since 1.35, and the kubelet now refuses to start on a cgroup v1 host unless `failCgroupV1: false` is set. Any distribution from the last few years uses v2 by default; check with `stat -fc %T /sys/fs/cgroup/`, which prints `cgroup2fs` on v2.

The kubelet and the runtime must also agree on a **cgroup driver**: `cgroupfs` writes to the cgroup filesystem directly, and `systemd` asks systemd to create slices. On a host that boots with systemd, use `systemd` for both: two managers of the same cgroup tree end in instability under pressure. The kubelet's own default is `cgroupfs`, but kubeadm writes `cgroupDriver: systemd` into its configuration, and CRI-O uses `systemd` by default. Recent kubelets can ask the runtime which driver it uses, through the CRI's `RuntimeConfig` call; containerd 2.x answers it, containerd 1.x does not, so with containerd 1.x the two settings must still match by hand.

### Reserved Resources and Allocatable

Not all of a node is for Pods. The kubelet subtracts what you reserve for the operating system (`systemReserved`) and for Kubernetes' own daemons (`kubeReserved`), and the hard eviction threshold, from the node's capacity. What remains is **allocatable**, the number the scheduler compared requests with in part two. Managed clusters set these reservations for you, as a function of the node's size.

## Probes and Restarts

The kubelet does not only start containers; it keeps checking them. It has three kinds of **probes**, each with a different consequence:

| Probe | Question | When it fails | Until it succeeds |
| --- | --- | --- | --- |
| **Startup** | Has the app finished starting? | The container is killed and restarted | Liveness and readiness probes do not run |
| **Liveness** | Is the app still working? | The container is killed and restarted | (runs for the container's whole life) |
| **Readiness** | Can the app take traffic now? | The Pod is marked not Ready and removed from its Services' endpoints | The Pod is not Ready |

Each probe uses one of four mechanisms: an HTTP `GET` (any code from 200 to 399 is a success), a TCP connect, a gRPC health check, or a command run inside the container (`exec`). The kubelet itself makes the HTTP, TCP and gRPC checks, by connecting to the Pod's IP from the node. An `exec` probe is different: the kubelet asks the runtime to run the command in the container with the CRI's `ExecSync`, which costs a new process every time.

The timing comes from five fields, with these defaults:

| Field | Default | Meaning |
| --- | --- | --- |
| `initialDelaySeconds` | 0 | Wait before the first probe |
| `periodSeconds` | 10 | Time between probes |
| `timeoutSeconds` | 1 | A probe slower than this counts as a failure |
| `failureThreshold` | 3 | Failures in a row before the probe is considered failed |
| `successThreshold` | 1 | Successes in a row to pass again (must be 1 for liveness and startup) |

So with the defaults, a container whose app hangs is killed 20 to 30 seconds later: three failed probes, ten seconds apart, the first of them up to a period after the hang began. Readiness reacts on the same clock, and does not wait for a restart: as soon as the readiness probe fails three times, the EndpointSlice controller takes the Pod out of its Services' EndpointSlices, and traffic stops reaching it.

### Restart Policy and CrashLoopBackOff

When a container exits, or is killed by its liveness probe, the kubelet looks at the Pod's `restartPolicy`: `Always` (the default, and the only choice for a Deployment), `OnFailure` (restart only on a non-zero exit code, typical for Jobs) or `Never`.

It does not restart a crashing container in a tight loop. It waits, and the wait grows: **10 seconds after the first exit, then 20, 40, 80, 160, and at most 300 seconds**. While the kubelet waits, the container's reason is `CrashLoopBackOff`. The back-off is reset once a container has run for 10 minutes without a problem.

`CrashLoopBackOff` is therefore not an error of its own. It is the kubelet saying: *this container keeps exiting, and I am waiting before I try again*. The real error is in the container's last exit, which `kubectl describe pod` shows under `Last State`, and in its logs from before the restart, which `kubectl logs --previous` shows.

The five-minute cap can now be tuned per node. Since Kubernetes 1.35 the `KubeletCrashLoopBackOffMax` feature is beta and on by default, and the kubelet configuration's `crashLoopBackOff.maxContainerRestartPeriod` sets the cap anywhere from 1 to 300 seconds. A separate alpha gate, `ReduceDefaultCrashLoopBackOffDecay`, off by default, starts the back-off at 1 second and caps it at 60 for the whole cluster.

The canvas below runs ten minutes of a container whose app hangs 30 seconds after each start. Its liveness and readiness probes share the same period and threshold. Watch when it leaves the Service's endpoints, when it is restarted, and how the back-off between restarts grows.

**Probes and CrashLoopBackOff.** Ten minutes of a container whose app hangs 30 s after each start. Its liveness and readiness probes share a period and a failure threshold. Rows: the container (working, hung, or in back-off), its probes, and whether the Pod is Ready. With a probe every 10 s and 3 failures, the hang is noticed after 20 s: the Pod leaves the endpoints and restarts at that moment, then waits 10, 20, 40, 80 and 160 s, for 5 restarts. A 60 s cap gives 6. A probe every second notices in 2 s; 10 failures at 10 s leave a hung Pod in the endpoints for 90 s. The controls set all three.

With the defaults, the hang goes unnoticed for 20 seconds, and the Pod stays in its Service's endpoints all that time, taking requests it cannot answer. Then it is restarted, and the kubelet waits 10, 20, 40, 80 and 160 seconds before the next starts: five restarts in ten minutes. A shorter period notices sooner at the cost of more probes, and a higher threshold forgives a slow moment but leaves a broken Pod serving for longer: at 10 failures of 10 seconds, 90 seconds. A cap of 60 seconds gives a sixth restart in the same ten minutes.

## Node Status, Heartbeats and Leases

The kubelet also reports on the node itself, in two ways:

- **The Node's status.** Its conditions (`Ready`, `MemoryPressure`, `DiskPressure`, `PIDPressure`), its capacity and allocatable, its addresses and the images it has. The kubelet checks every 10 seconds (`nodeStatusUpdateFrequency`), but writes the status only when something changed, or every 5 minutes otherwise.
- **A Lease**, in the `kube-node-lease` namespace, with the node's name. The kubelet renews it every 10 seconds. It is a small object, cheap to write, and it is the real heartbeat: on a cluster of thousands of nodes, writing full Node objects every few seconds would load etcd for nothing.

The **node lifecycle controller**, in the kube-controller-manager, watches both. If a node's Lease has not been renewed for 50 seconds (`--node-monitor-grace-period`), it sets the node's `Ready` condition to `Unknown` and adds the taints you met in part two: `node.kubernetes.io/unreachable` with `NoSchedule` and `NoExecute`. The scheduler stops placing Pods there, and after five minutes by default, Pods that do not tolerate the `NoExecute` taint for longer are evicted, and their controllers create replacements elsewhere.

That five-minute wait is a toleration: every Pod gets `tolerationSeconds: 300` for `not-ready` and `unreachable` added by admission, unless it sets its own. A stateless service that must move faster can lower it.

## Node-Pressure Eviction and Image Garbage Collection

A node can run out of memory or disk while every Pod stays inside its limits: limits can add up to more than the node has, and BestEffort Pods have none. The kubelet's **eviction manager** watches the node's resources every 10 seconds and, when one crosses a threshold, evicts Pods to get it back.

The default **hard eviction thresholds** on Linux:

| Signal | Evict when |
| --- | --- |
| `memory.available` | less than `100Mi` |
| `nodefs.available` | less than 10% (the filesystem with `/var/lib/kubelet`, logs and `emptyDir`) |
| `imagefs.available` | less than 15% (the filesystem with the runtime's images and container layers) |
| `nodefs.inodesFree` | less than 5% |
| `imagefs.inodesFree` | less than 5% |

When a threshold is crossed, the kubelet sets the matching node condition (`MemoryPressure`, `DiskPressure`), which taints the node so that no new Pods arrive. For disk, it first tries to reclaim space without evicting anyone: it deletes dead containers and unused images. Then it evicts Pods, choosing first those that use more of the starved resource than they requested, then by priority, then by how far over their request they are. BestEffort Pods, which requested nothing, are therefore the first to go, and Guaranteed Pods within their requests the last. An evicted Pod has the phase `Failed` and the reason `Evicted`, and its controller replaces it, usually on another node.

A **hard** threshold evicts at once, with no grace period. A **soft** threshold (`evictionSoft`, none by default) must be crossed for a while (`evictionSoftGracePeriod`) and lets the Pod terminate gracefully. Node-pressure eviction is not the same as the kernel's OOM killer: eviction is the kubelet acting before the node runs out, and the OOM killer is what happens when it did not act in time.

**Image garbage collection** runs before it comes to that. When the image filesystem is more than 85% full (`imageGCHighThresholdPercent`), the kubelet deletes unused images, oldest used first, until it is under 80% (`imageGCLowThresholdPercent`). An image is only deleted when no container uses it and it has been unused for at least two minutes (`imageMinimumGCAge`).

## Stopping a Pod

Deleting a Pod in the API server does not stop it at once. It sets the Pod's `deletionTimestamp`, and the kubelet, which sees the change in its watch, does the stopping:

1. The Pod is marked `Terminating`; the EndpointSlice controller marks its endpoints as terminating and no longer ready, so Services stop sending it new connections.
2. The kubelet runs each container's `preStop` hook, if it has one.
3. It asks the runtime to stop each container, which sends `SIGTERM` to its main process.
4. It waits for the containers to exit, up to `terminationGracePeriodSeconds`, **30 seconds by default**, counted from the start of the `preStop` hook.
5. Any container still running then gets `SIGKILL`.
6. The kubelet stops the sandbox, which calls CNI `DEL`, unmounts the volumes, and tells the API server the Pod is gone, which removes the object.

Two well-known problems come from this order. Endpoint removal and `SIGTERM` happen at about the same time, so a process that exits at once on `SIGTERM` can still receive a few requests from proxies that have not seen the update: a short `sleep` in a `preStop` hook is the usual fix. And a process that ignores `SIGTERM`, often because it runs as a child of a shell that does not forward signals, always waits out the full grace period before being killed.

A Pod stuck in `Terminating` for a long time usually has a **finalizer** that nothing removes, or is on a node whose kubelet is gone, so that no one reports it stopped. `kubectl delete pod --grace-period=0 --force` removes the object from the API server without waiting for the kubelet; use it only when you are sure the node, and the containers on it, are really gone.

**Graceful node shutdown** extends this to the node itself: when the node is shut down, the kubelet delays it through a systemd inhibitor lock and terminates its Pods first, normal Pods before critical ones. It is beta and enabled by default, but does nothing until you set `shutdownGracePeriod` and `shutdownGracePeriodCriticalPods`, both 0 by default.

## Why Pods Get Stuck on the Node

When `kubectl get pods` shows a Pod with a node but not running, the `STATUS` column shows a container's waiting or terminated reason. Each points to a different step of the startup sequence:

| Status | Step that failed | Where to look | Common fixes |
| --- | --- | --- | --- |
| `ContainerCreating` (for minutes) | Volumes or sandbox | Events: `FailedMount`, `FailedAttachVolume`, `FailedCreatePodSandBox` | A missing Secret or ConfigMap, a volume still attached to another node, a broken CNI plugin |
| `ErrImagePull`, `ImagePullBackOff` | Image pull | Events: `Failed to pull image` and the registry's answer | A typo in the name or tag, a private registry without `imagePullSecrets`, a rate limit, no route to the registry |
| `InvalidImageName` | Image pull | The image field | A malformed reference, such as an uppercase letter or a stray space |
| `CreateContainerConfigError` | Container config | Events | A Secret or ConfigMap, or one of its keys, that an environment variable names but does not exist |
| `CreateContainerError`, `RunContainerError` | `CreateContainer` or `StartContainer` | Events, `crictl inspect` | A command that does not exist in the image, a bad mount, a security context the node refuses |
| `Init:CrashLoopBackOff` | An init container | `kubectl logs <pod> -c <init-container>` | The init step itself fails: a migration, a wait for a dependency |
| `CrashLoopBackOff` | The app, after start | `kubectl logs --previous`, `Last State` | Read the exit code and the logs: a config error, a missing dependency, a failing liveness probe |
| `OOMKilled` | The app, at its memory limit | `Last State: Terminated, Reason: OOMKilled` | A higher memory limit, or a fix for the memory use |
| `Running` but not `Ready` | Readiness | Events: `Readiness probe failed` | The probe's path, port or timeout, or an app that is not ready yet |
| `Terminating` (for minutes) | Stopping | `metadata.finalizers`, the node's status | A stuck finalizer, or a node that is gone |

![A Pod stuck in ContainerCreating waits on volumes or its sandbox; an image error is the name, tag or credentials; CrashLoopBackOff's last state says OOMKilled, liveness or another exit.](https://media.opsfolk.com/2026/11/52d94ebdb3196d0bb749a1b5-1344x1024.webp)

## Debugging on the Node, Step by Step

**1. What does the API server know?**

```bash
kubectl get pod web-0 -o wide
kubectl describe pod web-0
```

Read the `Events` at the end, then each container's `State` and `Last State`. Most problems are named here.

**2. What did the container say before it died?**

```bash
kubectl logs web-0 --previous
kubectl logs web-0 -c init-db        # an init container's logs
```

`--previous` reads the logs of the last terminated instance of the container. Without it, a container in `CrashLoopBackOff` often shows nothing: its new instance has not started yet.

**3. What does the kubelet say?** On the node:

```bash
journalctl -u kubelet --since "15 min ago" | grep web-0
```

The kubelet logs each sync, each failed call to the runtime, and each probe failure, with the Pod's name.

**4. What does the runtime have?** Still on the node:

```bash
sudo crictl pods --name web-0
sudo crictl ps -a --pod <pod-id>
sudo crictl inspect <container-id> | grep -E '"exitCode"|"reason"|"message"'
sudo crictl logs <container-id>
journalctl -u containerd --since "15 min ago"
```

If `crictl` shows a container the API server does not, or the reverse, the kubelet and the runtime disagree: the kubelet's logs say why.

**5. What is the kubelet configured to do?** Without logging into the node:

```bash
kubectl get --raw "/api/v1/nodes/worker-2/proxy/configz" | jq .kubeletconfig
```

This shows the configuration the kubelet is really running with, defaults included: eviction thresholds, cgroup driver, `maxPods`, image GC settings.

### Kubelet Metrics

The kubelet exposes Prometheus metrics on its port 10250, at `/metrics`, and the per-container usage from cAdvisor at `/metrics/cadvisor`. A few are worth a dashboard:

- `kubelet_pod_start_duration_seconds`: how long Pods take from the kubelet seeing them to running.
- `kubelet_pleg_relist_duration_seconds`: how long a relist takes. Rising values come before `PLEG is not healthy`.
- `kubelet_runtime_operations_errors_total`: failed CRI calls, by operation.
- `kubelet_evictions`: Pods evicted, by eviction signal.
- `container_cpu_cfs_throttled_periods_total` (cAdvisor): periods in which a container was throttled by its CPU limit.

```bash
kubectl get --raw "/api/v1/nodes/worker-2/proxy/metrics" | grep kubelet_pleg_relist_duration
```

## Configuring the Kubelet

The kubelet reads a `KubeletConfiguration` file, passed with `--config` (`/var/lib/kubelet/config.yaml` on kubeadm clusters). Most of what this article described is set there:

```yaml
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
containerRuntimeEndpoint: unix:///run/containerd/containerd.sock
cgroupDriver: systemd
staticPodPath: /etc/kubernetes/manifests
maxPods: 110
serializeImagePulls: false
maxParallelImagePulls: 3
systemReserved:
  cpu: 500m
  memory: 1Gi
kubeReserved:
  cpu: 500m
  memory: 1Gi
evictionHard:
  memory.available: 500Mi
  nodefs.available: 10%
  imagefs.available: 15%
imageGCHighThresholdPercent: 85
imageGCLowThresholdPercent: 80
shutdownGracePeriod: 60s
shutdownGracePeriodCriticalPods: 20s
```

A change needs a restart of the kubelet: `systemctl restart kubelet`. Its containers keep running through the restart, thanks to the shim. Mind one trap when you set `evictionHard`: once you set any threshold, the ones you leave out are no longer the defaults, so list all of them. On managed clusters, the provider owns this file; change it through the node pool's settings rather than on the node, or your change is lost when the node is replaced.

## Key Takeaways

- The kubelet runs on every node, watches the Pods bound to it, and reconciles each one: it never runs containers itself, but asks a container runtime through the CRI.
- A bound Pod goes through admission on the node, cgroups, volumes, a sandbox with its network from CNI, image pulls, init containers and sidecars, then app containers and probes.
- containerd and CRI-O are high-level runtimes that implement the CRI; runc and other OCI runtimes create the Linux processes. A shim per Pod keeps containers running when the kubelet or containerd restarts.
- The Pod's IP belongs to its sandbox, the pause container, so a restarted container keeps it.
- Limits become cgroups: going over the memory limit is `OOMKilled` with exit code 137; going over the CPU limit is throttling.
- Liveness failures restart a container, readiness failures take the Pod out of its Services. Restarts wait 10 s, doubling to 5 minutes: that wait is `CrashLoopBackOff`.
- The kubelet renews a Lease every 10 seconds; after 50 seconds without one, the node is `Unknown`, and its Pods are evicted 5 minutes later.
- On a stuck Pod, read events and `Last State`, then `kubectl logs --previous`, then `journalctl -u kubelet` and `crictl` on the node.

## FAQ

### What does the kubelet do in Kubernetes?

It is the agent on each node that runs Pods. It receives the Pods the scheduler bound to its node, asks the container runtime to create their sandboxes and containers, mounts their volumes, runs their probes, restarts containers that fail, evicts Pods when the node runs short of memory or disk, and reports the status of the Pods and the node to the API server.

### What is the difference between the kubelet and kube-proxy?

Both run on every node, but they do different jobs. The kubelet manages Pods and their containers. kube-proxy manages Service networking: it programs iptables, IPVS or nftables rules so that traffic to a Service's IP reaches one of its Pods. Some CNI plugins, such as Cilium, replace kube-proxy entirely; nothing replaces the kubelet.

### What is a container runtime in Kubernetes?

It is the software that actually runs containers on a node. The kubelet talks to a high-level runtime, containerd or CRI-O, through the Container Runtime Interface. That runtime pulls images and manages containers, and calls a low-level OCI runtime, usually runc, to create each container's Linux namespaces and cgroups and start its process.

### Does Kubernetes still support Docker?

Kubernetes removed the dockershim, its built-in adapter for Docker Engine, in version 1.24, so the kubelet no longer talks to Docker Engine directly. Images built with Docker still run on every cluster, because they are standard OCI images. To keep Docker Engine on a node, you can install cri-dockerd, an adapter that implements the CRI in front of it.

### What is the pause container?

It is the first container of every Pod on runc-based runtimes, running the tiny `pause` image. It holds the Pod's network, IPC and UTS namespaces, which the Pod's other containers join, so they can share one IP address and talk over `localhost`. Its process just sleeps until the Pod is deleted.

### What does CrashLoopBackOff mean?

It means a container keeps exiting and the kubelet is waiting before it restarts it again. The wait doubles after each exit, from 10 seconds up to 5 minutes. To find the cause, look at the container's `Last State` in `kubectl describe pod` and its logs from before the restart with `kubectl logs --previous`.

### What is the Container Runtime Interface (CRI)?

It is the gRPC API between the kubelet and the container runtime, served on a Unix socket. It has a runtime service, to create and manage Pod sandboxes and containers, and an image service, to pull and list images. Any runtime that implements it, such as containerd or CRI-O, can run Kubernetes Pods, and `crictl` is a command-line client for it.

## What's Next

You have followed a Pod from its binding to running containers, and seen how the kubelet keeps them alive and reports on them. The Pod is now Ready, and its IP is in its Services' EndpointSlices, but no client should use that IP: the next rollout replaces the Pod, and its replacement gets another address. In the next part of *Kubernetes Internals: How a Cluster Really Works*, [Kubernetes Services, DNS and Ingress Explained](https://opsfolk.com/blog/kubernetes-services-dns-and-ingress-explained), we follow a request to that Pod: how a Service gives it a stable address, how kube-proxy and CoreDNS turn that address and a name into a Pod, and how Ingress and the Gateway API bring traffic in from outside the cluster.
