Skip to content

Commit

Permalink
Add documentation for crictl
Browse files Browse the repository at this point in the history
  • Loading branch information
feiskyer committed Jun 5, 2018
1 parent cb6a190 commit de3c5f6
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 30 deletions.
75 changes: 47 additions & 28 deletions content/en/docs/tasks/debug-application-cluster/crictl.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ reviewers:
- Random-Liu
- feiskyer
- mrunalp
title: crictl
title: Crictl
---

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.
Expand Down Expand Up @@ -65,7 +65,7 @@ crictl connects to `unix:///var/run/dockershim.sock` by default. For other runti
- By setting the endpoint in the config file `--config=/etc/crictl.yaml`

```sh
# cat /etc/crictl.yaml
$ cat /etc/crictl.yaml
runtime-endpoint: unix:///var/run/dockershim.sock
image-endpoint: unix:///var/run/dockershim.sock
timeout: 10
Expand All @@ -87,52 +87,64 @@ debug: true
### Run pod sandbox with config file

```sh
# cat podsandbox-config.json
$ cat pod-config.json
{
"metadata": {
"name": "nginx-sandbox",
"namespace": "default",
"attempt": 1,
"uid": "hdishd83djaidwnduwk28bcsb"
},
"logDirectory": "/tmp",
"linux": {
}
}

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

List pod sandboxes and check the sandbox is in Ready state:

```sh
$ crictl pods
POD ID CREATED STATE NAME NAMESPACE ATTEMPT
f84dd361f8dc5 17 seconds ago Ready busybox-sandbox default 1
```

### Pull a busybox image

```sh
# 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
$ crictl pull busybox
Image is up to date for busybox@sha256:141c253bc4c3fd0a201d32dc1f493bcf3fff003b6df416dea4f41046e0f37d47
```

### Create container in a pod sandbox with config file
List images and check the busybox image has been pulled:

```sh
# cat podsandbox-config.json
$ crictl images
IMAGE TAG IMAGE ID SIZE
busybox latest 8c811b4aec35f 1.15MB
k8s.gcr.io/pause 3.1 da86e6ba6ca19 742kB
```

### Create container in the pod sandbox with config file

```sh
$ cat pod-config.json
{
"metadata": {
"name": "nginx-sandbox",
"namespace": "default",
"attempt": 1,
"uid": "hdishd83djaidwnduwk28bcsb"
},
"logDirectory": "/tmp",
"linux": {
}
}

# cat container-config.json
$ cat container-config.json
{
"metadata": {
"name": "busybox"
Expand All @@ -143,31 +155,38 @@ gcr.io/google_containers/pause-amd64 3.0 99e59f495ffaa 7
"command": [
"top"
],
"logPath":"busybox/0.log",
"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
$ crictl create f84dd361f8dc51518ed291fbadd6db537b0496536c1d2d6c05ff943ce8c9a54f container-config.json pod-config.json
3e025dd50a72d956c4f14881fbb5b1080c9275674e95fb67f965f6478a957d60
```

List containers and check the container is in Created state:

```sh
$ crictl ps -a
CONTAINER ID IMAGE CREATED STATE NAME ATTEMPT
3e025dd50a72d busybox 32 seconds ago Created busybox 0
```

### Start container

```sh
# crictl start 0a2c761303163f2acaaeaee07d2ba143ee4cea7e3bde3d32190e2a36525c8a05
0a2c761303163f2acaaeaee07d2ba143ee4cea7e3bde3d32190e2a36525c8a05
# crictl ps
CONTAINER ID CREATED STATE NAME
0a2c761303163f2acaaeaee07d2ba143ee4cea7e3bde3d32190e2a36525c8a05 2 minutes ago CONTAINER_RUNNING busybox
$ crictl start 3e025dd50a72d956c4f14881fbb5b1080c9275674e95fb67f965f6478a957d60
3e025dd50a72d956c4f14881fbb5b1080c9275674e95fb67f965f6478a957d60

$ crictl ps
CONTAINER ID IMAGE CREATED STATE NAME ATTEMPT
3e025dd50a72d busybox About a minute ago Running busybox 0
```

### Exec a command in container

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,5 +359,4 @@ Learn about additional debugging tools, including:
* [Getting into containers via `exec`](/docs/tasks/debug-application-cluster/get-shell-running-container/)
* [Connecting to containers via proxies](/docs/tasks/access-kubernetes-api/http-proxy-access-api/)
* [Connecting to containers via port forwarding](/docs/tasks/access-application-cluster/port-forward-access-application-cluster/)


* [Crictl](/docs/tasks/debug-application-cluster/crictl/)

0 comments on commit de3c5f6

Please sign in to comment.