1Container(Runtime)                    CLI                   Container(Runtime)
2
3
4
5       crictl  provides  a  CLI  for  CRI-compatible  container runtimes. This
6       allows the CRI runtime developers to debug their runtime without  need‐
7       ing to set up Kubernetes components.
8
9
10       crictl  is  currently  in  Beta and still under quick iterations. It is
11       hosted at the  cri-tools  ⟨https://github.com/kubernetes-incubator/cri-
12       tools⟩  repository.  We  encourage the CRI developers to report bugs or
13       help extend the coverage by adding more functionalities.
14
15

Install crictl

17       crictl   can   be    downloaded    from    cri-tools    release    page
18https://github.com/kubernetes-incubator/cri-tools/releases⟩:
19
20
21              VERSION="v1.11.1"
22              wget https://github.com/kubernetes-incubator/cri-tools/releases/download/$VERSION/crictl-$VERSION-linux-amd64.tar.gz
23              sudo tar zxvf crictl-$VERSION-linux-amd64.tar.gz -C /usr/local/bin
24              rm -f crictl-$VERSION-linux-amd64.tar.gz
25
26
27

Usage

29              crictl SUBCOMMAND [FLAGS]
30
31
32
33       Subcommands includes:
34
35
36              · attach:       Attach to a running container
37
38              · create:       Create a new container
39
40              · exec:         Run a command in a running container
41
42              · version:      Display runtime version information
43
44              · images:       List images
45
46              · inspect:      Display the status of one or more containers
47
48              · inspecti:     Return the status of one ore more images
49
50              · inspectp:     Display the status of one or more pods
51
52              · logs:         Fetch the logs of a container
53
54              · port-forward: Forward local port to a pod
55
56              · ps:           List containers
57
58              · pull:         Pull an image from a registry
59
60              · runp:         Run a new pod
61
62              · rm:           Remove one or more containers
63
64              · rmi:          Remove one or more images
65
66              · rmp:          Remove one or more pods
67
68              · pods:         List pods
69
70              · start:        Start one or more created containers
71
72              · info:         Display information of the container runtime
73
74              · stop:         Stop one or more running containers
75
76              · stopp:        Stop one or more running pods
77
78              · update:       Update one or more running containers
79
80              · config:       Get and set crictl options
81
82              · stats:        List container(s) resource usage statistics
83
84              · completion:   Output bash shell completion code
85
86              · help, h:      Shows a list of commands or help for one command
87
88
89
90       crictl  connects  to  unix:///var/run/dockershim.sock  by  default. For
91       other runtimes, the endpoint can be set in three ways:
92
93
94              · By setting flags --runtime-endpoint and --image-endpoint
95
96              · By setting  environment  variables  CONTAINER_RUNTIME_ENDPOINT
97                and IMAGE_SERVICE_ENDPOINT
98
99              · By   setting   the   endpoint   in   the  config  file  --con‐
100                fig=/etc/crictl.yaml
101
102
103
104              $ cat /etc/crictl.yaml
105              runtime-endpoint: unix:///var/run/dockershim.sock
106              image-endpoint: unix:///var/run/dockershim.sock
107              timeout: 10
108              debug: true
109
110
111

Additional options

113              · --runtime-endpoint, -r: CRI server runtime endpoint  (default:
114                "unix:///var/run/dockershim.sock").The default server is dock‐
115                ershim. If we want to debug other CRI server such  as  frakti,
116                we can add flag --runtime-endpoint=/var/run/frakti.sock
117
118              · --image-endpoint,  -i: CRI server image endpoint, default same
119                as runtime endpoint.
120
121              · --timeout, -t: Timeout of connecting to server (default: 10s)
122
123              · --debug, -D: Enable debug output
124
125              · --help, -h: show help
126
127              · --version, -v: print the version information of crictl
128
129              · --config, -c: Config file in yaml format. Overrided  by  flags
130                or environment variables.
131
132
133

Examples

135   Run pod sandbox with config file
136              $ cat pod-config.json
137              {
138                  "metadata": {
139                      "name": "nginx-sandbox",
140                      "namespace": "default",
141                      "attempt": 1,
142                      "uid": "hdishd83djaidwnduwk28bcsb"
143                  },
144                  "logDirectory": "/tmp",
145                  "linux": {
146                  }
147              }
148
149              $ crictl runp pod-config.json
150              f84dd361f8dc51518ed291fbadd6db537b0496536c1d2d6c05ff943ce8c9a54f
151
152
153
154       List pod sandboxes and check the sandbox is in Ready state:
155
156
157              $ crictl pods
158              POD ID              CREATED             STATE               NAME                NAMESPACE           ATTEMPT
159              f84dd361f8dc5       17 seconds ago      Ready               busybox-sandbox     default             1
160
161
162
163   Pull a busybox image
164              $ crictl pull busybox
165              Image is up to date for busybox@sha256:141c253bc4c3fd0a201d32dc1f493bcf3fff003b6df416dea4f41046e0f37d47
166
167
168
169       List images and check the busybox image has been pulled:
170
171
172              $ crictl images
173              IMAGE               TAG                 IMAGE ID            SIZE
174              busybox             latest              8c811b4aec35f       1.15MB
175              k8s.gcr.io/pause    3.1                 da86e6ba6ca19       742kB
176
177
178
179   Create container in the pod sandbox with config file
180              $ cat pod-config.json
181              {
182                  "metadata": {
183                      "name": "nginx-sandbox",
184                      "namespace": "default",
185                      "attempt": 1,
186                      "uid": "hdishd83djaidwnduwk28bcsb"
187                  },
188                  "log_directory": "/tmp",
189                  "linux": {
190                  }
191              }
192
193              $ cat container-config.json
194              {
195                "metadata": {
196                    "name": "busybox"
197                },
198                "image":{
199                    "image": "busybox"
200                },
201                "command": [
202                    "top"
203                ],
204                "log_path":"busybox/0.log",
205                "linux": {
206                }
207              }
208
209              $ crictl create f84dd361f8dc51518ed291fbadd6db537b0496536c1d2d6c05ff943ce8c9a54f container-config.json pod-config.json
210              3e025dd50a72d956c4f14881fbb5b1080c9275674e95fb67f965f6478a957d60
211
212
213
214       List containers and check the container is in Created state:
215
216
217              $ crictl ps -a
218              CONTAINER ID        IMAGE               CREATED             STATE               NAME                ATTEMPT
219              3e025dd50a72d       busybox             32 seconds ago      Created             busybox             0
220
221
222
223   Start container
224              $ crictl start 3e025dd50a72d956c4f14881fbb5b1080c9275674e95fb67f965f6478a957d60
225              3e025dd50a72d956c4f14881fbb5b1080c9275674e95fb67f965f6478a957d60
226
227              $ crictl ps
228              CONTAINER ID        IMAGE               CREATED              STATE               NAME                ATTEMPT
229              3e025dd50a72d       busybox             About a minute ago   Running             busybox             0
230
231
232
233   Exec a command in container
234              crictl exec -i -t 3e025dd50a72d956c4f14881fbb5b1080c9275674e95fb67f965f6478a957d60 ls
235              bin   dev   etc   home  proc  root  sys   tmp   usr   var
236
237
238

More information

240       Visit   kubernetes-incubator/cri-tools  ⟨https://github.com/kubernetes-
241       incubator/cri-tools⟩ for more information.
242
243
244
245(CRI)                              Interface                Container(Runtime)
Impressum