Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Wat het doet
Kubernetes nodes do not run Docker; the kubelet talks to a runtime (containerd or CRI-O) through the Container Runtime Interface. crictl speaks the same interface, so on a node you can see what kubelet sees — even when the API server is down. This is a key CKA troubleshooting skill (for example when a static pod of the control plane does not start).
Set the runtime socket in /etc/crictl.yaml.
Zo schrijf je het
crictl [--runtime-endpoint URL] COMMAND [OPTIONS]Belangrijkste delen
Commands
pods- List pod sandboxes.
ps[-a]- List (all) containers.
logs[-f]ID- Container logs.
inspectID/inspectpID/inspectiIMG- Details of a container / pod / image.
exec-itIDsh- Run a command in a container.
images- List images.
pullIMG/rmiIMG- Pull / remove an image.
stats- Resource use of containers.
stop/rmID- Stop / remove a container.
stopp/rmpID- Stop / remove a pod.
info- Runtime info and status.
rmi--prune- Remove unused images.
Opties 7
Meest gebruikt
Flags
Niets past bij dit filter.
Voorbeelden 10
$ als gewone gebruiker# als root (of met sudo)
1Point crictl at containerd
cat /etc/crictl.yaml runtime-endpoint: unix:///run/containerd/containerd.sock image-endpoint: unix:///run/containerd/containerd.sock timeout: 102List pods and containers on this node
crictl pods crictl ps -a3Find why kube-apiserver does not start (CKA)
crictl ps -a --name kube-apiserver crictl logs $(crictl ps -a --name kube-apiserver -q | head -1) journalctl -u kubelet -n 50A typo in /etc/kubernetes/manifests/kube-apiserver.yaml is the usual cause.
4Show the containers of one namespace
crictl pods --namespace shop crictl ps --pod $(crictl pods --name shop -q | head -1)5Look inside a container
crictl exec -it 3f2a91c0d1e7 sh6See resource use
crictl stats7Images on the node
crictl images crictl pull ghcr.io/s0sta/shop:1.4.0 crictl rmi --prune8Read details as JSON
crictl inspect 3f2a91c0d1e7 | jq '.info.runtimeSpec.process.user'9Use it on k3s
k3s crictl ps10Check the runtime status
crictl info | jq '.status.conditions' systemctl status containerd
Niets past bij dit filter.
Let op
- Containers you remove with crictl are recreated by kubelet if a pod still wants them.
- Use crictl to look, kubectl to change — the API server is the source of truth.
Bestanden
/etc/crictl.yaml- Runtime endpoint settings.
/etc/kubernetes/manifests/- Static pods (control plane on kubeadm clusters).
/var/log/pods/- Container log files.
Tips om te onthouden
- Without
/etc/crictl.yamlcrictl tries several sockets and prints warnings.
Exitcodes
0 | Success. |
1 | Error. |