Skip to content

Commit f7602b2

Browse files
authored
Merge pull request #321 from feiskyer/docs
Update crictl docs and examples
2 parents eae53b2 + c05b426 commit f7602b2

5 files changed

+96
-65
lines changed

docs/crictl.md

+88-62
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22

33
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.
44

5-
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.
5+
crictl is currently in Beta and still under quick iterations. It is hosted at the [cri-tools](https://github.com/kubernetes-incubator/cri-tools) repository. We encourage the CRI developers to report bugs or help extend the coverage by adding more functionalities.
66

7-
## Install
7+
## Install crictl
88

9-
The CRI CLI can be installed easily via `go get` command:
9+
crictl can be downloaded from cri-tools [release page](https://github.com/kubernetes-incubator/cri-tools/releases):
1010

1111
```sh
12-
go get github.com/kubernetes-incubator/cri-tools/cmd/crictl
12+
VERSION="v1.0.0-beta.1"
13+
wget https://github.com/kubernetes-incubator/cri-tools/releases/download/$VERSION/crictl-$VERSION-linux-amd64.tar.gz
14+
sudo tar zxvf crictl-$VERSION-linux-amd64.tar.gz -C /usr/local/bin
15+
rm -f crictl-$VERSION-linux-amd64.tar.gz
1316
```
1417

15-
Then `crictl` binary can be found in `$GOPATH/bin`.
16-
17-
*Note: ensure GO is installed and GOPATH is set before installing crictl.*
18-
1918
## Usage
2019

2120
```sh
@@ -24,37 +23,41 @@ crictl SUBCOMMAND [FLAGS]
2423

2524
Subcommands includes:
2625

27-
- `info`: Display runtime version information
28-
- `runp`: Run a new pod sandbox
29-
- `stopp`: Stop a running pod sandbox
30-
- `rmp`: Remove a pod sandbox
31-
- `inspectp`: Display the status of a pod sandbox
32-
- `pods`: List pod sandboxes
33-
- `create`: Create a new container
34-
- `start`: Start a created container
35-
- `stop`: Stop a running container
36-
- `rm`: Remove a container
37-
- `inspect`: Display the status of a container
38-
- `ps`: List containers
39-
- `status`: Display status of the container runtime
40-
- `attach`: Attach to a running container
41-
- `pull`: Pull an image from a registry
42-
- `images`: List images
43-
- `inspecti`: Return the status of an image
44-
- `rmi`: Remove an image
45-
- `exec`: Run a command in a running container
46-
- `port-forward`: Forward local port to a pod sandbox
47-
- `logs`: Fetch the logs of a container
48-
- `help`: Shows a list of commands or help for one command
26+
- `attach`: Attach to a running container
27+
- `create`: Create a new container
28+
- `exec`: Run a command in a running container
29+
- `version`: Display runtime version information
30+
- `images`: List images
31+
- `inspect`: Display the status of one or more containers
32+
- `inspecti`: Return the status of one ore more images
33+
- `inspectp`: Display the status of one or more pods
34+
- `logs`: Fetch the logs of a container
35+
- `port-forward`: Forward local port to a pod
36+
- `ps`: List containers
37+
- `pull`: Pull an image from a registry
38+
- `runp`: Run a new pod
39+
- `rm`: Remove one or more containers
40+
- `rmi`: Remove one or more images
41+
- `rmp`: Remove one or more pods
42+
- `pods`: List pods
43+
- `start`: Start one or more created containers
44+
- `info`: Display information of the container runtime
45+
- `stop`: Stop one or more running containers
46+
- `stopp`: Stop one or more running pods
47+
- `update`: Update one or more running containers
48+
- `config`: Get and set crictl options
49+
- `stats`: List container(s) resource usage statistics
50+
- `completion`: Output bash shell completion code
51+
- `help, h`: Shows a list of commands or help for one command
4952

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

5255
- By setting flags `--runtime-endpoint` and `--image-endpoint`
5356
- By setting environment variables `CONTAINER_RUNTIME_ENDPOINT` and `IMAGE_SERVICE_ENDPOINT`
5457
- By setting the endpoint in the config file `--config=/etc/crictl.yaml`
5558

56-
```
57-
# cat /etc/crictl.yaml
59+
```sh
60+
$ cat /etc/crictl.yaml
5861
runtime-endpoint: unix:///var/run/dockershim.sock
5962
image-endpoint: unix:///var/run/dockershim.sock
6063
timeout: 10
@@ -75,53 +78,65 @@ debug: true
7578

7679
### Run pod sandbox with config file
7780

78-
```
79-
# cat podsandbox-config.json
81+
```sh
82+
$ cat pod-config.json
8083
{
8184
"metadata": {
8285
"name": "nginx-sandbox",
8386
"namespace": "default",
8487
"attempt": 1,
8588
"uid": "hdishd83djaidwnduwk28bcsb"
8689
},
90+
"logDirectory": "/tmp",
8791
"linux": {
8892
}
8993
}
9094

91-
# crictl runp podsandbox-config.json
92-
e1c83b0b8d481d4af8ba98d5f7812577fc175a37b10dc824335951f52addbb4e
93-
# crictl pods
94-
PODSANDBOX ID NAME STATE
95-
e1c83b0b8d481d4af8ba98d5f7812577fc175a37b10dc824335951f52addbb4e nginx-sandbox SANDBOX_READY
95+
$ crictl runp pod-config.json
96+
f84dd361f8dc51518ed291fbadd6db537b0496536c1d2d6c05ff943ce8c9a54f
9697
```
9798

98-
### Pull a busybox image
99+
List pod sandboxes and check the sandbox is in Ready state:
99100

101+
```sh
102+
$ crictl pods
103+
POD ID CREATED STATE NAME NAMESPACE ATTEMPT
104+
f84dd361f8dc5 17 seconds ago Ready busybox-sandbox default 1
100105
```
101-
# crictl pull busybox
102-
Image is update to date for busybox@sha256:b82b5740006c1ab823596d2c07f081084ecdb32fd258072707b99f52a3cb8692
103-
# crictl images
104-
IMAGE TAG IMAGE ID SIZE
105-
busybox latest d20ae45477cbc 1.13MB
106-
gcr.io/google_containers/pause-amd64 3.0 99e59f495ffaa 747kB
106+
107+
### Pull a busybox image
108+
109+
```sh
110+
$ crictl pull busybox
111+
Image is up to date for busybox@sha256:141c253bc4c3fd0a201d32dc1f493bcf3fff003b6df416dea4f41046e0f37d47
107112
```
108113

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

116+
```sh
117+
$ crictl images
118+
IMAGE TAG IMAGE ID SIZE
119+
busybox latest 8c811b4aec35f 1.15MB
120+
k8s.gcr.io/pause 3.1 da86e6ba6ca19 742kB
111121
```
112-
# cat podsandbox-config.json
122+
123+
### Create container in the pod sandbox with config file
124+
125+
```sh
126+
$ cat pod-config.json
113127
{
114128
"metadata": {
115129
"name": "nginx-sandbox",
116130
"namespace": "default",
117131
"attempt": 1,
118132
"uid": "hdishd83djaidwnduwk28bcsb"
119133
},
134+
"log_directory": "/tmp",
120135
"linux": {
121136
}
122137
}
123138

124-
# cat container-config.json
139+
$ cat container-config.json
125140
{
126141
"metadata": {
127142
"name": "busybox"
@@ -132,30 +147,41 @@ gcr.io/google_containers/pause-amd64 3.0 99e59f495ffaa 7
132147
"command": [
133148
"top"
134149
],
150+
"log_path":"busybox/0.log",
135151
"linux": {
136152
}
137153
}
138154

139-
# crictl create e1c83b0b8d481d4af8ba98d5f7812577fc175a37b10dc824335951f52addbb4e container-config.json podsandbox-config.json
140-
0a2c761303163f2acaaeaee07d2ba143ee4cea7e3bde3d32190e2a36525c8a05
141-
# crictl ps -a
142-
CONTAINER ID CREATED STATE NAME
143-
0a2c761303163f2acaaeaee07d2ba143ee4cea7e3bde3d32190e2a36525c8a05 1 minutes ago CONTAINER_CREATED busybox
155+
$ crictl create f84dd361f8dc51518ed291fbadd6db537b0496536c1d2d6c05ff943ce8c9a54f container-config.json pod-config.json
156+
3e025dd50a72d956c4f14881fbb5b1080c9275674e95fb67f965f6478a957d60
144157
```
145158

146-
### Start container
159+
List containers and check the container is in Created state:
147160

161+
```sh
162+
$ crictl ps -a
163+
CONTAINER ID IMAGE CREATED STATE NAME ATTEMPT
164+
3e025dd50a72d busybox 32 seconds ago Created busybox 0
148165
```
149-
# crictl start 0a2c761303163f2acaaeaee07d2ba143ee4cea7e3bde3d32190e2a36525c8a05
150-
0a2c761303163f2acaaeaee07d2ba143ee4cea7e3bde3d32190e2a36525c8a05
151-
# crictl ps
152-
CONTAINER ID CREATED STATE NAME
153-
0a2c761303163f2acaaeaee07d2ba143ee4cea7e3bde3d32190e2a36525c8a05 2 minutes ago CONTAINER_RUNNING busybox
166+
167+
### Start container
168+
169+
```sh
170+
$ crictl start 3e025dd50a72d956c4f14881fbb5b1080c9275674e95fb67f965f6478a957d60
171+
3e025dd50a72d956c4f14881fbb5b1080c9275674e95fb67f965f6478a957d60
172+
173+
$ crictl ps
174+
CONTAINER ID IMAGE CREATED STATE NAME ATTEMPT
175+
3e025dd50a72d busybox About a minute ago Running busybox 0
154176
```
155177

156178
### Exec a command in container
157179

158-
```
159-
# crictl exec -i -t 0a2c761303163f2acaaeaee07d2ba143ee4cea7e3bde3d32190e2a36525c8a05 ls
180+
```sh
181+
crictl exec -i -t 3e025dd50a72d956c4f14881fbb5b1080c9275674e95fb67f965f6478a957d60 ls
160182
bin dev etc home proc root sys tmp usr var
161183
```
184+
185+
## More information
186+
187+
Visit [kubernetes-incubator/cri-tools](https://github.com/kubernetes-incubator/cri-tools) for more information.

docs/examples/container-config.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"command": [
99
"top"
1010
],
11+
"log_path":"busybox.0.log",
1112
"linux": {
1213
}
13-
}
14+
}

docs/examples/container-config.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ metadata:
33
image:
44
image: busybox:latest
55
command:
6-
- top
6+
- top
7+
log_path: busybox.0.log
8+

docs/examples/podsandbox-config.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"attempt": 1,
66
"uid": "hdishd83djaidwnduwk28bcsb"
77
},
8+
"log_directory": "/tmp",
89
"linux": {
910
}
10-
}
11+
}

docs/examples/podsandbox-config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ metadata:
33
name: busybox-sandbox
44
namespace: default
55
uid: hdishd83djaidwnduwk28bcsb
6+
log_directory: /tmp
67
linux:
78
namespaces:
89
options: {}

0 commit comments

Comments
 (0)