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
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
| Symptom | Layer | Where to look |
|---|---|---|
| Stuck in ContainerCreating, event says failed to create pod sandbox | Sandbox or CNI | kubectl describe pod events, CNI plugin Pods and logs, crictl pods |
| Stuck in ContainerCreating after the sandbox exists | Image or mounts | crictl images, events for pull or volume errors |
| Container exits right after start | The app or its config | crictl ps -a, crictl logs <id>, kubectl logs --previous |
| Node NotReady, kubelet logs PLEG is not healthy | Runtime is slow or stuck | crictl info, systemctl status containerd, journalctl -u containerd |
| Node NotReady, container runtime is down | Runtime stopped | systemctl restart containerd, then check the kubelet |
| kubectl logs and exec fail on one node only | kubelet or runtime on that node | systemctl 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
Further reading: Container Runtime Interface · Debugging nodes with crictl · Container runtimes · How a Pod Starts · Node NotReady and component failures (CKA)