Operate and shipLesson 6 of 10
- Metrics, logs, events and traces, not reconciled
- Horizontal pod autoscaling, not reconciled
- Right-sizing and in-place resize, not reconciled
- A troubleshooting method, not reconciled
- kubectl debug and ephemeral containers, not reconciled
- Debugging from the node: crictl, journalctl and nsenter, not reconciled
- Upgrades and version skew, not reconciled
- etcd, backup and disaster recovery, not reconciled
- GitOps with Argo CD, not reconciled
- Progressive delivery, not reconciled
Debugging from the node: crictl, journalctl and nsenter
When a kubelet stops reporting, kubectl shows the last status it sent and cannot reach the node for logs. The node still has the kubelet's journal, the runtime's containers and their logs, and every pod's namespaces.
Shows the lesson one block at a time. Arrow keys step, number keys jump to a scene, and Escape returns to the page where you were.
Reconcile, in 7 scenes
When kubectl stops helping
Everything kubectl shows about a node comes from its kubelet: the node’s conditions, each pod’s status, and every log line, exec session and port-forward, which the API server gets by calling the kubelet on port 10250. When the kubelet stops, the control plane keeps the last status it posted and can reach nothing on the machine.
This lesson’s cluster runs two Deployments on kx-worker2: invoicer, a build that panics on start and sits in CrashLoopBackOff, and payments, which serves. Stop that node’s kubelet:
docker exec kx-worker2 systemctl stop kubelet
kubectl wait --for=condition=Ready=Unknown node/kx-worker2 --timeout=120s
node/kx-worker2 condition met
kubectl get nodes
NAME STATUS ROLES AGE VERSION kx-control-plane Ready control-plane 2m25s v1.37.0 kx-worker Ready <none> 2m20s v1.37.0 kx-worker2 NotReady <none> 2m20s v1.37.0 kx-worker3 Ready <none> 2m20s v1.37.0
kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES invoicer-7849c7cc5d-nshlv 0/1 CrashLoopBackOff 3 (76s ago) 115s 10.244.2.2 kx-worker2 <none> <none> payments-98b6d55cb-5t86m 0/1 Running 0 115s 10.244.2.3 kx-worker2 <none> <none>
kubectl logs deploy/invoicer --previous
Error from server: Get "https://172.18.0.4:10250/containerLogs/default/invoicer-7849c7cc5d-nshlv/invoicer?previous=true": dial tcp 172.18.0.4:10250: connect: connection refused
The node turned NotReady once 50 seconds passed with no Lease renewal or status update from the kubelet, the kube-controller-manager’s default --node-monitor-grace-period. The pod rows are frozen at the kubelet’s last report: invoicer’s restart count stops climbing and its “ago” keeps growing. payments reads 0/1 because the node lifecycle controller marks every pod on an unreachable node not ready, so Services stop sending it traffic, whether or not the process still answers.
kubectl logs, exec, port-forward and debug all end at the kubelet, so they fail with connection refused. The rest of this lesson works from a shell on the machine that does not depend on the kubelet: SSH, a cloud provider’s serial console or session manager, or on kind, docker exec into the node’s container.
The kubelet’s unit and journal
On a systemd host the kubelet is kubelet.service. kind’s unit sets Restart=always with RestartSec=1s, so a kubelet that crashes is back a second later, and one that keeps failing on start shows activating (auto-restart) in systemctl status with a climbing restart counter. inactive (dead) means it was stopped and nothing started it again. Its log is the unit’s journal:
docker exec kx-worker2 systemctl stop kubelet
docker exec kx-worker2 journalctl -u kubelet -n 6
Nov 19 09:01:30 kx-worker2 kubelet[240]: I1119 09:01:30.734254 240 server.go:302] "Shutting down pods API server" Nov 19 09:01:30 kx-worker2 kubelet[240]: I1119 09:01:30.554766 240 volume_manager.go:341] "Shutting down Kubelet Volume Manager" Nov 19 09:01:30 kx-worker2 kubelet[240]: I1119 09:01:30.262825 240 tlsconfig.go:258] "Shutting down DynamicServingCertificateController" Nov 19 09:01:30 kx-worker2 systemd[1]: kubelet.service: Deactivated successfully. Nov 19 09:01:30 kx-worker2 systemd[1]: Stopped kubelet.service - kubelet: The Kubernetes Node Agent. Nov 19 09:01:30 kx-worker2 systemd[1]: kubelet.service: Consumed 1.440s CPU time, 37.6M memory peak.
docker exec kx-worker2 sh -c 'journalctl -u kubelet | grep " E1"'
Nov 19 09:01:10 kx-worker2 kubelet[240]: E1119 09:01:10.103376 240 pod_workers.go:1338] "Error syncing pod, skipping" err="failed to \"StartContainer\" for \"invoicer\" with CrashLoopBackOff: \"back-off 40s restarting failed container=invoicer pod=invoicer-7849c7cc5d-nshlv_default(2b6265ec-b5e3-4bd9-9e59-4120b8675024)\"" pod="default/invoicer-7849c7cc5d-nshlv" podUID="2b6265ec-b5e3-4bd9-9e59-4120b8675024"
Each kubelet line carries a klog header: a severity letter (I, W, E or F), the month and day, the time, the process ID, and the source file and line that logged it. The kubelet runs at logging.verbosity: 0 from /var/lib/kubelet/config.yaml. At that level the journal holds every error and the major lifecycle steps, such as the Error syncing pod line for invoicer’s back-off. A failed probe logs at verbosity 1 and the SyncLoop lines for each pod it adds or updates at 2, so neither appears; the probe failure is still recorded as an Unhealthy event on the pod. To see more, raise the verbosity in the config file and restart the unit, and lower it again afterwards, because verbosity 4 and above writes several lines per pod per sync.
When the kubelet will not start at all, the last lines before Stopped or Failed name the cause: a config file that does not parse, an expired client certificate, a container runtime socket that does not answer. Check containerd with systemctl status containerd before blaming the kubelet.
The runtime’s view
The kubelet is a client of the container runtime. It asks containerd, through the CRI socket /run/containerd/containerd.sock, to create pod sandboxes and containers, and containerd runs them. crictl is a CRI client for people, using the same socket, so it works with the kubelet stopped:
docker exec kx-worker2 systemctl stop kubelet
docker exec kx-worker2 crictl pods
POD ID CREATED STATE NAME NAMESPACE ATTEMPT RUNTIME e52abc1a90450 59 seconds ago Ready invoicer-7849c7cc5d-nshlv default 0 (default) f569e11eec60e 59 seconds ago Ready payments-98b6d55cb-5t86m default 0 (default) 38c46675dfe5c About a minute ago Ready kindnet-ctm5s kube-system 0 (default) db7ffc4e33c91 About a minute ago Ready kube-proxy-vcmn6 kube-system 0 (default)
docker exec kx-worker2 crictl ps -a
CONTAINER IMAGE CREATED STATE NAME ATTEMPT POD ID POD NAMESPACE 975e1688b91cb 8b5324dd71ade 22 seconds ago Exited invoicer 3 e52abc1a90450 invoicer-7849c7cc5d-nshlv default b9ee3d09cba9e 2e6dba323dd4a 53 seconds ago Running payments 0 f569e11eec60e payments-98b6d55cb-5t86m default 7331dddd718a4 54a067e90e058 About a minute ago Running kindnet-cni 0 38c46675dfe5c kindnet-ctm5s kube-system b758919ad1fcc d2d1dea1152ae About a minute ago Running kube-proxy 0 db7ffc4e33c91 kube-proxy-vcmn6 kube-system
docker exec kx-worker2 sh -c 'crictl logs $(crictl ps -a -q --name invoicer)'
{"time":"2026-11-19T09:01:08.516Z","level":"INFO","msg":"starting web","version":"1.2.0","pid":1}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x6b2f3a]
goroutine 1 [running]:
main.(*Config).listenAddr(...)
/src/cmd/web/config.go:42
main.main()
/src/cmd/web/main.go:27 +0x3acrictl pods lists pod sandboxes, one per pod, each with the pause process that holds the pod’s namespaces. crictl ps -a lists containers, exited ones included. ATTEMPT is the restart count the kubelet assigned when it created the container, the number kubectl shows as RESTARTS. The kubelet keeps the most recent dead container of each, so invoicer’s last attempt is still listed, Exited, and nothing will start another: restarting is the kubelet’s decision, and containerd only runs what it is asked to.
crictl logs asks containerd for the container’s log path, then reads the file itself, from /var/log/pods/<namespace>_<pod>_<uid>/<container>/<attempt>.log. --previous reads the file of the attempt before. That is the same file kubectl logs would have streamed through the kubelet.
Two copies of one pod
The kubelet’s absence does not stop the control plane. Every pod carries a toleration for the node.kubernetes.io/unreachable taint with tolerationSeconds: 300, and when it runs out the pods are evicted and their controllers replace them on healthy nodes, as the nodes and kubelet lesson describes. Follow payments through it from both sides:
docker exec kx-worker2 systemctl stop kubelet
kubectl wait --for=condition=Ready=Unknown node/kx-worker2 --timeout=120s
node/kx-worker2 condition met
kubectl wait --for=condition=Available deployment/payments --timeout=400s
deployment.apps/payments condition met
kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES invoicer-7849c7cc5d-4h44f 0/1 Error 1 (2s ago) 6s 10.244.3.2 kx-worker3 <none> <none> invoicer-7849c7cc5d-nshlv 0/1 Terminating 3 (6m22s ago) 7m1s 10.244.2.2 kx-worker2 <none> <none> payments-98b6d55cb-5t86m 0/1 Terminating 0 7m1s 10.244.2.3 kx-worker2 <none> <none> payments-98b6d55cb-xvrrt 1/1 Running 0 6s 10.244.3.3 kx-worker3 <none> <none>
docker exec kx-worker2 crictl ps --name payments
CONTAINER IMAGE CREATED STATE NAME ATTEMPT POD ID POD NAMESPACE b9ee3d09cba9e 2e6dba323dd4a 6 minutes ago Running payments 0 f569e11eec60e payments-98b6d55cb-5t86m default
The API shows the evicted pod Terminating and its replacement Running on kx-worker3. The node shows the evicted pod’s container still running, because deleting a pod only sets its deletion timestamp, and stopping the container is the kubelet’s job. Two copies of payments now run. Only the new one gets Service traffic, but anything the old one does on its own, such as writing to shared storage, consuming from a queue or holding a lease, it keeps doing.
Entering a pod from the node
A pod’s isolation is a set of Linux namespaces, and any process in the pod is a handle on them. nsenter -t <pid> -n joins the network namespace of process <pid> and runs a program there; -m adds the mount namespace, -p the PID namespace and -u the UTS namespace. The program is the node’s own, so ip, ss or tcpdump work against a pod whose image has none of them:
docker exec kx-worker2 systemctl stop kubelet
docker exec kx-worker2 pidof web
668
docker exec kx-worker2 sh -c 'nsenter -t $(pidof -s web) -n ip -br addr'
lo UNKNOWN 127.0.0.1/8 ::1/128 tunl0@NONE DOWN gre0@NONE DOWN gretap0@NONE DOWN erspan0@NONE DOWN ip_vti0@NONE DOWN ip6_vti0@NONE DOWN sit0@NONE DOWN ip6tnl0@NONE DOWN ip6gre0@NONE DOWN eth0@if13 UP 10.244.2.3/24 fe80::2877:ffff:fe46:b1ca/64
docker exec kx-worker2 sh -c 'nsenter -t $(pidof -s web) -n ip route'
default via 10.244.2.1 dev eth0 10.244.2.0/24 via 10.244.2.1 dev eth0 src 10.244.2.3 10.244.2.1 dev eth0 scope link src 10.244.2.3
eth0 carries the address kubectl showed for payments, and the default route points at the node’s end of the pod’s veth pair. None of it needed the kubelet or the API server.
kubectl debug reaches the same namespaces through the API: it adds an ephemeral container to the pod, which the kubelet pulls and starts, and the request passes RBAC, admission and Pod Security, and lands in the audit log. Use it whenever the kubelet is healthy. nsenter needs root on the node and bypasses all of that, so it is the tool for a node whose kubelet cannot start containers, and access to it deserves the same care as access to the node itself.
Node debug pods
kubectl debug node/<name> creates a pod bound to that node, in the host’s network, PID and IPC namespaces, with the node’s root filesystem at /host. It is a pod, so the node’s kubelet has to start it:
docker exec kx-worker2 systemctl stop kubelet
kubectl debug node/kx-worker2 --image=busybox:1.37 -- sleep 3600
Creating debugging pod node-debugger-kx-worker2-jdx7s with container debugger on node kx-worker2.
kubectl get pods -l app.kubernetes.io/managed-by=kubectl-debug -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES node-debugger-kx-worker2-jdx7s 0/1 Pending 0 0s <none> kx-worker2 <none> <none>
The pod is assigned to kx-worker2 and stays Pending, because no kubelet there picks it up. On a node whose kubelet works, a node debug pod is the way in without SSH. The node’s tools live under /host, and chroot /host makes them the shell’s own, so the node’s journalctl and crictl run as they would over SSH. chroot needs the sysadmin profile, which makes the pod privileged:
kubectl debug node/kx-worker2 -it --image=busybox:1.37 --profile=sysadmin
chroot /host
journalctl -u kubelet -n 20
crictl ps -a
exit
Delete the pod when you are done with kubectl delete pods -l app.kubernetes.io/managed-by=kubectl-debug; its container keeps the node’s root filesystem mounted until then.
Bringing the node back
A kubelet that was stopped on purpose comes back with systemctl start. One that stopped on its own needs the cause from its journal first, or it stops again. Once it runs, it renews its Lease and posts status, the node lifecycle controller removes the unreachable taints, and the kubelet syncs every pod bound to the node: it resumes invoicer’s back-off, and stops the containers of pods that were evicted while it was away, which completes their deletion.
docker exec kx-worker2 systemctl stop kubelet
kubectl wait --for=condition=Ready=Unknown node/kx-worker2 --timeout=120s
node/kx-worker2 condition met
docker exec kx-worker2 systemctl start kubelet
kubectl wait --for=condition=Ready node/kx-worker2 --timeout=120s
node/kx-worker2 condition met
kubectl get nodes
NAME STATUS ROLES AGE VERSION kx-control-plane Ready control-plane 2m26s v1.37.0 kx-worker Ready <none> 2m21s v1.37.0 kx-worker2 Ready <none> 2m21s v1.37.0 kx-worker3 Ready <none> 2m21s v1.37.0
docker exec kx-worker2 systemctl stop kubeletkubectl --context kind-kx wait --for=condition=Ready=Unknown node/kx-worker2 --timeout=120sdocker exec kx-worker2 journalctl -u kubelet -n 5docker exec kx-worker2 crictl psdocker exec kx-worker2 systemctl start kubeletkubectl --context kind-kx wait --for=condition=Ready node/kx-worker2 --timeout=120s
For your own kind cluster kx: copy a command and paste it into your terminal. Run in the simulator runs the same command in this page's simulated cluster instead; nothing on this page touches your machine. The node turns NotReady about 50 seconds after the stop, while crictl ps still lists every container on it. The journal ends with systemd stopping the unit; after the start, the kubelet posts status within seconds and the wait returns.
Actual state
Check your understanding
Your first answer to each check is the one that counts. After a miss you can answer again; passing every check reconciles the lesson.
Lesson not yet reconciled
Desired: 5 objectives, 0 metReconciled: 5 of 5 objectives met
- Recognise a node whose kubelet has stopped, and say which kubectl commands still work against it. (not yet met)
- Read the kubelet's unit, status and journal with systemctl and journalctl, and know what its default verbosity leaves out. (not yet met)
- List a node's pods and containers and read their logs with crictl, without the kubelet. (not yet met)
- Run a node tool inside a pod's network namespace with nsenter, and choose between that and kubectl debug. (not yet met)
- Bring a node back from NotReady from the node shell. (not yet met)
Pass every check above to reconcile this lesson.
Every check has passed, so the desired state is met. First-try accuracy: 0 of 6. This lesson's review cards are in your queue.
Sources
Checked against kubernetes.io documentation and upstream source at kind v0.33.0, cri-tools v1.37.0, containerd v2.3.4 and Kubernetes v1.37.0 for Kubernetes 1.37 on .
- kubernetes.io/docs/tasks/debug/debug-cluster/crictl
- kubernetes.io/docs/tasks/debug/debug-cluster/kubectl-node-debug
- kubernetes.io/docs/tasks/debug/debug-cluster
- kubernetes.io/docs/concepts/architecture/nodes
- kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration
- kubernetes.io/docs/concepts/cluster-administration/node-shutdown
- kubernetes.io/docs/concepts/cluster-administration/logging
- kubernetes.io/docs/reference/config-api/kubelet-config.v1beta1
- kubernetes.io/docs/reference/command-line-tools-reference/kube-controller-manager
- man7.org/linux/man-pages/man1/nsenter.1.html
- freedesktop.org/software/systemd/man/latest/journalctl.html
- freedesktop.org/software/systemd/man/latest/systemd.service.html
- raw.githubusercontent.com/kubernetes-sigs/kind/v0.33.0/images/base/files/etc/systemd/system/kubelet.service
- raw.githubusercontent.com/kubernetes-sigs/kind/v0.33.0/images/base/files/etc/systemd/system/kubelet.service.d/10-kubeadm.conf
- raw.githubusercontent.com/kubernetes-sigs/kind/v0.33.0/images/base/files/etc/systemd/system/kubelet.service.d/11-kind.conf
- raw.githubusercontent.com/kubernetes-sigs/kind/v0.33.0/images/base/files/kind/bin/create-kubelet-cgroup-v2.sh
- raw.githubusercontent.com/kubernetes-sigs/cri-tools/v1.37.0/cmd/crictl/container.go
- raw.githubusercontent.com/kubernetes-sigs/cri-tools/v1.37.0/cmd/crictl/sandbox.go
- raw.githubusercontent.com/kubernetes-sigs/cri-tools/v1.37.0/cmd/crictl/logs.go
- raw.githubusercontent.com/containerd/containerd/v2.3.4/internal/cri/server/version.go
- raw.githubusercontent.com/kubernetes/kubernetes/v1.37.0/pkg/kubelet/pod_workers.go
- raw.githubusercontent.com/kubernetes/kubernetes/v1.37.0/pkg/kubelet/kubelet.go
- raw.githubusercontent.com/kubernetes/kubernetes/v1.37.0/pkg/kubelet/prober/prober.go
Debugging from the node: crictl, journalctl and nsenter
↓ ↑ step, 1 to 7 scene, Esc leave