cri-tools provides a CLI(crictl) for CRI-compatible container runtimes. This is an easy way to verify CRI implementation in PouchContainer without setting up all Kubernetes components.
The CRI CLI can be installed easily via go get
command:
go get github.com/kubernetes-incubator/cri-tools/cmd/crictl
Then crictl
binary can be found in $GOPATH/bin
.
Note: ensure GO is installed and GOPATH is set before installing crictl.
crictl SUBCOMMAND [FLAGS]
Subcommands includes(crictl v1.12):
attach
: Attach to a running containercreate
: Create a new containerexec
: Run a command in a running containerversion
: Display runtime version informationimages
: List imagesinspect
: Display the status of one or more containersinspecti
: Return the status of one ore more imagesinspectp
: Display the status of one or more podslogs
: Fetch the logs of a containerport-forward
: Forward local port to a podps
: List containerspull
: Pull an image from a registryrunp
: Run a new podrm
: Remove one or more containersrmi
: Remove one or more imagesrmp
: Remove one or more podspods
: List podsstart
: Start one or more created containersinfo
: Display information of the container runtimestop
: Stop one or more running containersstopp
: Stop one or more running podsupdate
: Update one or more running containersconfig
: Get and set crictl optionsstats
: List container(s) resource usage statisticscompletion
: Output bash shell completion codehelp, h
: Shows a list of commands or help for one command
crictl connects to /var/run/dockershim.sock by default. For other runtimes, the endpoint can be set in three ways:
- By setting flags
--runtime-endpoint
and--image-endpoint
- By setting environment variables
CRI_RUNTIME_ENDPOINT
andCRI_IMAGE_ENDPOINT
- By setting the endpoint in the config file
--config=/etc/crictl.yaml
# cat /etc/crictl.yaml
runtime-endpoint: unix:///var/run/pouchcri.sock
image-endpoint: unix:///var/run/pouchcri.sock
timeout: 10
debug: true
# pouch pull k8s.gcr.io/pause-amd64:3.0
# cat sandbox-config.json
{
"metadata": {
"name": "nginx-sandbox",
"namespace": "default",
"attempt": 1,
"uid": "hdishd83djaidwnduwk28bcsb"
},
"linux": {
}
}
# crictl runs sandbox-config.json
53bfc944e2e6b391089d441d364e9fea98ea4a51c882d831f5a83d5fd0803162
# pouch ps
Name ID Status Image Runtime Created
k8s_POD_nginx-sandbox_default_hdishd83djaidwnduwk28bcsb_1 53bfc9 running k8s.gcr.io/pause-amd64:3.0 runc 4 seconds ago
# crictl pull docker.io/library/redis:alpine
Image is update to date for 0153c5db97e5
# crictl images
IMAGE TAG IMAGE ID SIZE
docker.io/library/redis alpine 0153c5db97e58 10.1MB
If PouchContainer has not fully or correctly implemented some interfaces in CRI, crictl command execution would fail:
# crictl ps
FATA[0000] listing containers failed: rpc error: code = Unknown desc = ListContainers Not Implemented Yet