You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the YAML file, in the `command` and `args` fields, you can see that the
@@ -65,56 +69,72 @@ the container starts.
65
69
写入 `/dev/termination-log` 文件。
66
70
容器写完 "Sleep expired" 消息后就终止了。
67
71
68
-
<!-- 1. Display information about the Pod: -->
69
-
1. 显示 Pod 的信息:
72
+
<!--
73
+
1. Display information about the Pod:
74
+
-->
75
+
2. 显示 Pod 的信息:
70
76
71
-
kubectl get pod termination-demo
77
+
```shell
78
+
kubectl get pod termination-demo
79
+
```
72
80
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
+
-->
74
84
重复前面的命令直到 Pod 不再运行。
75
85
76
-
<!-- 1. Display detailed information about the Pod: -->
77
-
1. 显示 Pod 的详细信息:
86
+
<!--
87
+
1. Display detailed information about the Pod:
88
+
-->
89
+
3. 显示 Pod 的详细信息:
78
90
79
-
kubectl get pod termination-demo --output=yaml
91
+
```shell
92
+
kubectl get pod termination-demo --output=yaml
93
+
```
80
94
81
-
<!--The output includes the "Sleep expired" message:-->
95
+
<!--
96
+
The output includes the "Sleep expired" message:
97
+
-->
82
98
输出结果包含 "Sleep expired" 消息:
83
99
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
+
```
95
113
96
114
<!--
97
115
1. Use a Go template to filter the output so that it includes
98
116
only the termination message:
99
117
-->
100
-
1. 使用 Go 模板过滤输出结果,使其只含有终止消息:
118
+
4. 使用 Go 模板过滤输出结果,使其只含有终止消息:
101
119
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
+
```
108
123
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
+
```
112
132
113
133
<!--
114
134
## Customizing the termination message
115
135
116
136
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
118
138
value of `/dev/termination-log`. By customizing this field, you can tell Kubernetes
119
139
to use a different file. Kubernetes use the contents from the specified file to
120
140
populate the Container's status message on both success and failure.
0 commit comments