crictl: Kubernetes Container Runtime Troubleshooting Tool
crictl
is a command-line interface for CRI-compatible container runtimes. It is a lightweight tool used to inspect and troubleshoot containers and pods managed by Kubernetes, especially when you need to debug issues at the container runtime level.
What is crictl?
- crictl stands for "Container Runtime Interface Control".
- It interacts directly with the container runtime (like containerd or CRI-O) used by Kubernetes, bypassing the kubelet and Kubernetes API.
- Useful for low-level troubleshooting when
kubectl
is not enough or the kubelet is not functioning properly.
Why use crictl?
- Inspect and debug containers and pods at the runtime level.
- View logs, status, and configuration of containers and pods.
- Pull, run, and remove images directly from the runtime.
- Essential for troubleshooting node-level issues.
Basic Usage
- List all pods:
crictl pods
- List all containers:
crictl ps -a
- Inspect a specific pod:
crictl inspectp <pod-id>
- Inspect a specific container:
crictl inspect <container-id>
- View container logs:
crictl logs <container-id>
- Pull an image:
crictl pull <image-name>
- Remove a container:
crictl rm <container-id>
Configuration
crictl
uses a config file (default:/etc/crictl.yaml
) to connect to the container runtime socket.- Example config for containerd:
runtime-endpoint: unix:///run/containerd/containerd.sock
image-endpoint: unix:///run/containerd/containerd.sock
timeout: 10
debug: false