Skip to content

Commit c799322

Browse files
authored
Merge pull request #41705 from windsonsea/debugy
[zh] sync /debug-application/debug-pods.md
2 parents a1d18a9 + a074360 commit c799322

File tree

1 file changed

+56
-49
lines changed

1 file changed

+56
-49
lines changed

content/zh-cn/docs/tasks/debug/debug-application/debug-pods.md

Lines changed: 56 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ title: 调试 Pod
33
content_type: task
44
weight: 10
55
---
6-
76
<!--
87
reviewers:
98
- mikedanese
@@ -16,23 +15,21 @@ weight: 10
1615
<!-- overview -->
1716

1817
<!--
19-
This guide is to help users debug applications that are deployed into Kubernetes and not behaving correctly.
20-
This is *not* a guide for people who want to debug their cluster. For that you should check out
21-
[this guide](/docs/tasks/debug/debug-cluster).
18+
This guide is to help users debug applications that are deployed into Kubernetes
19+
and not behaving correctly. This is *not* a guide for people who want to debug their cluster.
20+
For that you should check out [this guide](/docs/tasks/debug/debug-cluster).
2221
-->
23-
2422
本指南帮助用户调试那些部署到 Kubernetes 上后没有正常运行的应用。
2523
本指南 **并非** 指导用户如何调试集群。
2624
如果想调试集群的话,请参阅[这里](/zh-cn/docs/tasks/debug/debug-cluster)
2725

28-
2926
<!-- body -->
3027

