> For the complete documentation index, see [llms.txt](https://doc.cncf.vip/kubernetes-handbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.cncf.vip/kubernetes-handbook/fu-lu/debug-kubernetes-services.md).

# Kubernetes 中的应用故障排查

* 查看某个资源的定义和用法

```bash
kubectl explain
```

* 查看Pod的状态

```bash
kubectl get pods
kubectl describe pods my-pod
```

* 监控Pod状态的变化

```bash
kubectl get pod -w
```

可以看到一个 namespace 中所有的 pod 的 phase 变化，请参考 [Pod 的生命周期](/kubernetes-handbook/gai-nian-yu-yuan-li/pod-state-and-lifecycle/pod-lifecycle.md)。

* 查看 Pod 的日志

```bash
kubectl logs my-pod
kubectl logs my-pod -c my-container
kubectl logs -f my-pod
kubectl logs -f my-pod -c my-container
```

`-f` 参数可以 follow 日志输出。

* 交互式 debug

```bash
kubectl exec my-pod -it /bin/bash
kubectl top pod POD_NAME --containers
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.cncf.vip/kubernetes-handbook/fu-lu/debug-kubernetes-services.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
