2
2
3
3
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.
4
4
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.
6
6
7
- ## Install
7
+ ## Install crictl
8
8
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 ) :
10
10
11
11
``` 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
13
16
```
14
17
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
-
19
18
## Usage
20
19
21
20
``` sh
@@ -24,37 +23,41 @@ crictl SUBCOMMAND [FLAGS]
24
23
25
24
Subcommands includes:
26
25
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
49
52
50
53
crictl connects to ` unix:///var/run/dockershim.sock ` by default. For other runtimes, the endpoint can be set in three ways:
51
54
52
55
- By setting flags ` --runtime-endpoint ` and ` --image-endpoint `
53
56
- By setting environment variables ` CONTAINER_RUNTIME_ENDPOINT ` and ` IMAGE_SERVICE_ENDPOINT `
54
57
- By setting the endpoint in the config file ` --config=/etc/crictl.yaml `
55
58
56
- ```
57
- # cat /etc/crictl.yaml
59
+ ``` sh
60
+ $ cat /etc/crictl.yaml
58
61
runtime-endpoint: unix:///var/run/dockershim.sock
59
62
image-endpoint: unix:///var/run/dockershim.sock
60
63
timeout: 10
@@ -75,53 +78,65 @@ debug: true
75
78
76
79
### Run pod sandbox with config file
77
80
78
- ```
79
- # cat podsandbox -config.json
81
+ ``` sh
82
+ $ cat pod -config.json
80
83
{
81
84
" metadata" : {
82
85
" name" : " nginx-sandbox" ,
83
86
" namespace" : " default" ,
84
87
" attempt" : 1,
85
88
" uid" : " hdishd83djaidwnduwk28bcsb"
86
89
},
90
+ " logDirectory" : " /tmp" ,
87
91
" linux" : {
88
92
}
89
93
}
90
94
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
96
97
```
97
98
98
- ### Pull a busybox image
99
+ List pod sandboxes and check the sandbox is in Ready state:
99
100
101
+ ``` sh
102
+ $ crictl pods
103
+ POD ID CREATED STATE NAME NAMESPACE ATTEMPT
104
+ f84dd361f8dc5 17 seconds ago Ready busybox-sandbox default 1
100
105
```
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
107
112
```
108
113
109
- ### Create container in a pod sandbox with config file
114
+ List images and check the busybox image has been pulled:
110
115
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
111
121
```
112
- # cat podsandbox-config.json
122
+
123
+ ### Create container in the pod sandbox with config file
124
+
125
+ ``` sh
126
+ $ cat pod-config.json
113
127
{
114
128
" metadata" : {
115
129
" name" : " nginx-sandbox" ,
116
130
" namespace" : " default" ,
117
131
" attempt" : 1,
118
132
" uid" : " hdishd83djaidwnduwk28bcsb"
119
133
},
134
+ " log_directory" : " /tmp" ,
120
135
" linux" : {
121
136
}
122
137
}
123
138
124
- # cat container-config.json
139
+ $ cat container-config.json
125
140
{
126
141
" metadata" : {
127
142
" name" : " busybox"
@@ -132,30 +147,41 @@ gcr.io/google_containers/pause-amd64 3.0 99e59f495ffaa 7
132
147
" command" : [
133
148
" top"
134
149
],
150
+ " log_path" :" busybox/0.log" ,
135
151
" linux" : {
136
152
}
137
153
}
138
154
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
144
157
```
145
158
146
- ### Start container
159
+ List containers and check the container is in Created state:
147
160
161
+ ``` sh
162
+ $ crictl ps -a
163
+ CONTAINER ID IMAGE CREATED STATE NAME ATTEMPT
164
+ 3e025dd50a72d busybox 32 seconds ago Created busybox 0
148
165
```
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
154
176
```
155
177
156
178
### Exec a command in container
157
179
158
- ```
159
- # crictl exec -i -t 0a2c761303163f2acaaeaee07d2ba143ee4cea7e3bde3d32190e2a36525c8a05 ls
180
+ ``` sh
181
+ crictl exec -i -t 3e025dd50a72d956c4f14881fbb5b1080c9275674e95fb67f965f6478a957d60 ls
160
182
bin dev etc home proc root sys tmp usr var
161
183
```
184
+
185
+ ## More information
186
+
187
+ Visit [ kubernetes-incubator/cri-tools] ( https://github.com/kubernetes-incubator/cri-tools ) for more information.
0 commit comments