Skip to content

Commit 89f4f01

Browse files
authored
Merge pull request kubernetes#6288 from tengqm/termination-message-policy
Document terminationMessagePolicy
2 parents 4bca69f + a7c8e8c commit 89f4f01

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

docs/tasks/debug-application-cluster/determine-reason-pod-failure.md

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -75,25 +75,36 @@ only the termination message:
7575
{% raw %} kubectl get pod termination-demo -o go-template="{{range .status.containerStatuses}}{{.lastState.terminated.message}}{{end}}"{% endraw %}
7676
```
7777

78-
## Setting the termination log file
79-
80-
By default Kubernetes retrieves termination messages from
81-
`/dev/termination-log`. To change this to a different file,
82-
specify a `terminationMessagePath` field for your Container.
83-
84-
For example, suppose your Container writes termination messages to
85-
`/tmp/my-log`, and you want Kubernetes to retrieve those messages.
86-
Set `terminationMessagePath` as shown here:
87-
88-
apiVersion: v1
89-
kind: Pod
90-
metadata:
91-
name: msg-path-demo
92-
spec:
93-
containers:
94-
- name: msg-path-demo-container
95-
image: debian
96-
terminationMessagePath: "/tmp/my-log"
78+
## Customizing the termination message
79+
80+
Kubernetes retrieves termination messages from the termination message file
81+
specified in the `terminationMessagePath` field of a Container, which as a default
82+
value of `/dev/termination-log`. By customizing this field, you can tell Kubernetes
83+
to use a different file. Kubernetes use the contents from the specified file to
84+
populate the Container's status message on both success and failure.
85+
86+
In the following example, the container writes termination messages to
87+
`/tmp/my-log` for Kubernetes to retrieve:
88+
89+
```yaml
90+
apiVersion: v1
91+
kind: Pod
92+
metadata:
93+
name: msg-path-demo
94+
spec:
95+
containers:
96+
- name: msg-path-demo-container
97+
image: debian
98+
terminationMessagePath: "/tmp/my-log"
99+
```
100+
101+
Moreover, users can set the `terminationMessagePolicy` field of a Container for
102+
further customization. This field defaults to "`File`" which means the termination
103+
messages are retrieved only from the termination message file. By setting the
104+
`terminationMessagePolicy` to "`FallbackToLogsOnError`", you can tell Kubernetes
105+
to use the last chunk of container log output if the termination message file
106+
is empty and the container exited with an error. The log output is limited to
107+
2048 bytes or 80 lines, whichever is smaller.
97108

98109
{% endcapture %}
99110

0 commit comments

Comments
 (0)