Document terminationMessagePolicy

This commit is contained in:
Qiming Teng
2017-11-13 11:34:02 +08:00
parent f7ca5c7a52
commit a7c8e8cce6
@@ -75,25 +75,36 @@ only the termination message:
{% raw %} kubectl get pod termination-demo -o go-template="{{range .status.containerStatuses}}{{.lastState.terminated.message}}{{end}}"{% endraw %} {% raw %} kubectl get pod termination-demo -o go-template="{{range .status.containerStatuses}}{{.lastState.terminated.message}}{{end}}"{% endraw %}
``` ```
## Setting the termination log file ## Customizing the termination message
By default Kubernetes retrieves termination messages from Kubernetes retrieves termination messages from the termination message file
`/dev/termination-log`. To change this to a different file, specified in the `terminationMessagePath` field of a Container, which as a default
specify a `terminationMessagePath` field for your Container. value of `/dev/termination-log`. By customizing this field, you can tell Kubernetes
to use a different file. Kubernetes use the contents from the specified file to
populate the Container's status message on both success and failure.
For example, suppose your Container writes termination messages to In the following example, the container writes termination messages to
`/tmp/my-log`, and you want Kubernetes to retrieve those messages. `/tmp/my-log` for Kubernetes to retrieve:
Set `terminationMessagePath` as shown here:
apiVersion: v1 ```yaml
kind: Pod apiVersion: v1
metadata: kind: Pod
name: msg-path-demo metadata:
spec: name: msg-path-demo
containers: spec:
- name: msg-path-demo-container containers:
image: debian - name: msg-path-demo-container
terminationMessagePath: "/tmp/my-log" image: debian
terminationMessagePath: "/tmp/my-log"
```
Moreover, users can set the `terminationMessagePolicy` field of a Container for
further customization. This field defaults to "`File`" which means the termination
messages are retrieved only from the termination message file. By setting the
`terminationMessagePolicy` to "`FallbackToLogsOnError`", you can tell Kubernetes
to use the last chunk of container log output if the termination message file
is empty and the container exited with an error. The log output is limited to
2048 bytes or 80 lines, whichever is smaller.
{% endcapture %} {% endcapture %}