Skip to content

Commit 5154fe2

Browse files
authored
Merge pull request #36576 from yanrongshi/zh-cn]Rewrite-determine-reason-pod-failure.md
[zh-cn] Fix layout of determine-reason-pod-failure.md
2 parents 3c73460 + fbb6999 commit 5154fe2

File tree

1 file changed

+53
-33
lines changed

1 file changed

+53
-33
lines changed

content/zh-cn/docs/tasks/debug/debug-application/determine-reason-pod-failure.md

Lines changed: 53 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,14 @@ the container starts.
5050

5151
{{< codenew file="debug/termination.yaml" >}}
5252

53-
<!-- 1. Create a Pod based on the YAML configuration file: -->
53+
<!--
54+
1. Create a Pod based on the YAML configuration file:
55+
-->
5456
1. 基于 YAML 配置文件创建 Pod:
5557

56-
kubectl apply -f https://k8s.io/examples/debug/termination.yaml
58+
```shell
59+
kubectl apply -f https://k8s.io/examples/debug/termination.yaml
60+
```
5761

5862
<!--
5963
In the YAML file, in the `command` and `args` fields, you can see that the
@@ -65,56 +69,72 @@ the container starts.
6569
写入 `/dev/termination-log` 文件。
6670
容器写完 "Sleep expired" 消息后就终止了。
6771

68-
<!-- 1. Display information about the Pod: -->
69-
1. 显示 Pod 的信息:
72+
<!--
73+
1. Display information about the Pod:
74+
-->
75+
2. 显示 Pod 的信息:
7076

71-
kubectl get pod termination-demo
77+
```shell
78+
kubectl get pod termination-demo
79+
```
7280

73-
<!--Repeat the preceding command until the Pod is no longer running.-->
81+
<!--
82+
Repeat the preceding command until the Pod is no longer running.
83+
-->
7484
重复前面的命令直到 Pod 不再运行。
7585

76-
<!-- 1. Display detailed information about the Pod: -->
77-
1. 显示 Pod 的详细信息:
86+
<!--
87+
1. Display detailed information about the Pod:
88+
-->
89+
3. 显示 Pod 的详细信息:
7890

79-
kubectl get pod termination-demo --output=yaml
91+
```shell
92+
kubectl get pod termination-demo --output=yaml
93+
```
8094

81-
<!--The output includes the "Sleep expired" message:-->
95+
<!--
96+
The output includes the "Sleep expired" message:
97+
-->
8298
输出结果包含 "Sleep expired" 消息:
8399

84-
apiVersion: v1
85-
kind: Pod
86-
...
87-
lastState:
88-
terminated:
89-
containerID: ...
90-
exitCode: 0
91-
finishedAt: ...
92-
message: |
93-
Sleep expired
94-
...
100+
```
101+
apiVersion: v1
102+
kind: Pod
103+
...
104+
lastState:
105+
terminated:
106+
containerID: ...
107+
exitCode: 0
108+
finishedAt: ...
109+
message: |
110+
Sleep expired
111+
...
112+
```
95113

96114
<!--
97115
1. Use a Go template to filter the output so that it includes
98116
only the termination message:
99117
-->
100-
1. 使用 Go 模板过滤输出结果,使其只含有终止消息:
118+
4. 使用 Go 模板过滤输出结果,使其只含有终止消息:
101119

102-
kubectl get pod termination-demo -o go-template="{{range .status.containerStatuses}}{{.lastState.terminated.message}}{{end}}"
103-
104-
<!--
105-
If you are running a multi-container pod, you can use a Go template to include the container's name. By doing so, you can discover which of the containers is failing:
106-
-->
107-
如果你正在运行多容器 Pod,则可以使用 Go 模板来包含容器的名称。这样,你可以发现哪些容器出现故障:
120+
```shell
121+
kubectl get pod termination-demo -o go-template="{{range .status.containerStatuses}}{{.lastState.terminated.message}}{{end}}"
122+
```
108123

109-
```shell
110-
kubectl get pod multi-container-pod -o go-template='{{range .status.containerStatuses}}{{printf "%s:\n%s\n\n" .name .lastState.terminated.message}}{{end}}'
111-
```
124+
<!--
125+
If you are running a multi-container pod, you can use a Go template to include the container's name. By doing so, you can discover which of the containers is failing:
126+
-->
127+
如果你正在运行多容器 Pod,则可以使用 Go 模板来包含容器的名称。这样,你可以发现哪些容器出现故障:
128+
129+
```shell
130+
kubectl get pod multi-container-pod -o go-template='{{range .status.containerStatuses}}{{printf "%s:\n%s\n\n" .name .lastState.terminated.message}}{{end}}'
131+
```
112132

113133
<!--
114134
## Customizing the termination message
115135
116136
Kubernetes retrieves termination messages from the termination message file
117-
specified in the `terminationMessagePath` field of a Container, which as a default
137+
specified in the `terminationMessagePath` field of a Container, which has a default
118138
value of `/dev/termination-log`. By customizing this field, you can tell Kubernetes
119139
to use a different file. Kubernetes use the contents from the specified file to
120140
populate the Container's status message on both success and failure.
@@ -143,7 +163,7 @@ kubelet 会截断长度超过 4096 字节的消息。
143163
例如,如果有 12 个容器(`initContainers``containers`),
144164
每个容器都有 1024 字节的可用终止消息空间。
145165

146-
默认的终止消息路径是 `/dev/termination-log`
166+
默认的终止消息路径是 `/dev/termination-log`
147167
Pod 启动后不能设置终止消息路径。
148168

149169
<!--

0 commit comments

Comments
 (0)