crictl man page

crictl provides a CLI for CRI-compatible container runtimes. This allows the CRI runtime developers to debug their runtime without needing to set up Kubernetes components.

crictl is currently in Alpha and still under quick iterations. We encourage the CRI developers to report bugs or help extend the coverage by adding more functionalities.

Install

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.

Usage

crictl SUBCOMMAND [FLAGS]

Subcommands includes:

crictl connects to unix:///var/run/dockershim.sock by default. For other runtimes, the endpoint can be set in three ways:

Additional options.IP · 2

--runtime-endpoint, -r: CRI server runtime endpoint (default: "unix:///var/run/dockershim.sock").The default server is dockershim. If we want to debug other CRI server such as frakti, we can add flag --runtime-endpoint=/var/run/frakti.sock

Examples

Run pod sandbox with config file

# cat podsandbox-config.json
{
    "metadata": {
        "name": "nginx-sandbox",
        "namespace": "default",
        "attempt": 1,
        "uid": "hdishd83djaidwnduwk28bcsb"
    },
    "linux": {
    }
}

# crictl runp podsandbox-config.json
e1c83b0b8d481d4af8ba98d5f7812577fc175a37b10dc824335951f52addbb4e
# crictl pods
PODSANDBOX ID                                                      NAME                STATE
e1c83b0b8d481d4af8ba98d5f7812577fc175a37b10dc824335951f52addbb4e   nginx-sandbox       SANDBOX_READY

Pull a busybox image

# crictl pull busybox
Image is update to date for busybox@sha256:b82b5740006c1ab823596d2c07f081084ecdb32fd258072707b99f52a3cb8692
# crictl images
IMAGE                                  TAG                 IMAGE ID            SIZE
busybox                                latest              d20ae45477cbc       1.13MB
gcr.io/google_containers/pause-amd64   3.0                 99e59f495ffaa       747kB

Create container in a pod sandbox with config file

# cat podsandbox-config.json
{
    "metadata": {
        "name": "nginx-sandbox",
        "namespace": "default",
        "attempt": 1,
        "uid": "hdishd83djaidwnduwk28bcsb"
    },
    "linux": {
    }
}

# cat container-config.json
{
  "metadata": {
      "name": "busybox"
  },
  "image":{
      "image": "busybox"
  },
  "command": [
      "top"
  ],
  "linux": {
  }
}

# crictl create e1c83b0b8d481d4af8ba98d5f7812577fc175a37b10dc824335951f52addbb4e container-config.json podsandbox-config.json
0a2c761303163f2acaaeaee07d2ba143ee4cea7e3bde3d32190e2a36525c8a05
# crictl ps -a
CONTAINER ID                                                       CREATED             STATE               NAME
0a2c761303163f2acaaeaee07d2ba143ee4cea7e3bde3d32190e2a36525c8a05   1 minutes ago       CONTAINER_CREATED   busybox

Start container

# crictl start 0a2c761303163f2acaaeaee07d2ba143ee4cea7e3bde3d32190e2a36525c8a05
0a2c761303163f2acaaeaee07d2ba143ee4cea7e3bde3d32190e2a36525c8a05
# crictl ps
CONTAINER ID                                                       CREATED             STATE               NAME
0a2c761303163f2acaaeaee07d2ba143ee4cea7e3bde3d32190e2a36525c8a05   2 minutes ago       CONTAINER_RUNNING   busybox

Exec a command in container

# crictl exec -i -t 0a2c761303163f2acaaeaee07d2ba143ee4cea7e3bde3d32190e2a36525c8a05 ls
bin   dev   etc   home  proc  root  sys   tmp   usr   var

Info

Interface (CRI) CLI