CRI-tools
Conventionally, container engines come equipped with a command-line tool to help users debug applications and simplify troubleshooting. For instance, when Docker is employed as the container runtime, you can use the docker command to inspect the status of containers and images and verify the accuracy of a container's configuration. But what if you're using other container engines? Here's when crictl comes in as an outstanding substitute for the docker tool.
Crictl is a part of cri-tools and functions much like the docker command line. It offers the direct advantage of being able to communicate with the container runtime via CRI, without the need for Kubelet. Designed specifically for Kubernetes, it is efficient at managing resources such as Pods, containers, and images. It aids both developers and users in debugging application issues and troubleshooting anomalies. Crictl can be used with all container runtimes implementing CRI interfaces.
But don't mistake crictl as a substitution for kubectl; it solely communicates with the container runtime via the CRI and is useful for debugging and troubleshooting, not for executing containers. While crictl does have commands to run Pods and containers, it's recommended to use them for debugging purposes only. Be cautious; if you create new Pods on a Kubernetes Node, Kubelet will stop and delete them.
Moving beyond crictl, cri-tools also provides a validation test tool critest, which checks whether the container runtime has implemented the necessary CRI features. Critest ensures that the implementation of the container runtime aligns with Kubelet's requirements by conducting an array of tests. This highly recommended tool should run its tests on all container runtimes before release. In most cases, critest is a part of integrated container runtime testing, ensuring that any code updates won't damage CRI functionality.
CRI-tools officially had their General Availability (GA) release in Version 1.11. For detailed usage techniques, please refer to kubernetes-sigs/cri-tools and Debugging Kubernetes nodes with crictl.
A Sneak Peek at crictl in Action
Querying a Pod
$ crictl pods --name nginx-65899c769f-wv2gp
POD ID CREATED STATE NAME NAMESPACE ATTEMPT
4dccb216c4adb 2 minutes ago Ready nginx-65899c769f-wv2gp default 0Listing Pods
$ crictl pods
POD ID CREATED STATE NAME NAMESPACE ATTEMPT
926f1b5a1d33a About a minute ago Ready sh-84d7dcf559-4r2gq default 0
4dccb216c4adb About a minute ago Ready nginx-65899c769f-wv2gp default 0
a86316e96fa89 17 hours ago Ready kube-proxy-gblk4 kube-system 0
919630b8f81f1 17 hours ago Ready nvidia-device-plugin-zgbbv kube-system 0Listing Images
Listing Containers
Executing a Command Inside a Container
Checking Container Logs
Learn More
最后更新于