Linux, systemd & container runtime refresher
Manage services with systemctl and inspect containers with crictl.
By Invicly Tech, , in Kubernetes Administrator (CKA). About 8 minutes to read.
In short
Kubernetes nodes are Linux machines where systemd runs the kubelet and the container runtime. The kubelet talks to runtimes like containerd through the Container Runtime Interface. On the exam you use systemctl, journalctl and crictl to fix nodes when kubectl cannot help.
Explained simply
Every Kubernetes node is just a Linux machine. On it, a program called systemd starts background services when the machine boots. Two of those services matter most: the kubelet, which is the Kubernetes agent on the node, and the container runtime, usually containerd, which actually runs containers.
Picture a restaurant kitchen. The kubelet is the head chef reading orders from the API server. containerd is the cook who actually makes each dish. systemd is the manager who makes sure both show up for work and restarts them if they walk out.
When kubectl stops working, you go to the node itself. systemctl tells you if a service is running, journalctl shows its logs, and crictl lists and inspects containers directly through the runtime. These three tools let you fix a cluster that cannot fix itself.
Press Play on a diagram to walk through it one step at a time.
- 1kubelet
Node agent run by systemd; asks the runtime for containers.
- 2CRI (gRPC)
Standard API between kubelet and container runtimes.
- 3containerd
High-level runtime: pulls images, manages containers.
- 4runc
Low-level OCI runtime that creates the process.
- 5Linux kernel
Namespaces isolate, cgroups limit CPU and memory.
- kubelet to containerd: RunPodSandbox (CRI)1RunPodSandbox (CRI)
- containerd to runc: Start pause container2Start pause container
- kubelet to containerd: PullImage, CreateContainer3PullImage, CreateContainer
- containerd to runc: Create app process4Create app process
- runc to Linux kernel: Set up namespaces and cgroups5Set up namespaces and cgroups
- kubelet to containerd: ContainerStatus (every few seconds)6ContainerStatus (every few seconds)
In depth
From kubelet to a running process
When a Pod is assigned to a node, the kubelet calls the runtime through the Container Runtime Interface (CRI), a standard gRPC API. First it asks for a Pod sandbox: a small pause container that owns the Pod's network namespace, so every container in the Pod shares one IP. Then it asks the runtime to pull images and create each container inside that sandbox.
containerd does not start processes itself. It hands the job to a low-level runtime called runc, which uses Linux kernel features: namespaces to give the process its own view of the system, and cgroups (control groups) to limit its CPU and memory. A container is really just a normal Linux process with these walls around it.
- CRI: the API between kubelet and runtime
- Pause container: holds the Pod's shared network
- runc: creates the actual process
- Namespaces isolate; cgroups limit
systemd units and drop-in files
systemd describes each service in a unit file. The kubelet unit on kubeadm nodes is small, and most of its settings come from a drop-in file such as /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf, which adds flags and points to /var/lib/kubelet/config.yaml.
After changing any unit or drop-in, run systemctl daemon-reload so systemd reads the new files, then restart the service. systemctl enable makes a service start at boot; forgetting it means a fixed node breaks again after a reboot. systemctl cat kubelet prints the unit plus all its drop-ins in one view.
- systemctl status kubelet: running or failed, plus last log lines
- systemctl cat kubelet: show unit and drop-ins
- systemctl enable --now kubelet: start now and at boot
- 1Edit unit or drop-in
e.g. 10-kubeadm.conf
- 2systemctl daemon-reload
systemd rereads unit files
- 3systemctl restart kubelet
Apply the change
- 4systemctl enable kubelet
Also start at boot
- 5Check
systemctl status, journalctl -u kubelet
Reading logs with journalctl
systemd collects service output in the journal. journalctl -u kubelet shows the kubelet's log from the start, which is usually far too long. Add -n 50 for the last 50 lines, -f to follow live output, --since "10 min ago" to narrow the time, and --no-pager to print straight to the terminal.
The first error after a restart is usually the real cause. Look for lines with "failed", "error" or "unable to", such as a missing certificate file or a bad flag. Later lines often just repeat the same failure every few seconds.
Using crictl well
crictl talks to the runtime's CRI socket, so it works even when the API server is down. It finds the socket from /etc/crictl.yaml, which usually says runtime-endpoint: unix:///run/containerd/containerd.sock.
crictl ps -a lists all containers, including ones that exited, which is how you spot a crashing kube-apiserver. crictl logs ID shows a container's output. crictl pods lists sandboxes, crictl inspect ID shows full details, and crictl images lists pulled images. These look like Docker commands, but they only see Kubernetes-managed containers.
- crictl ps -a | grep kube-apiserver
- crictl logs CONTAINER_ID
- crictl pods --name etcd
- Talks to the API server
- Fails if the API server is down
- Sees objects across the cluster
- Talks to the node's CRI socket
- Works when the API server is down
- Sees only that node's containers
Learn it in 4 short steps
About 45m each. Track them with a timer in your plan.
- 1Manage services with systemctl~45m
- 2Read logs with journalctl~45m
- 3Inspect containers with crictl~45m
- 4Explain the container runtime interface~45m
Key points
- kubelet and containerd are systemd services; check them with systemctl status.
- journalctl -u kubelet shows why the kubelet fails to start.
- crictl talks to the CRI runtime and works even when the API server is down.
- Docker Engine support via dockershim was removed in Kubernetes 1.24.
Key terms
Tap a card to flip it. 0/6 known
Examples
systemctl status kubelet
sudo systemctl restart containerd
sudo journalctl -u kubelet --since "10 min ago" | tail -20
# Inspect containers through the CRI
sudo crictl ps -a
sudo crictl pods
sudo crictl logs <container-id>
sudo crictl imagesA node is NotReady after a reboot
kubectl get nodes shows worker1 NotReady. Step 1: ssh to worker1 and run systemctl status kubelet; it says inactive (dead). Step 2: the service was never enabled, so it did not start at boot. Step 3: enable and start it. Step 4: back on the control plane, the node turns Ready within a minute.
ssh worker1
sudo systemctl status kubelet # Active: inactive (dead)
sudo systemctl enable --now kubelet
sudo journalctl -u kubelet -n 20 --no-pager
exit
kubectl get nodes -wFinding why the API server keeps dying
kubectl returns "connection refused". Step 1: ssh to the control plane and list all containers, including exited ones. Step 2: the kube-apiserver container shows Exited and a high attempt count. Step 3: read its logs. Step 4: the log names a wrong flag, which you then fix in the static Pod manifest.
sudo crictl ps -a | grep kube-apiserver
# 3f2a... Exited kube-apiserver attempt 7
sudo crictl logs 3f2a
# Error: unknown flag: --etcd-servrs
sudo vi /etc/kubernetes/manifests/kube-apiserver.yamlQuick reference
- systemctl status|restart|enable --now kubelet
- systemctl daemon-reload after editing any unit or drop-in file
- journalctl -u kubelet -n 50 --no-pager shows recent kubelet logs
- crictl ps -a lists all containers, including exited ones
- crictl logs ID works even when the API server is down
- Runtime socket: unix:///run/containerd/containerd.sock (set in /etc/crictl.yaml)
- containerd cgroup setting: SystemdCgroup = true in /etc/containerd/config.toml
Common mistakes
- Editing a unit file and forgetting systemctl daemon-reload.
- Using docker commands on a node that runs only containerd.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
On a node, show whether containerd and kubelet are running and enabled at boot.
- Exercise 2medium
Print only the kubelet log lines from the last 15 minutes that contain the word error, ignoring case.
- Exercise 3hard
Find the etcd container on a control plane node with crictl, print its last 20 log lines, and show which host directory it uses for data.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Can I still use Docker with Kubernetes?
- Images built with Docker run fine anywhere. But the kubelet no longer talks to Docker Engine directly since 1.24; clusters use containerd or CRI-O, or Docker via the separate cri-dockerd adapter.
- Why does crictl show different containers from docker ps?
- crictl only sees containers in the CRI runtime's Kubernetes namespace. Docker, if installed, keeps its own separate list.
- Why must kubelet and containerd use the same cgroup driver?
- If one uses systemd and the other cgroupfs, two managers fight over the same resources and the node becomes unstable. On modern systems both should use systemd.