Debugs containers and pods at the CRI level with crictl: inspect sandboxes, run containers directly, and read container logs and stats.
Agentic Workflow: Read -> Reason -> Act (crictl)
You are crictl (devops/general) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — devops context for crictl
- Domain: Debugs containers and pods at the CRI level with crictl: inspect sandboxes, run containers directly, and read container logs and stats.
- cri-inspection: List, inspect, and describe pods and containers as seen by the container runtime. —
crictl ps
- debug-and-logs: Run one-off debug containers, exec into running containers, and stream logs at runtime level. —
crictl run --no-pull debug-container.json sandbox.json
- Check
knowledge and prerequisites: crictl
2. Reason — think for crictl
- For
cri-inspection: List, inspect, and describe pods and containers as seen by the container runtime. — decide which checks to run
- For
debug-and-logs: Run one-off debug containers, exec into running containers, and stream logs at runtime level. — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with crictl tools
- Tools:
Glob, Grep, Read, Crictl (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
crictl:453f4608
crictl CRI Debugging
Inspect containers and pods at the container-runtime-interface level, below kubectl.
What This Skill Does
- Lists pods and containers the way containerd sees them
- Inspects sandbox and container details (images, mounts, labels)
- Execs and reads logs without relying on the API server
- Runs one-off debug containers (e.g. busybox) inside the runtime
- Pulls stats and prunes stale images/containers
When to Use
- kubectl hangs or the API server is down but nodes run containers
- Debugging container start failures, OOM kills, or runtime errors
- Forensics: what is actually running on a node right now
Real Commands
# Inspect
crictl pods
crictl pods --state Ready
crictl ps -a
crictl inspect 3e2d1c4a # container details
crictl inspectp a9b8c7d6 # pod sandbox details
crictl images
crictl info # runtime + CRI version
# Debug
crictl run --no-pull debug.json sandbox.json
crictl exec -it 3e2d1c4a sh
crictl logs --tail 200 3e2d1c4a
crictl stats
# Cleanup
crictl rm -f <id>
crictl rmi --prune
crictl cleanup
Debug Container Config
{
"metadata": { "name": "debug-container" },
"image": { "image": "busybox" },
"command": ["sh", "-c", "sleep 3600"],
"stdin": true
}
Best Practices
- Set
--runtime-endpoint unix:///run/containerd/containerd.sock on containerd nodes
- Use
crictl inspect output (JSON) with jq for scripting
- Prefer
crictl logs --tail over full logs in production
- Use
crictl stats to spot CPU/mem pressure before OOM-kill forensics
Capabilities
cri-inspection
List, inspect, and describe pods and containers as seen by the container runtime.
Parameters:
id (string): Container or pod sandbox ID prefix
state (string): Filter by state: Running, Exited, Ready
Commands:
crictl ps
crictl pods
crictl inspect $(docker ps -q)
crictl inspectp demo-pod-id
crictl images
crictl info
Examples:
- crictl ps -a
- crictl inspect 3e2d1c4a
- crictl pods --state Ready
debug-and-logs
Run one-off debug containers, exec into running containers, and stream logs at runtime level.
Parameters:
container-id (string): Container ID prefix
tail (integer): Number of log lines to show
Commands:
crictl run --no-pull debug-container.json sandbox.json
crictl exec -it $(docker ps -q) sh
crictl logs --tail 100 $(docker ps -q)
crictl stats
crictl rm $(docker ps -q)
crictl rmi --prune
Examples:
- crictl exec -it 3e2d1c4a sh
- crictl logs --tail 200 3e2d1c4a
- crictl stats
References
1---2name: "crictl"3description: "Debugs containers and pods at the CRI level with crictl: inspect sandboxes, run containers directly, and read container logs and stats. Use when working with cri inspection, debug and logs, devops or when the user mentions cri inspection, debug and logs, devops."4license: "MIT"5compatibility: "Requires crictl."6metadata:7 source: https://skillmd.com/skills/opknock/crictl8 author: Kdesk9 version: 2.0.010 category: devops11allowed-tools: "Glob Grep Read Bash(crictl:*)"12---1314Debugs containers and pods at the CRI level with crictl: inspect sandboxes, run containers directly, and read container logs and stats.1516## Agentic Workflow: Read -> Reason -> Act (crictl)1718You are **crictl** (devops/general) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — devops context for `crictl`21- Domain: Debugs containers and pods at the CRI level with crictl: inspect sandboxes, run containers directly, and read container logs and stats.22- **cri-inspection**: List, inspect, and describe pods and containers as seen by the container runtime. — `crictl ps`23- **debug-and-logs**: Run one-off debug containers, exec into running containers, and stream logs at runtime level. — `crictl run --no-pull debug-container.json sandbox.json`24- Check `knowledge` and `prerequisites: crictl`2526### 2. Reason — think for `crictl`27- For `cri-inspection`: List, inspect, and describe pods and containers as seen by the container runtime. — decide which checks to run28- For `debug-and-logs`: Run one-off debug containers, exec into running containers, and stream logs at runtime level. — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `crictl` tools32- Tools: `Glob`, `Grep`, `Read`, `Crictl` (see frontmatter `tools`/`allowed-tools`)33- Use `safe_path` for any write; record evidence (paths, checksums)34- Fingerprint: `crictl:453f4608`3536# crictl CRI Debugging3738Inspect containers and pods at the container-runtime-interface level, below kubectl.3940## What This Skill Does4142- Lists pods and containers the way containerd sees them43- Inspects sandbox and container details (images, mounts, labels)44- Execs and reads logs without relying on the API server45- Runs one-off debug containers (e.g. busybox) inside the runtime46- Pulls stats and prunes stale images/containers4748## When to Use4950- kubectl hangs or the API server is down but nodes run containers51- Debugging container start failures, OOM kills, or runtime errors52- Forensics: what is actually running on a node right now5354## Real Commands5556```bash57# Inspect58crictl pods59crictl pods --state Ready60crictl ps -a61crictl inspect 3e2d1c4a # container details62crictl inspectp a9b8c7d6 # pod sandbox details63crictl images64crictl info # runtime + CRI version6566# Debug67crictl run --no-pull debug.json sandbox.json68crictl exec -it 3e2d1c4a sh69crictl logs --tail 200 3e2d1c4a70crictl stats7172# Cleanup73crictl rm -f <id>74crictl rmi --prune75crictl cleanup76```7778## Debug Container Config7980```json81{82 "metadata": { "name": "debug-container" },83 "image": { "image": "busybox" },84 "command": ["sh", "-c", "sleep 3600"],85 "stdin": true86}87```8889## Best Practices9091- Set `--runtime-endpoint unix:///run/containerd/containerd.sock` on containerd nodes92- Use `crictl inspect` output (JSON) with jq for scripting93- Prefer `crictl logs --tail` over full logs in production94- Use `crictl stats` to spot CPU/mem pressure before OOM-kill forensics9596## Capabilities9798### cri-inspection99List, inspect, and describe pods and containers as seen by the container runtime.100101**Parameters:**102- `id` (string): Container or pod sandbox ID prefix103- `state` (string): Filter by state: Running, Exited, Ready104105**Commands:**106- `crictl ps`107- `crictl pods`108- `crictl inspect $(docker ps -q)`109- `crictl inspectp demo-pod-id`110- `crictl images`111- `crictl info`112113**Examples:**114- crictl ps -a115- crictl inspect 3e2d1c4a116- crictl pods --state Ready117118### debug-and-logs119Run one-off debug containers, exec into running containers, and stream logs at runtime level.120121**Parameters:**122- `container-id` (string): Container ID prefix123- `tail` (integer): Number of log lines to show124125**Commands:**126- `crictl run --no-pull debug-container.json sandbox.json`127- `crictl exec -it $(docker ps -q) sh`128- `crictl logs --tail 100 $(docker ps -q)`129- `crictl stats`130- `crictl rm $(docker ps -q)`131- `crictl rmi --prune`132133**Examples:**134- crictl exec -it 3e2d1c4a sh135- crictl logs --tail 200 3e2d1c4a136- crictl stats137138## References139- [crictl Reference (Kubernetes)](https://kubernetes.io/docs/reference/tools/mapcrictl/)140- [crictl GitHub](https://github.com/kubernetes-sigs/cri-tools/blob/master/docs/crictl.md)