Unify debug pod docs and update for kubectl alpha debug (#19093)

Co-Authored-By: Tim Bannister <tim@scalefactory.com>

Co-authored-by: Tim Bannister <tim@scalefactory.com>
This commit is contained in:
Lee Verberne
2020-03-16 16:02:42 +01:00
committed by GitHub
parent e752b37bf0
commit 46bda9606a
4 changed files with 211 additions and 101 deletions
@@ -93,40 +93,9 @@ worker node, but it can't run on that machine. Again, the information from
### My pod is crashing or otherwise unhealthy
First, take a look at the logs of the current container:
Once your pod has been scheduled, the methods described in [Debug Running Pods](
/docs/tasks/debug-application-cluster/debug-running-pods/) are available for debugging.
```shell
kubectl logs ${POD_NAME} ${CONTAINER_NAME}
```
If your container has previously crashed, you can access the previous
container's crash log with:
```shell
kubectl logs --previous ${POD_NAME} ${CONTAINER_NAME}
```
Alternately, you can run commands inside that container with `exec`:
```shell
kubectl exec ${POD_NAME} -c ${CONTAINER_NAME} -- ${CMD} ${ARG1} ${ARG2} ... ${ARGN}
```
{{< note >}}
`-c ${CONTAINER_NAME}` is optional. You can omit it for pods that
only contain a single container.
{{< /note >}}
As an example, to look at the logs from a running Cassandra pod, you might run:
```shell
kubectl exec cassandra -- cat /var/log/cassandra/system.log
```
If your cluster enabled it, you can also try adding an [ephemeral container](/docs/concepts/workloads/pods/ephemeral-containers/) into the existing pod. You can use the new temporary container to run arbitrary commands, for example, to diagnose problems inside the Pod. See the page about [ephemeral container](/docs/concepts/workloads/pods/ephemeral-containers/) for more details, including feature availability.
If none of these approaches work, you can find the host machine that the pod is
running on and SSH into that host.
## Debugging ReplicationControllers