With the removal docker as the default container runtime in kubernetes.
When a situation arises where you need to debug the container application container
You can use Crictl and Nerdctl and debug the issue quickly
Crictl
- Install crictl
VERSION="v1.22.0"
wget https://github.com/kubernetes-sigs/cri-tools/releases/download/$VERSION/crictl-$VERSION-linux-amd64.tar.gz
sudo tar zxvf crictl-$VERSION-linux-amd64.tar.gz -C /usr/local/bin
- Create a endpoint configuration file (crictl.yaml)
Example
To interact with containerd runtime env
cat /etc/crictl.yaml
runtime-endpoint: unix:///run/containerd/containerd.sock
image-endpoint: unix:///run/containerd/containerd.sock
timeout: 2
debug: false
pull-image-on-create: false
To interact with docker runtime
cat /etc/crictl.yaml
runtime-endpoint: unix:///var/run/dockershim.sock
image-endpoint: unix:///var/run/dockershim.sock
timeout: 2
debug: false
pull-image-on-create: false
To interact with Crio runtime
cat /etc/crictl.yaml
runtime-endpoint: unix:///run/crio/crio.sock
image-endpoint: unix:///run/crio/crio.sock
timeout: 2
debug: false
- Execute the crictl commands
Example:
kiran@master1:~$ sudo crictl --help
kiran@master1:~$ sudo crictl info
kiran@master1:~$ sudo crictl info
kiran@master1:~$ sudo crictl inspect <>
kiran@master1:~$ sudo crictl pods
Nerdctl
While critctl is great its not compatible with Docker CLI, not friendly to users, and does not support non-CRI features
Currently nerdctl runs with containerd runtime
https://github.com/containerd/nerdctl
- Installing
wget https://github.com/containerd/nerdctl/releases/download/v0.11.1/nerdctl-0.11.1-linux-amd64.tar.gz
sudo tar Cxzvvf /usr/local/bin nerdctl-0.11.1-linux-amd64.tar.gz
- Commands
sudo nerdctl version
sudo nerdctl system info
sudo nerdctl help
nerdctl --namespace k8s.io ps -a
nerdctl run -d --name nginx -p 8080:80 nginx:alpine
nerdclt ps
nerdctl logs -f <>
nerdctl compose up -d
nerdctl top <>
nerdctl volume ls
nerdctl volume inspect
nerdctl network -h
nerdctl port <>
Ref: https://github.com/kubernetes-sigs/cri-tools/blob/master/docs/crictl.md https://kubernetes.io/docs/tasks/debug-application-cluster/crictl/
https://github.com/containerd/nerdctl
https://github.com/containerd/nerdctl/releases
A good video which talks about it