[zh] Sync a task: debug-cluster/crictl.md
parent
719e87a452
commit
20fe906954
content/zh-cn/docs/tasks/debug/debug-cluster
|
@ -126,16 +126,7 @@ The following examples show some `crictl` commands and example output.
|
|||
-->
|
||||
## crictl 命令示例 {#example-crictl-commands}
|
||||
|
||||
{{< warning >}}
|
||||
<!--
|
||||
If you use `crictl` to create pod sandboxes or containers on a running
|
||||
Kubernetes cluster, the Kubelet will eventually delete them. `crictl` is not a
|
||||
general purpose workflow tool, but a tool that is useful for debugging.
|
||||
-->
|
||||
如果使用 `crictl` 在正在运行的 Kubernetes 集群上创建 Pod 沙盒或容器,
|
||||
kubelet 最终将删除它们。
|
||||
`crictl` 不是一个通用的工作流工具,而是一个对调试有用的工具。
|
||||
{{< /warning >}}
|
||||
以下示例展示了一些 `crictl` 命令及其示例输出。
|
||||
|
||||
<!--
|
||||
### List pods
|
||||
|
@ -370,195 +361,10 @@ The output is similar to this:
|
|||
-->
|
||||
输出类似于这样:
|
||||
|
||||
```none
|
||||
```
|
||||
10.240.0.96 - - [06/Jun/2018:02:45:51 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.47.0" "-"
|
||||
```
|
||||
|
||||
<!--
|
||||
### Run a pod sandbox
|
||||
|
||||
Using `crictl` to run a pod sandbox is useful for debugging container runtimes.
|
||||
On a running Kubernetes cluster, the sandbox will eventually be stopped and
|
||||
deleted by the Kubelet.
|
||||
-->
|
||||
### 运行 Pod 沙盒 {#run-a-pod-sandbox}
|
||||
|
||||
用 `crictl` 运行 Pod 沙盒对容器运行时排错很有帮助。
|
||||
在运行的 Kubernetes 集群中,沙盒会随机地被 kubelet 停止和删除。
|
||||
|
||||
<!--
|
||||
1. Create a JSON file like the following:
|
||||
-->
|
||||
1. 编写下面的 JSON 文件:
|
||||
|
||||
```json
|
||||
{
|
||||
"metadata": {
|
||||
"name": "nginx-sandbox",
|
||||
"namespace": "default",
|
||||
"attempt": 1,
|
||||
"uid": "hdishd83djaidwnduwk28bcsb"
|
||||
},
|
||||
"log_directory": "/tmp",
|
||||
"linux": {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<!--
|
||||
2. Use the `crictl runp` command to apply the JSON and run the sandbox.
|
||||
-->
|
||||
2. 使用 `crictl runp` 命令应用 JSON 文件并运行沙盒。
|
||||
|
||||
```shell
|
||||
crictl runp pod-config.json
|
||||
```
|
||||
|
||||
<!--
|
||||
The ID of the sandbox is returned.
|
||||
-->
|
||||
返回了沙盒的 ID。
|
||||
|
||||
<!--
|
||||
### Create a container
|
||||
|
||||
Using `crictl` to create a container is useful for debugging container runtimes.
|
||||
On a running Kubernetes cluster, the container will eventually be stopped and
|
||||
deleted by the Kubelet.
|
||||
-->
|
||||
### 创建容器 {#create-a-container}
|
||||
|
||||
用 `crictl` 创建容器对容器运行时排错很有帮助。
|
||||
在运行的 Kubernetes 集群中,容器最终将被 kubelet 停止和删除。
|
||||
|
||||
<!--
|
||||
1. Pull a busybox image
|
||||
-->
|
||||
1. 拉取 busybox 镜像
|
||||
|
||||
```shell
|
||||
crictl pull busybox
|
||||
```
|
||||
```none
|
||||
Image is up to date for busybox@sha256:141c253bc4c3fd0a201d32dc1f493bcf3fff003b6df416dea4f41046e0f37d47
|
||||
```
|
||||
|
||||
<!--
|
||||
2. Create configs for the pod and the container:
|
||||
-->
|
||||
2. 创建 Pod 和容器的配置:
|
||||
|
||||
<!--
|
||||
**Pod config**:
|
||||
-->
|
||||
**Pod 配置**:
|
||||
|
||||
```json
|
||||
{
|
||||
"metadata": {
|
||||
"name": "busybox-sandbox",
|
||||
"namespace": "default",
|
||||
"attempt": 1,
|
||||
"uid": "aewi4aeThua7ooShohbo1phoj"
|
||||
},
|
||||
"log_directory": "/tmp",
|
||||
"linux": {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<!--
|
||||
**Container config**:
|
||||
-->
|
||||
**容器配置**:
|
||||
|
||||
```json
|
||||
{
|
||||
"metadata": {
|
||||
"name": "busybox"
|
||||
},
|
||||
"image":{
|
||||
"image": "busybox"
|
||||
},
|
||||
"command": [
|
||||
"top"
|
||||
],
|
||||
"log_path":"busybox.log",
|
||||
"linux": {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<!--
|
||||
3. Create the container, passing the ID of the previously-created pod, the
|
||||
container config file, and the pod config file. The ID of the container is
|
||||
returned.
|
||||
-->
|
||||
3. 创建容器,传递先前创建的 Pod 的 ID、容器配置文件和 Pod 配置文件。返回容器的 ID。
|
||||
|
||||
```bash
|
||||
crictl create f84dd361f8dc51518ed291fbadd6db537b0496536c1d2d6c05ff943ce8c9a54f container-config.json pod-config.json
|
||||
```
|
||||
|
||||
<!--
|
||||
4. List all containers and verify that the newly-created container has its
|
||||
state set to `Created`.
|
||||
-->
|
||||
4. 查询所有容器并确认新创建的容器状态为 `Created`。
|
||||
|
||||
```bash
|
||||
crictl ps -a
|
||||
```
|
||||
<!--
|
||||
The output is similar to this:
|
||||
-->
|
||||
输出类似于这样:
|
||||
|
||||
```none
|
||||
CONTAINER ID IMAGE CREATED STATE NAME ATTEMPT
|
||||
3e025dd50a72d busybox 32 seconds ago Created busybox 0
|
||||
```
|
||||
|
||||
<!--
|
||||
### Start a container
|
||||
|
||||
To start a container, pass its ID to `crictl start`:
|
||||
-->
|
||||
### 启动容器 {#start-a-container}
|
||||
|
||||
要启动容器,要将容器 ID 传给 `crictl start`:
|
||||
|
||||
```shell
|
||||
crictl start 3e025dd50a72d956c4f14881fbb5b1080c9275674e95fb67f965f6478a957d60
|
||||
```
|
||||
|
||||
<!--
|
||||
The output is similar to this:
|
||||
-->
|
||||
输出类似于这样:
|
||||
|
||||
```
|
||||
3e025dd50a72d956c4f14881fbb5b1080c9275674e95fb67f965f6478a957d60
|
||||
```
|
||||
|
||||
<!--
|
||||
Check the container has its state set to `Running`.
|
||||
-->
|
||||
确认容器的状态为 `Running`。
|
||||
|
||||
```shell
|
||||
crictl ps
|
||||
```
|
||||
|
||||
<!--
|
||||
The output is similar to this:
|
||||
-->
|
||||
输出类似于这样:
|
||||
|
||||
```none
|
||||
CONTAINER ID IMAGE CREATED STATE NAME ATTEMPT
|
||||
3e025dd50a72d busybox About a minute ago Running busybox 0
|
||||
```
|
||||
|
||||
## {{% heading "whatsnext" %}}
|
||||
|
||||
|
|
Loading…
Reference in New Issue