Skip to main content
Kubernetes internalsLesson 8 of 12

Inside the Node: kubelet, CRI and containerd

The scheduler has bound a Pod to node-1. Now everything happens on that node: the kubelet talks to the container runtime over a gRPC socket, the runtime asks runc to start a process, and the kubelet keeps checking what is really running.

CRI call—
Pod statusPending
Node ReadyTrue
Worker node · node-1API serverPod bound to node-1Adminssh · crictlkubeletsync loopPLEGrelists containerscontainerdCRI gRPC serverCNI pluginPod networkcontainerd-shimrunc-v2 · per Podpausesandbox · netnswebapp containerRegistryimagePod web
RequestResponse / reportWatchAppears in a later step

What you will learn

  • The kubelet only speaks CRI, a gRPC API on a local socket
  • RunPodSandbox, the pause container and CNI
  • Shims and runc: who is the parent of your process
  • How PLEG turns runtime state into Pod status
  • Why Pods keep running when containerd dies

Which layer to look at​

SymptomLayerWhere to look
Stuck in ContainerCreating, event says failed to create pod sandboxSandbox or CNIkubectl describe pod events, CNI plugin Pods and logs, crictl pods
Stuck in ContainerCreating after the sandbox existsImage or mountscrictl images, events for pull or volume errors
Container exits right after startThe app or its configcrictl ps -a, crictl logs <id>, kubectl logs --previous
Node NotReady, kubelet logs PLEG is not healthyRuntime is slow or stuckcrictl info, systemctl status containerd, journalctl -u containerd
Node NotReady, container runtime is downRuntime stoppedsystemctl restart containerd, then check the kubelet
kubectl logs and exec fail on one node onlykubelet or runtime on that nodesystemctl status kubelet containerd

The process tree on a node looks like containerd-shim-runc-v2 → pause and your app processes, not containerd → app.

Try it yourself​

kubectl get pod web -o wide # Which node, which IP
kubectl get pod web -o jsonpath='{.status.containerStatuses[0].containerID}{"\n"}' # containerd://<id>

# On that node
sudo crictl info | head -40 # RuntimeReady and NetworkReady conditions
sudo crictl pods --name web # The sandbox (pause) for this Pod
sudo crictl ps -a --pod <pod-id> # Containers in that sandbox, including exited ones
sudo crictl inspect <container-id> | grep -m1 '"pid"' # Host PID of the app process
sudo crictl logs --tail 20 <container-id> # Same log file kubectl logs reads
ps -ef | grep [c]ontainerd-shim # One shim per Pod, parent of the processes
sudo journalctl -u kubelet --since -10m | grep -i pleg # PLEG health messages

Check yourself

  1. containerd crashes on a node. What happens to the Pods already running there?
  2. Why does an app container keep the same Pod IP after it restarts?
  3. The kubelet logs PLEG is not healthy and the node turns NotReady. What is the most likely cause?

Further reading: Container Runtime Interface · Debugging nodes with crictl · Container runtimes · How a Pod Starts · Node NotReady and component failures (CKA)