Skip to content

Commit 23286b6

Browse files
committed
Fix crictl page
This PR fixes a link (at the bottom of the page) to reference. It also fixes the indentation of the number lists, the incorrect syntax tag for code snippets.
1 parent 6b6c7a2 commit 23286b6

File tree

1 file changed

+103
-88
lines changed
  • content/en/docs/tasks/debug-application-cluster

1 file changed

+103
-88
lines changed

content/en/docs/tasks/debug-application-cluster/crictl.md

Lines changed: 103 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@ Kubernetes node. `crictl` and its source are hosted in the
1919

2020
## {{% heading "prerequisites" %}}
2121

22-
2322
`crictl` requires a Linux operating system with a CRI runtime.
2423

2524
<!-- steps -->
2625

2726
## Installing crictl
2827

29-
You can download a compressed archive `crictl` from the cri-tools [release
30-
page](https://github.com/kubernetes-sigs/cri-tools/releases), for several
28+
You can download a compressed archive `crictl` from the cri-tools
29+
[release page](https://github.com/kubernetes-sigs/cri-tools/releases), for several
3130
different architectures. Download the version that corresponds to your version
3231
of Kubernetes. Extract it and move it to a location on your system path, such as
3332
`/usr/local/bin/`.
@@ -85,6 +84,7 @@ List all pods:
8584
```shell
8685
crictl pods
8786
```
87+
8888
The output is similar to this:
8989

9090
```
@@ -100,6 +100,7 @@ List pods by name:
100100
```shell
101101
crictl pods --name nginx-65899c769f-wv2gp
102102
```
103+
103104
The output is similar to this:
104105

105106
```
@@ -112,6 +113,7 @@ List pods by label:
112113
```shell
113114
crictl pods --label run=nginx
114115
```
116+
115117
The output is similar to this:
116118

117119
```
@@ -126,6 +128,7 @@ List all images:
126128
```shell
127129
crictl images
128130
```
131+
129132
The output is similar to this:
130133

131134
```
@@ -141,6 +144,7 @@ List images by repository:
141144
```shell
142145
crictl images nginx
143146
```
147+
144148
The output is similar to this:
145149

146150
```
@@ -153,6 +157,7 @@ Only list image IDs:
153157
```shell
154158
crictl images -q
155159
```
160+
156161
The output is similar to this:
157162

158163
```
@@ -169,6 +174,7 @@ List all containers:
169174
```shell
170175
crictl ps -a
171176
```
177+
172178
The output is similar to this:
173179

174180
```
@@ -181,9 +187,10 @@ CONTAINER ID IMAGE
181187

182188
List running containers:
183189

184-
```
190+
```shell
185191
crictl ps
186192
```
193+
187194
The output is similar to this:
188195

189196
```
@@ -198,6 +205,7 @@ CONTAINER ID IMAGE
198205
```shell
199206
crictl exec -i -t 1f73f2d81bf98 ls
200207
```
208+
201209
The output is similar to this:
202210

203211
```
@@ -211,6 +219,7 @@ Get all container logs:
211219
```shell
212220
crictl logs 87d3992f84f74
213221
```
222+
214223
The output is similar to this:
215224

216225
```
@@ -224,6 +233,7 @@ Get only the latest `N` lines of logs:
224233
```shell
225234
crictl logs --tail=1 87d3992f84f74
226235
```
236+
227237
The output is similar to this:
228238

229239
```
@@ -236,98 +246,103 @@ Using `crictl` to run a pod sandbox is useful for debugging container runtimes.
236246
On a running Kubernetes cluster, the sandbox will eventually be stopped and
237247
deleted by the Kubelet.
238248

239-
1. Create a JSON file like the following:
249+
1. Create a JSON file like the following:
240250

241-
```json
242-
{
243-
"metadata": {
244-
"name": "nginx-sandbox",
245-
"namespace": "default",
246-
"attempt": 1,
247-
"uid": "hdishd83djaidwnduwk28bcsb"
248-
},
249-
"logDirectory": "/tmp",
250-
"linux": {
251-
}
252-
}
253-
```
251+
```json
252+
{
253+
"metadata": {
254+
"name": "nginx-sandbox",
255+
"namespace": "default",
256+
"attempt": 1,
257+
"uid": "hdishd83djaidwnduwk28bcsb"
258+
},
259+
"logDirectory": "/tmp",
260+
"linux": {
261+
}
262+
}
263+
```
254264

255-
2. Use the `crictl runp` command to apply the JSON and run the sandbox.
265+
2. Use the `crictl runp` command to apply the JSON and run the sandbox.
256266

257-
```shell
258-
crictl runp pod-config.json
259-
```
267+
```shell
268+
crictl runp pod-config.json
269+
```
260270

261-
The ID of the sandbox is returned.
271+
The ID of the sandbox is returned.
262272

263273
### Create a container
264274

265275
Using `crictl` to create a container is useful for debugging container runtimes.
266276
On a running Kubernetes cluster, the sandbox will eventually be stopped and
267277
deleted by the Kubelet.
268278

269-
1. Pull a busybox image
270-
271-
```shell
272-
crictl pull busybox
273-
Image is up to date for busybox@sha256:141c253bc4c3fd0a201d32dc1f493bcf3fff003b6df416dea4f41046e0f37d47
274-
```
275-
276-
2. Create configs for the pod and the container:
277-
278-
**Pod config**:
279-
```yaml
280-
{
281-
"metadata": {
282-
"name": "nginx-sandbox",
283-
"namespace": "default",
284-
"attempt": 1,
285-
"uid": "hdishd83djaidwnduwk28bcsb"
286-
},
287-
"log_directory": "/tmp",
288-
"linux": {
289-
}
290-
}
291-
```
292-
293-
**Container config**:
294-
```yaml
295-
{
296-
"metadata": {
297-
"name": "busybox"
298-
},
299-
"image":{
300-
"image": "busybox"
301-
},
302-
"command": [
303-
"top"
304-
],
305-
"log_path":"busybox.log",
306-
"linux": {
307-
}
308-
}
309-
```
310-
311-
3. Create the container, passing the ID of the previously-created pod, the
312-
container config file, and the pod config file. The ID of the container is
313-
returned.
314-
315-
```shell
316-
crictl create f84dd361f8dc51518ed291fbadd6db537b0496536c1d2d6c05ff943ce8c9a54f container-config.json pod-config.json
317-
```
318-
319-
4. List all containers and verify that the newly-created container has its
320-
state set to `Created`.
321-
322-
```shell
323-
crictl ps -a
324-
```
325-
The output is similar to this:
279+
1. Pull a busybox image
280+
281+
```shell
282+
crictl pull busybox
283+
```
284+
```none
285+
Image is up to date for busybox@sha256:141c253bc4c3fd0a201d32dc1f493bcf3fff003b6df416dea4f41046e0f37d47
286+
```
287+
288+
2. Create configs for the pod and the container:
289+
290+
**Pod config**:
291+
292+
```json
293+
{
294+
"metadata": {
295+
"name": "nginx-sandbox",
296+
"namespace": "default",
297+
"attempt": 1,
298+
"uid": "hdishd83djaidwnduwk28bcsb"
299+
},
300+
"log_directory": "/tmp",
301+
"linux": {
302+
}
303+
}
304+
```
305+
306+
**Container config**:
307+
308+
```json
309+
{
310+
"metadata": {
311+
"name": "busybox"
312+
},
313+
"image":{
314+
"image": "busybox"
315+
},
316+
"command": [
317+
"top"
318+
],
319+
"log_path":"busybox.log",
320+
"linux": {
321+
}
322+
}
323+
```
324+
325+
3. Create the container, passing the ID of the previously-created pod, the
326+
container config file, and the pod config file. The ID of the container is
327+
returned.
328+
329+
```shell
330+
crictl create f84dd361f8dc51518ed291fbadd6db537b0496536c1d2d6c05ff943ce8c9a54f container-config.json pod-config.json
331+
```
332+
333+
4. List all containers and verify that the newly-created container has its
334+
state set to `Created`.
335+
336+
```shell
337+
crictl ps -a
338+
```
339+
340+
The output is similar to this:
326341

327-
```
328-
CONTAINER ID IMAGE CREATED STATE NAME ATTEMPT
329-
3e025dd50a72d busybox 32 seconds ago Created busybox 0
330-
```
342+
```
343+
CONTAINER ID IMAGE CREATED STATE NAME ATTEMPT
344+
3e025dd50a72d busybox 32 seconds ago Created busybox 0
345+
```
331346

332347
### Start a container
333348

@@ -336,6 +351,7 @@ To start a container, pass its ID to `crictl start`:
336351
```shell
337352
crictl start 3e025dd50a72d956c4f14881fbb5b1080c9275674e95fb67f965f6478a957d60
338353
```
354+
339355
The output is similar to this:
340356

341357
```
@@ -350,13 +366,12 @@ crictl ps
350366
The output is similar to this:
351367

352368
```
353-
CONTAINER ID IMAGE CREATED STATE NAME ATTEMPT
354-
3e025dd50a72d busybox About a minute ago Running busybox 0
369+
CONTAINER ID IMAGE CREATED STATE NAME ATTEMPT
370+
3e025dd50a72d busybox About a minute ago Running busybox 0
355371
```
356372

357373
## {{% heading "whatsnext" %}}
358374

359375
* [Learn more about `crictl`](https://github.com/kubernetes-sigs/cri-tools).
360-
* [Map `docker` CLI commands to `crictl`](/reference/tools/map-crictl-dockercli/).
376+
* [Map `docker` CLI commands to `crictl`](/docs/reference/tools/map-crictl-dockercli/).
361377

362-
<!-- discussion -->

0 commit comments

Comments
 (0)