3128
<!--
3229
## Diagnosing the problem
3330
34-
The first step in troubleshooting is triage. What is the problem? Is it your Pods, your Replication Controller or
35-
your Service?
31+
The first step in troubleshooting is triage. What is the problem?
32+
Is it your Pods, your Replication Controller or your Service?
3633
3734
* [Debugging Pods](#debugging-pods)
3835
* [Debugging Replication Controllers](#debugging-replication-controllers)
@@ -49,7 +46,8 @@ your Service?
4946
<!--
5047
### Debugging Pods
5148
52-
The first step in debugging a Pod is taking a look at it. Check the current state of the Pod and recent events with the following command:
49+
The first step in debugging a Pod is taking a look at it. Check the current
50+
state of the Pod and recent events with the following command:
5351
-->
5452
### 调试 Pod {#debugging-pods}
5553

@@ -60,7 +58,8 @@ kubectl describe pods ${POD_NAME}
6058
```
6159

6260
<!--
63-
Look at the state of the containers in the pod. Are they all `Running`? Have there been recent restarts?
61+
Look at the state of the containers in the pod. Are they all `Running`?
62+
Have there been recent restarts?
6463
6564
Continue debugging depending on the state of the pods.
6665
-->
@@ -71,32 +70,35 @@ Continue debugging depending on the state of the pods.
7170
<!--
7271
#### My pod stays pending
7372
74-
If a Pod is stuck in `Pending` it means that it can not be scheduled onto a node. Generally this is because
75-
there are insufficient resources of one type or another that prevent scheduling. Look at the output of the
76-
`kubectl describe ...` command above. There should be messages from the scheduler about why it can not schedule
77-
your pod. Reasons include:
73+
If a Pod is stuck in `Pending` it means that it can not be scheduled onto a node.
74+
Generally this is because there are insufficient resources of one type or another
75+
that prevent scheduling. Look at the output of the `kubectl describe ...` command above.
76+
There should be messages from the scheduler about why it can not schedule your pod.
77+
Reasons include:
7878
-->
7979
#### Pod 停滞在 Pending 状态 {#my-pod-stays-pending}
8080

81-
如果一个 Pod 停滞在 `Pending` 状态,表示 Pod 没有被调度到节点上。通常这是因为
82-
某种类型的资源不足导致无法调度
81+
如果一个 Pod 停滞在 `Pending` 状态,表示 Pod 没有被调度到节点上。
82+
通常这是因为某种类型的资源不足导致无法调度
8383
查看上面的 `kubectl describe ...` 命令的输出,其中应该显示了为什么没被调度的原因。
8484
常见原因如下:
8585

8686
<!--
87-
* **You don't have enough resources**: You may have exhausted the supply of CPU or Memory in your cluster, in this case
88-
you need to delete Pods, adjust resource requests, or add new nodes to your cluster. See
89-
[Compute Resources document](/docs/concepts/configuration/manage-resources-containers/) for more information.
90-
91-
* **You are using `hostPort`**: When you bind a Pod to a `hostPort` there are a limited number of places that pod can be
92-
scheduled. In most cases, `hostPort` is unnecessary, try using a Service object to expose your Pod. If you do require
93-
`hostPort` then you can only schedule as many Pods as there are nodes in your Kubernetes cluster.
87+
* **You don't have enough resources**: You may have exhausted the supply of CPU
88+
or Memory in your cluster, in this case you need to delete Pods, adjust resource
89+
requests, or add new nodes to your cluster. See [Compute Resources document](/docs/concepts/configuration/manage-resources-containers/)
90+
for more information.
91+
92+
* **You are using `hostPort`**: When you bind a Pod to a `hostPort` there are a
93+
limited number of places that pod can be scheduled. In most cases, `hostPort`
94+
is unnecessary, try using a Service object to expose your Pod. If you do require
95+
`hostPort` then you can only schedule as many Pods as there are nodes in your Kubernetes cluster.
9496
-->
95-
* **资源不足**:
97+
* **资源不足**
9698
你可能耗尽了集群上所有的 CPU 或内存。此时,你需要删除 Pod、调整资源请求或者为集群添加节点。
9799
更多信息请参阅[计算资源文档](/zh-cn/docs/concepts/configuration/manage-resources-containers/)
98100

99-
* **使用了 `hostPort`**:
101+
* **使用了 `hostPort`**
100102
如果绑定 Pod 到 `hostPort`,那么能够运行该 Pod 的节点就有限了。
101103
多数情况下,`hostPort` 是非必要的,而应该采用 Service 对象来暴露 Pod。
102104
如果确实需要使用 `hostPort`,那么集群中节点的个数就是所能创建的 Pod
@@ -105,8 +107,10 @@ scheduled. In most cases, `hostPort` is unnecessary, try using a Service object
105107
<!--
106108
#### My pod stays waiting
107109
108-
If a Pod is stuck in the `Waiting` state, then it has been scheduled to a worker node, but it can't run on that machine.
109-
Again, the information from `kubectl describe ...` should be informative. The most common cause of `Waiting` pods is a failure to pull the image. There are three things to check:
110+
If a Pod is stuck in the `Waiting` state, then it has been scheduled to a worker node,
111+
but it can't run on that machine. Again, the information from `kubectl describe ...`
112+
should be informative. The most common cause of `Waiting` pods is a failure to pull the image.
113+
There are three things to check:
110114
111115
* Make sure that you have the name of the image correct.
112116
* Have you pushed the image to the registry?
@@ -119,20 +123,21 @@ Again, the information from `kubectl describe ...` should be informative. The m
119123
同样,`kubectl describe ...` 命令的输出可能很有用。
120124
`Waiting` 状态的最常见原因是拉取镜像失败。要检查的有三个方面:
121125

122-
* 确保镜像名字拼写正确
123-
* 确保镜像已被推送到镜像仓库
126+
* 确保镜像名字拼写正确
127+
* 确保镜像已被推送到镜像仓库
124128
* 尝试手动是否能拉取镜像。例如,如果你在你的 PC 上使用 Docker,请运行 `docker pull <镜像>`
125129

126130
<!--
127131
#### My pod is crashing or otherwise unhealthy
128132
129-
Once your pod has been scheduled, the methods described in [Debug Running Pods](
130-
/docs/tasks/debug/debug-application/debug-running-pod/) are available for debugging.
133+
Once your pod has been scheduled, the methods described in
134+
[Debug Running Pods](/docs/tasks/debug/debug-application/debug-running-pod/)
135+
are available for debugging.
131136
-->
132137
#### Pod 处于 Crashing 或别的不健康状态 {#my-pod-is-crashing-or-otherwise-unhealthy}
133138

134-
一旦 Pod 被调度,就可以采用
135-
[调试运行中的 Pod](/zh-cn/docs/tasks/debug/debug-application/debug-running-pod/)
139+
一旦 Pod 被调度,
140+
就可以采用[调试运行中的 Pod](/zh-cn/docs/tasks/debug/debug-application/debug-running-pod/)
136141
中的方法来进一步调试。
137142

138143
<!--
@@ -160,7 +165,7 @@ If you misspelled `command` as `commnd` then will give an error like this:
160165
-->
161166
可以做的第一件事是删除你的 Pod,并尝试带有 `--validate` 选项重新创建。
162167
例如,运行 `kubectl apply --validate -f mypod.yaml`
163-
如果 `command` 被误拼成 `commnd`,你将会看到下面的错误信息:
168+
如果 `command` 被误拼成 `commnd`,你将会看到下面的错误信息:
164169

165170
```shell
166171
I0805 10:43:25.129850 46757 schema.go:126] unknown field: commnd
@@ -175,9 +180,9 @@ The next thing to check is whether the pod on the apiserver
175180
matches the pod you meant to create (e.g. in a yaml file on your local machine).
176181
For example, run `kubectl get pods/mypod -o yaml > mypod-on-apiserver.yaml` and then
177182
manually compare the original pod description, `mypod.yaml` with the one you got
178-
back from apiserver, `mypod-on-apiserver.yaml`. There will typically be some
179-
lines on the "apiserver" version that are not on the original version. This is
180-
expected. However, if there are lines on the original that are not on the apiserver
183+
back from apiserver, `mypod-on-apiserver.yaml`. There will typically be some
184+
lines on the "apiserver" version that are not on the original version. This is
185+
expected. However, if there are lines on the original that are not on the apiserver
181186
version, then this may indicate a problem with your pod spec.
182187
-->
183188
接下来就要检查的是 API 服务器上的 Pod 与你所期望创建的是否匹配
@@ -191,11 +196,12 @@ Pod 规约是有问题的。
191196
<!--
192197
### Debugging Replication Controllers
193198
194-
Replication controllers are fairly straightforward. They can either create Pods or they can't. If they can't
195-
create pods, then please refer to the [instructions above](#debugging-pods) to debug your pods.
199+
Replication controllers are fairly straightforward. They can either create Pods or they can't.
200+
If they can't create pods, then please refer to the
201+
[instructions above](#debugging-pods) to debug your pods.
196202
197-
You can also use `kubectl describe rc ${CONTROLLER_NAME}` to introspect events related to the replication
198-
controller.
203+
You can also use `kubectl describe rc ${CONTROLLER_NAME}` to introspect events
204+
related to the replication controller.
199205
-->
200206
### 调试副本控制器 {#debugging-replication-controllers}
201207

@@ -207,10 +213,11 @@ controller.
207213
<!--
208214
### Debugging Services
209215
210-
Services provide load balancing across a set of pods. There are several common problems that can make Services
216+
Services provide load balancing across a set of pods. There are several common problems that can make Services
211217
not work properly. The following instructions should help debug Service problems.
212218
213-
First, verify that there are endpoints for the service. For every Service object, the apiserver makes an `endpoints` resource available.
219+
First, verify that there are endpoints for the service. For every Service object,
220+
the apiserver makes an `endpoints` resource available.
214221
215222
You can view this resource with:
216223
-->
@@ -241,8 +248,8 @@ IP addresses in the Service's endpoints.
241248
<!--
242249
#### My service is missing endpoints
243250
244-
If you are missing endpoints, try listing pods using the labels that Service uses. Imagine that you have
245-
a Service where the labels are:
251+
If you are missing endpoints, try listing pods using the labels that Service uses.
252+
Imagine that you have a Service where the labels are:
246253
-->
247254
#### 服务缺少 Endpoints {#my-service-is-missing-endpoints}
248255

@@ -263,7 +270,8 @@ You can use:
263270
kubectl get pods --selector=name=nginx,type=frontend
264271
```
265272

266-
to list pods that match this selector. Verify that the list matches the Pods that you expect to provide your Service.
273+
to list pods that match this selector. Verify that the list matches the Pods that you expect to provide your Service.
274+
Verify that the pod's `containerPort` matches up with the Service's `targetPort`
267275
-->
268276
你可以使用如下命令列出与选择算符相匹配的 Pod,并验证这些 Pod 是否归属于创建的服务:
269277

@@ -298,8 +306,7 @@ You may also visit [troubleshooting document](/docs/tasks/debug/) for more infor
298306
-->
299307
如果上述方法都不能解决你的问题,
300308
请按照[调试 Service 文档](/zh-cn/docs/tasks/debug/debug-application/debug-service/)中的介绍,
301-
确保你的 `Service` 处于 Running ,有 `Endpoints` 被创建,`Pod` 真的在提供服务;
302-
DNS 服务已配置并正常工作,iptables 规则也以安装并且 `kube-proxy` 也没有异常行为。
309+
确保你的 `Service` 处于 Running 状态,有 `Endpoints` 被创建,`Pod` 真的在提供服务;
310+
DNS 服务已配置并正常工作,iptables 规则也已安装并且 `kube-proxy` 也没有异常行为。
303311

304312
你也可以访问[故障排查文档](/zh-cn/docs/tasks/debug/)来获取更多信息。
305-

0 commit comments

Comments
 (0)