From c746f40d3c9aedaead923b605e1f2d6263741bf8 Mon Sep 17 00:00:00 2001 From: Anthony Yeh Date: Tue, 29 Nov 2016 15:44:48 -0800 Subject: [PATCH] Task: Debugging Init Containers --- _data/tasks.yml | 5 + docs/tasks/index.md | 4 + .../troubleshoot/debug-init-containers.md | 137 ++++++++++++++++++ 3 files changed, 146 insertions(+) create mode 100644 docs/tasks/troubleshoot/debug-init-containers.md diff --git a/_data/tasks.yml b/_data/tasks.yml index 8e5bab4df9..d4f6071bf1 100644 --- a/_data/tasks.yml +++ b/_data/tasks.yml @@ -49,3 +49,8 @@ toc: path: /docs/tasks/manage-stateful-set/debugging-a-statefulset/ - title: Force Deleting StatefulSet Pods path: /docs/tasks/manage-stateful-set/delete-pods/ + +- title: Troubleshooting + section: + - title: Debugging Init Containers + path: /docs/tasks/troubleshoot/debug-init-containers/ diff --git a/docs/tasks/index.md b/docs/tasks/index.md index 53231a2e5a..4daee756ca 100644 --- a/docs/tasks/index.md +++ b/docs/tasks/index.md @@ -37,6 +37,10 @@ single thing, typically by giving a short sequence of steps. * [Debugging a StatefulSet](/docs/tasks/manage-stateful-set/debugging-a-statefulset/) * [Force Deleting StatefulSet Pods](/docs/tasks/manage-stateful-set/delete-pods/) +#### Troubleshooting + +* [Debugging Init Containers](/docs/tasks/troubleshoot/debug-init-containers/) + ### What's next If you would like to write a task page, see diff --git a/docs/tasks/troubleshoot/debug-init-containers.md b/docs/tasks/troubleshoot/debug-init-containers.md new file mode 100644 index 0000000000..73267fddd2 --- /dev/null +++ b/docs/tasks/troubleshoot/debug-init-containers.md @@ -0,0 +1,137 @@ +--- +assignees: +- bprashanth +- enisoc +- erictune +- foxish +- janetkuo +- kow3ns +- smarterclayton + +--- + +{% capture overview %} + +This page shows how to investigate problems related to the execution of +Init Containers. + +{% endcapture %} + +{% capture prerequisites %} + +* You should be familiar with the basics of + [Init Containers](/docs/user-guide/pods/init-containers/). +* You should have a [Pod](/docs/user-guide/pods/) you want to debug that uses + Init Containers. The example command lines below refer to the Pod as + `` and the Init Containers as `` and + ``. + +{% endcapture %} + +{% capture steps %} + +### Checking the status of Init Containers + +The Pod status will give you an overview of Init Container execution: + +```shell +kubectl get pod +``` + +For example, a status of `Init:1/2` indicates that one of two Init Containers +has completed successfully: + +``` +NAME READY STATUS RESTARTS AGE + 0/1 Init:1/2 0 7s +``` + +See [Understanding Pod status](#understanding-pod-status) for more examples of +status values and their meanings. + +### Getting details about Init Containers + +You can see detailed information about Init Container execution by running: + +```shell +kubectl describe pod +``` + +For example, a Pod with two Init Containers might show the following: + +``` +Init Containers: + : + Container ID: ... + ... + State: Terminated + Reason: Completed + Exit Code: 0 + Started: ... + Finished: ... + Ready: True + Restart Count: 0 + ... + : + Container ID: ... + ... + State: Waiting + Reason: CrashLoopBackOff + Last State: Terminated + Reason: Error + Exit Code: 1 + Started: ... + Finished: ... + Ready: False + Restart Count: 3 + ... +``` + +You can also access the Init Container statuses programmatically by reading the +`pod.beta.kubernetes.io/init-container-status` annotation on the Pod: + +{% raw %} +```shell +kubectl get pod --template '{{index .metadata.annotations "pod.beta.kubernetes.io/init-container-statuses"}}' +``` +{% endraw %} + +This will return the same information as above, but in raw JSON format. + +### Accessing logs from Init Containers + +You can access logs for an Init Container by passing its Container name along +with the Pod name: + +```shell +kubectl logs -c +``` + +If your Init Container runs a shell script, it helps to enable printing of +commands as they're executed. For example, you can do this in Bash by running +`set -x` at the beginning of the script. + +{% endcapture %} + +{% capture discussion %} + +### Understanding Pod status + +A Pod status beginning with `Init:` summarizes the status of Init Container +execution. The table below describes some example status values that you might +see while debugging Init Containers. + +Status | Meaning +------ | ------- +`Init:N/M` | The Pod has `M` Init Containers, and `N` have completed so far. +`Init:Error` | An Init Container has failed to execute. +`Init:CrashLoopBackOff` | An Init Container has failed repeatedly. + +A Pod with status `Pending` has not yet begun executing Init Containers. +A Pod with status `PodInitializing` or `Running` has already finished executing +Init Containers. + +{% endcapture %} + +{% include templates/task.md %} +