@@ -126,16 +126,7 @@ The following examples show some `crictl` commands and example output.
126
126
-->
127
127
## crictl 命令示例 {#example-crictl-commands}
128
128
129
- {{< warning >}}
130
- <!--
131
- If you use `crictl` to create pod sandboxes or containers on a running
132
- Kubernetes cluster, the Kubelet will eventually delete them. `crictl` is not a
133
- general purpose workflow tool, but a tool that is useful for debugging.
134
- -->
135
- 如果使用 ` crictl ` 在正在运行的 Kubernetes 集群上创建 Pod 沙盒或容器,
136
- kubelet 最终将删除它们。
137
- ` crictl ` 不是一个通用的工作流工具,而是一个对调试有用的工具。
138
- {{< /warning >}}
129
+ 以下示例展示了一些 ` crictl ` 命令及其示例输出。
139
130
140
131
<!--
141
132
### List pods
@@ -370,195 +361,10 @@ The output is similar to this:
370
361
-->
371
362
输出类似于这样:
372
363
373
- ``` none
374
- 10.240.0.96 - - [06/Jun/2018:02:45:51 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.47.0" "-"
375
364
```
376
-
377
- <!--
378
- ### Run a pod sandbox
379
-
380
- Using `crictl` to run a pod sandbox is useful for debugging container runtimes.
381
- On a running Kubernetes cluster, the sandbox will eventually be stopped and
382
- deleted by the Kubelet.
383
- -->
384
- ### 运行 Pod 沙盒 {#run-a-pod-sandbox}
385
-
386
- 用 ` crictl ` 运行 Pod 沙盒对容器运行时排错很有帮助。
387
- 在运行的 Kubernetes 集群中,沙盒会随机地被 kubelet 停止和删除。
388
-
389
- <!--
390
- 1. Create a JSON file like the following:
391
- -->
392
- 1 . 编写下面的 JSON 文件:
393
-
394
- ``` json
395
- {
396
- "metadata" : {
397
- "name" : " nginx-sandbox" ,
398
- "namespace" : " default" ,
399
- "attempt" : 1 ,
400
- "uid" : " hdishd83djaidwnduwk28bcsb"
401
- },
402
- "log_directory" : " /tmp" ,
403
- "linux" : {
404
- }
405
- }
406
- ```
407
-
408
- <!--
409
- 2. Use the `crictl runp` command to apply the JSON and run the sandbox.
410
- -->
411
- 2 . 使用 ` crictl runp ` 命令应用 JSON 文件并运行沙盒。
412
-
413
- ``` shell
414
- crictl runp pod-config.json
415
- ```
416
-
417
- <!--
418
- The ID of the sandbox is returned.
419
- -->
420
- 返回了沙盒的 ID。
421
-
422
- <!--
423
- ### Create a container
424
-
425
- Using `crictl` to create a container is useful for debugging container runtimes.
426
- On a running Kubernetes cluster, the container will eventually be stopped and
427
- deleted by the Kubelet.
428
- -->
429
- ### 创建容器 {#create-a-container}
430
-
431
- 用 ` crictl ` 创建容器对容器运行时排错很有帮助。
432
- 在运行的 Kubernetes 集群中,容器最终将被 kubelet 停止和删除。
433
-
434
- <!--
435
- 1. Pull a busybox image
436
- -->
437
- 1 . 拉取 busybox 镜像
438
-
439
- ``` shell
440
- crictl pull busybox
441
- ```
442
- ``` none
443
- Image is up to date for busybox@sha256:141c253bc4c3fd0a201d32dc1f493bcf3fff003b6df416dea4f41046e0f37d47
444
- ```
445
-
446
- <!--
447
- 2. Create configs for the pod and the container:
448
- -->
449
- 2 . 创建 Pod 和容器的配置:
450
-
451
- <!--
452
- **Pod config**:
453
- -->
454
- ** Pod 配置** :
455
-
456
- ``` json
457
- {
458
- "metadata" : {
459
- "name" : " busybox-sandbox" ,
460
- "namespace" : " default" ,
461
- "attempt" : 1 ,
462
- "uid" : " aewi4aeThua7ooShohbo1phoj"
463
- },
464
- "log_directory" : " /tmp" ,
465
- "linux" : {
466
- }
467
- }
468
- ```
469
-
470
- <!--
471
- **Container config**:
472
- -->
473
- ** 容器配置** :
474
-
475
- ``` json
476
- {
477
- "metadata" : {
478
- "name" : " busybox"
479
- },
480
- "image" :{
481
- "image" : " busybox"
482
- },
483
- "command" : [
484
- " top"
485
- ],
486
- "log_path" :" busybox.log" ,
487
- "linux" : {
488
- }
489
- }
490
- ```
491
-
492
- <!--
493
- 3. Create the container, passing the ID of the previously-created pod, the
494
- container config file, and the pod config file. The ID of the container is
495
- returned.
496
- -->
497
- 3 . 创建容器,传递先前创建的 Pod 的 ID、容器配置文件和 Pod 配置文件。返回容器的 ID。
498
-
499
- ``` bash
500
- crictl create f84dd361f8dc51518ed291fbadd6db537b0496536c1d2d6c05ff943ce8c9a54f container-config.json pod-config.json
501
- ```
502
-
503
- <!--
504
- 4. List all containers and verify that the newly-created container has its
505
- state set to `Created`.
506
- -->
507
- 4 . 查询所有容器并确认新创建的容器状态为 ` Created ` 。
508
-
509
- ``` bash
510
- crictl ps -a
511
- ```
512
- <!--
513
- The output is similar to this:
514
- -->
515
- 输出类似于这样:
516
-
517
- ``` none
518
- CONTAINER ID IMAGE CREATED STATE NAME ATTEMPT
519
- 3e025dd50a72d busybox 32 seconds ago Created busybox 0
520
- ```
521
-
522
- <!--
523
- ### Start a container
524
-
525
- To start a container, pass its ID to `crictl start`:
526
- -->
527
- ### 启动容器 {#start-a-container}
528
-
529
- 要启动容器,要将容器 ID 传给 ` crictl start ` :
530
-
531
- ``` shell
532
- crictl start 3e025dd50a72d956c4f14881fbb5b1080c9275674e95fb67f965f6478a957d60
533
- ```
534
-
535
- <!--
536
- The output is similar to this:
537
- -->
538
- 输出类似于这样:
539
-
540
- ```
541
- 3e025dd50a72d956c4f14881fbb5b1080c9275674e95fb67f965f6478a957d60
542
- ```
543
-
544
- <!--
545
- Check the container has its state set to `Running`.
546
- -->
547
- 确认容器的状态为 ` Running ` 。
548
-
549
- ``` shell
550
- crictl ps
365
+ 10.240.0.96 - - [06/Jun/2018:02:45:51 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.47.0" "-"
551
366
```
552
367
553
- <!--
554
- The output is similar to this:
555
- -->
556
- 输出类似于这样:
557
-
558
- ``` none
559
- CONTAINER ID IMAGE CREATED STATE NAME ATTEMPT
560
- 3e025dd50a72d busybox About a minute ago Running busybox 0
561
- ```
562
368
563
369
## {{% heading "whatsnext" %}}
564
370
0 commit comments