Skip to content

Commit c4aae88

Browse files
ptuxnasa9084
andauthored
[ja] Translate tasks/debug-application-cluster/debug-application-introspection into Japanese (#30868)
* done * Update content/ja/docs/tasks/debug-application-cluster/debug-application-introspection.md Co-authored-by: nasa9084 <[email protected]> * Update content/ja/docs/tasks/debug-application-cluster/debug-application-introspection.md Co-authored-by: nasa9084 <[email protected]> * Update content/ja/docs/tasks/debug-application-cluster/debug-application-introspection.md Co-authored-by: nasa9084 <[email protected]> * Update content/ja/docs/tasks/debug-application-cluster/debug-application-introspection.md Co-authored-by: nasa9084 <[email protected]> * Update content/ja/docs/tasks/debug-application-cluster/debug-application-introspection.md Co-authored-by: nasa9084 <[email protected]> * Update content/ja/docs/tasks/debug-application-cluster/debug-application-introspection.md Co-authored-by: nasa9084 <[email protected]> * Update content/ja/docs/tasks/debug-application-cluster/debug-application-introspection.md Co-authored-by: nasa9084 <[email protected]> * Update content/ja/docs/tasks/debug-application-cluster/debug-application-introspection.md Co-authored-by: nasa9084 <[email protected]> * Update content/ja/docs/tasks/debug-application-cluster/debug-application-introspection.md Co-authored-by: nasa9084 <[email protected]> * Update content/ja/docs/tasks/debug-application-cluster/debug-application-introspection.md Co-authored-by: nasa9084 <[email protected]> * Update content/ja/docs/tasks/debug-application-cluster/debug-application-introspection.md Co-authored-by: nasa9084 <[email protected]> * Update content/ja/docs/tasks/debug-application-cluster/debug-application-introspection.md Co-authored-by: nasa9084 <[email protected]> * Update content/ja/docs/tasks/debug-application-cluster/debug-application-introspection.md Co-authored-by: nasa9084 <[email protected]> * Update content/ja/docs/tasks/debug-application-cluster/debug-application-introspection.md Co-authored-by: nasa9084 <[email protected]> * Update content/ja/docs/tasks/debug-application-cluster/debug-application-introspection.md Co-authored-by: nasa9084 <[email protected]> * Update content/ja/docs/tasks/debug-application-cluster/debug-application-introspection.md Co-authored-by: nasa9084 <[email protected]> * Update content/ja/docs/tasks/debug-application-cluster/debug-application-introspection.md Co-authored-by: nasa9084 <[email protected]> * Update content/ja/docs/tasks/debug-application-cluster/debug-application-introspection.md Co-authored-by: nasa9084 <[email protected]> Co-authored-by: nasa9084 <[email protected]>
1 parent 16c4d45 commit c4aae88

File tree

1 file changed

+399
-0
lines changed

1 file changed

+399
-0
lines changed
Lines changed: 399 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,399 @@
1+
---
2+
content_type: concept
3+
title: アプリケーションの自己観察とデバッグ
4+
---
5+
6+
<!-- overview -->
7+
8+
アプリケーションが稼働すると、必然的にその問題をデバッグする必要が出てきます。
9+
先に、`kubectl get pods`を使って、Podの簡単なステータス情報を取得する方法を説明しました。
10+
しかし、アプリケーションに関するより多くの情報を取得する方法がいくつかあります。
11+
12+
<!-- body -->
13+
14+
## `kubectl describe pod`を使ってpodの詳細を取得
15+
16+
この例では、先ほどの例と同様に、Deploymentを使用して2つのpodを作成します。
17+
18+
{{< codenew file="application/nginx-with-request.yaml" >}}
19+
20+
以下のコマンドを実行して、Deploymentを作成します:
21+
22+
```shell
23+
kubectl apply -f https://k8s.io/examples/application/nginx-with-request.yaml
24+
```
25+
26+
```none
27+
deployment.apps/nginx-deployment created
28+
```
29+
30+
以下のコマンドでPodの状態を確認します:
31+
32+
```shell
33+
kubectl get pods
34+
```
35+
36+
```none
37+
NAME READY STATUS RESTARTS AGE
38+
nginx-deployment-1006230814-6winp 1/1 Running 0 11s
39+
nginx-deployment-1006230814-fmgu3 1/1 Running 0 11s
40+
```
41+
42+
`kubectl describe pod`を使うと、これらのPodについてより多くの情報を得ることができます。
43+
例えば:
44+
45+
```shell
46+
kubectl describe pod nginx-deployment-1006230814-6winp
47+
```
48+
49+
```none
50+
Name: nginx-deployment-1006230814-6winp
51+
Namespace: default
52+
Node: kubernetes-node-wul5/10.240.0.9
53+
Start Time: Thu, 24 Mar 2016 01:39:49 +0000
54+
Labels: app=nginx,pod-template-hash=1006230814
55+
Annotations: kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicaSet","namespace":"default","name":"nginx-deployment-1956810328","uid":"14e607e7-8ba1-11e7-b5cb-fa16" ...
56+
Status: Running
57+
IP: 10.244.0.6
58+
Controllers: ReplicaSet/nginx-deployment-1006230814
59+
Containers:
60+
nginx:
61+
Container ID: docker://90315cc9f513c724e9957a4788d3e625a078de84750f244a40f97ae355eb1149
62+
Image: nginx
63+
Image ID: docker://6f62f48c4e55d700cf3eb1b5e33fa051802986b77b874cc351cce539e5163707
64+
Port: 80/TCP
65+
QoS Tier:
66+
cpu: Guaranteed
67+
memory: Guaranteed
68+
Limits:
69+
cpu: 500m
70+
memory: 128Mi
71+
Requests:
72+
memory: 128Mi
73+
cpu: 500m
74+
State: Running
75+
Started: Thu, 24 Mar 2016 01:39:51 +0000
76+
Ready: True
77+
Restart Count: 0
78+
Environment: <none>
79+
Mounts:
80+
/var/run/secrets/kubernetes.io/serviceaccount from default-token-5kdvl (ro)
81+
Conditions:
82+
Type Status
83+
Initialized True
84+
Ready True
85+
PodScheduled True
86+
Volumes:
87+
default-token-4bcbi:
88+
Type: Secret (a volume populated by a Secret)
89+
SecretName: default-token-4bcbi
90+
Optional: false
91+
QoS Class: Guaranteed
92+
Node-Selectors: <none>
93+
Tolerations: <none>
94+
Events:
95+
FirstSeen LastSeen Count From SubobjectPath Type Reason Message
96+
--------- -------- ----- ---- ------------- -------- ------ -------
97+
54s 54s 1 {default-scheduler } Normal Scheduled Successfully assigned nginx-deployment-1006230814-6winp to kubernetes-node-wul5
98+
54s 54s 1 {kubelet kubernetes-node-wul5} spec.containers{nginx} Normal Pulling pulling image "nginx"
99+
53s 53s 1 {kubelet kubernetes-node-wul5} spec.containers{nginx} Normal Pulled Successfully pulled image "nginx"
100+
53s 53s 1 {kubelet kubernetes-node-wul5} spec.containers{nginx} Normal Created Created container with docker id 90315cc9f513
101+
53s 53s 1 {kubelet kubernetes-node-wul5} spec.containers{nginx} Normal Started Started container with docker id 90315cc9f513
102+
```
103+
104+
ここでは、コンテナ(複数可)とPodに関する構成情報(ラベル、リソース要件など)や、コンテナ(複数可)とPodに関するステータス情報(状態、準備状況、再起動回数、イベントなど)を確認できます。
105+
106+
コンテナの状態は、Waiting(待機中)、Running(実行中)、Terminated(終了)のいずれかです。状態に応じて、追加の情報が提供されます。ここでは、Running状態のコンテナについて、コンテナがいつ開始されたかが表示されています。
107+
108+
Readyは、コンテナが最後のReadiness Probeに合格したかどうかを示す。(この場合、コンテナにはReadiness Probeが設定されていません。Readiness Probeが設定されていない場合、コンテナは準備が完了した状態であるとみなされます)。
109+
110+
Restart Countは、コンテナが何回再起動されたかを示します。この情報は、再起動ポリシーが「always」に設定されているコンテナのクラッシュループを検出するのに役立ちます。
111+
112+
現在、Podに関連する条件は、二値のReady条件のみです。これは、Podがリクエストに対応可能であり、マッチングするすべてのサービスのロードバランシングプールに追加されるべきであることを示します。
113+
114+
最後に、Podに関連する最近のイベントのログが表示されます。このシステムでは、複数の同一イベントを圧縮して、最初に見られた時刻と最後に見られた時刻、そして見られた回数を示します。"From"はイベントを記録しているコンポーネントを示し、"SubobjectPath"はどのオブジェクト(例: Pod内のコンテナ)が参照されているかを示し、"Reason"と "Message"は何が起こったかを示しています。
115+
116+
## 例: Pending Podsのデバッグ
117+
118+
イベントを使って検出できる一般的なシナリオは、どのノードにも収まらないPodを作成した場合です。例えば、Podがどのノードでも空いている以上のリソースを要求したり、どのノードにもマッチしないラベルセレクターを指定したりする場合です。例えば、各(仮想)マシンが1つのCPUを持つ4ノードのクラスター上で、(2つではなく)5つのレプリカを持ち、500ではなく600ミリコアを要求する前のDeploymentを作成したとします。この場合、Podの1つがスケジュールできなくなります。(なお、各ノードではfluentdやskydnsなどのクラスターアドオンPodが動作しているため、もし1000ミリコアを要求した場合、どのPodもスケジュールできなくなります)
119+
120+
```shell
121+
kubectl get pods
122+
```
123+
124+
```none
125+
NAME READY STATUS RESTARTS AGE
126+
nginx-deployment-1006230814-6winp 1/1 Running 0 7m
127+
nginx-deployment-1006230814-fmgu3 1/1 Running 0 7m
128+
nginx-deployment-1370807587-6ekbw 1/1 Running 0 1m
129+
nginx-deployment-1370807587-fg172 0/1 Pending 0 1m
130+
nginx-deployment-1370807587-fz9sd 0/1 Pending 0 1m
131+
```
132+
133+
nginx-deployment-1370807587-fz9sdのPodが実行されていない理由を調べるには、保留中のPodに対して`kubectl describe pod`を使用し、そのイベントを見てみましょう
134+
135+
```shell
136+
kubectl describe pod nginx-deployment-1370807587-fz9sd
137+
```
138+
139+
```none
140+
Name: nginx-deployment-1370807587-fz9sd
141+
Namespace: default
142+
Node: /
143+
Labels: app=nginx,pod-template-hash=1370807587
144+
Status: Pending
145+
IP:
146+
Controllers: ReplicaSet/nginx-deployment-1370807587
147+
Containers:
148+
nginx:
149+
Image: nginx
150+
Port: 80/TCP
151+
QoS Tier:
152+
memory: Guaranteed
153+
cpu: Guaranteed
154+
Limits:
155+
cpu: 1
156+
memory: 128Mi
157+
Requests:
158+
cpu: 1
159+
memory: 128Mi
160+
Environment Variables:
161+
Volumes:
162+
default-token-4bcbi:
163+
Type: Secret (a volume populated by a Secret)
164+
SecretName: default-token-4bcbi
165+
Events:
166+
FirstSeen LastSeen Count From SubobjectPath Type Reason Message
167+
--------- -------- ----- ---- ------------- -------- ------ -------
168+
1m 48s 7 {default-scheduler } Warning FailedScheduling pod (nginx-deployment-1370807587-fz9sd) failed to fit in any node
169+
fit failure on node (kubernetes-node-6ta5): Node didn't have enough resource: CPU, requested: 1000, used: 1420, capacity: 2000
170+
fit failure on node (kubernetes-node-wul5): Node didn't have enough resource: CPU, requested: 1000, used: 1100, capacity: 2000
171+
```
172+
173+
ここでは、理由 `FailedScheduling` (およびその他の理由)でPodのスケジュールに失敗したという、スケジューラーによって生成されたイベントを見ることができます。このメッセージは、どのノードでもPodに十分なリソースがなかったことを示しています。
174+
175+
この状況を修正するには、`kubectl scale`を使用して、4つ以下のレプリカを指定するようにDeploymentを更新します。(あるいは、1つのPodを保留にしたままにしておいても害はありません。)
176+
177+
`kubectl describe pod`の最後に出てきたようなイベントは、etcdに永続化され、クラスターで何が起こっているかについての高レベルの情報を提供します。
178+
179+
すべてのイベントをリストアップするには、次のようにします:
180+
181+
182+
```shell
183+
kubectl get events
184+
```
185+
186+
しかし、イベントは名前空間に所属することを忘れてはいけません。つまり、名前空間で管理されているオブジェクトのイベントに興味がある場合(例: 名前空間 `my-namespace`のPods で何が起こったか)、コマンドに名前空間を明示的に指定する必要があります。
187+
188+
```shell
189+
kubectl get events --namespace=my-namespace
190+
```
191+
192+
すべての名前空間からのイベントを見るには、`--all-namespaces` 引数を使用できます。
193+
194+
`kubectl describe pod`に加えて、(`kubectl get pod` で提供される以上の)Podに関する追加情報を得るためのもう一つの方法は、`-o yaml`出力形式フラグを `kubectl get pod`に渡すことです。これにより、`kubectl describe pod`よりもさらに多くの情報、つまりシステムが持っているPodに関するすべての情報をYAML形式で得ることができます。ここでは、アノテーション(Kubernetesのシステムコンポーネントが内部的に使用している、ラベル制限のないキーバリューのメタデータ)、再起動ポリシー、ポート、ボリュームなどが表示されます。
195+
196+
```shell
197+
kubectl get pod nginx-deployment-1006230814-6winp -o yaml
198+
```
199+
200+
```yaml
201+
apiVersion: v1
202+
kind: Pod
203+
metadata:
204+
annotations:
205+
kubernetes.io/created-by: |
206+
{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicaSet","namespace":"default","name":"nginx-deployment-1006230814","uid":"4c84c175-f161-11e5-9a78-42010af00005","apiVersion":"extensions","resourceVersion":"133434"}}
207+
creationTimestamp: 2016-03-24T01:39:50Z
208+
generateName: nginx-deployment-1006230814-
209+
labels:
210+
app: nginx
211+
pod-template-hash: "1006230814"
212+
name: nginx-deployment-1006230814-6winp
213+
namespace: default
214+
resourceVersion: "133447"
215+
uid: 4c879808-f161-11e5-9a78-42010af00005
216+
spec:
217+
containers:
218+
- image: nginx
219+
imagePullPolicy: Always
220+
name: nginx
221+
ports:
222+
- containerPort: 80
223+
protocol: TCP
224+
resources:
225+
limits:
226+
cpu: 500m
227+
memory: 128Mi
228+
requests:
229+
cpu: 500m
230+
memory: 128Mi
231+
terminationMessagePath: /dev/termination-log
232+
volumeMounts:
233+
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
234+
name: default-token-4bcbi
235+
readOnly: true
236+
dnsPolicy: ClusterFirst
237+
nodeName: kubernetes-node-wul5
238+
restartPolicy: Always
239+
securityContext: {}
240+
serviceAccount: default
241+
serviceAccountName: default
242+
terminationGracePeriodSeconds: 30
243+
volumes:
244+
- name: default-token-4bcbi
245+
secret:
246+
secretName: default-token-4bcbi
247+
status:
248+
conditions:
249+
- lastProbeTime: null
250+
lastTransitionTime: 2016-03-24T01:39:51Z
251+
status: "True"
252+
type: Ready
253+
containerStatuses:
254+
- containerID: docker://90315cc9f513c724e9957a4788d3e625a078de84750f244a40f97ae355eb1149
255+
image: nginx
256+
imageID: docker://6f62f48c4e55d700cf3eb1b5e33fa051802986b77b874cc351cce539e5163707
257+
lastState: {}
258+
name: nginx
259+
ready: true
260+
restartCount: 0
261+
state:
262+
running:
263+
startedAt: 2016-03-24T01:39:51Z
264+
hostIP: 10.240.0.9
265+
phase: Running
266+
podIP: 10.244.0.6
267+
startTime: 2016-03-24T01:39:49Z
268+
```
269+
270+
## 例: ダウン/到達不可能なノードのデバッグ
271+
272+
例えば、ノード上で動作しているPodのおかしな挙動に気付いたり、Podがノード上でスケジュールされない原因を探ったりと、デバッグ時にノードのステータスを見ることが有用な場合があります。Podと同様に、`kubectl describe node`や`kubectl get node -o yaml`を使ってノードの詳細情報を取得することができます。例えば、ノードがダウンした場合(ネットワークから切断された、またはkubeletが死んで再起動しないなど)に表示される内容は以下の通りです。ノードがNotReadyであることを示すイベントに注目してください。また、Podが実行されなくなっていることにも注目してください(NotReady状態が5分続くと、Podは退避されます)。
273+
274+
```shell
275+
kubectl get nodes
276+
```
277+
278+
```none
279+
NAME STATUS ROLES AGE VERSION
280+
kubernetes-node-861h NotReady <none> 1h v1.13.0
281+
kubernetes-node-bols Ready <none> 1h v1.13.0
282+
kubernetes-node-st6x Ready <none> 1h v1.13.0
283+
kubernetes-node-unaj Ready <none> 1h v1.13.0
284+
```
285+
286+
```shell
287+
kubectl describe node kubernetes-node-861h
288+
```
289+
290+
```none
291+
Name: kubernetes-node-861h
292+
Role
293+
Labels: kubernetes.io/arch=amd64
294+
kubernetes.io/os=linux
295+
kubernetes.io/hostname=kubernetes-node-861h
296+
Annotations: node.alpha.kubernetes.io/ttl=0
297+
volumes.kubernetes.io/controller-managed-attach-detach=true
298+
Taints: <none>
299+
CreationTimestamp: Mon, 04 Sep 2017 17:13:23 +0800
300+
Phase:
301+
Conditions:
302+
Type Status LastHeartbeatTime LastTransitionTime Reason Message
303+
---- ------ ----------------- ------------------ ------ -------
304+
OutOfDisk Unknown Fri, 08 Sep 2017 16:04:28 +0800 Fri, 08 Sep 2017 16:20:58 +0800 NodeStatusUnknown Kubelet stopped posting node status.
305+
MemoryPressure Unknown Fri, 08 Sep 2017 16:04:28 +0800 Fri, 08 Sep 2017 16:20:58 +0800 NodeStatusUnknown Kubelet stopped posting node status.
306+
DiskPressure Unknown Fri, 08 Sep 2017 16:04:28 +0800 Fri, 08 Sep 2017 16:20:58 +0800 NodeStatusUnknown Kubelet stopped posting node status.
307+
Ready Unknown Fri, 08 Sep 2017 16:04:28 +0800 Fri, 08 Sep 2017 16:20:58 +0800 NodeStatusUnknown Kubelet stopped posting node status.
308+
Addresses: 10.240.115.55,104.197.0.26
309+
Capacity:
310+
cpu: 2
311+
hugePages: 0
312+
memory: 4046788Ki
313+
pods: 110
314+
Allocatable:
315+
cpu: 1500m
316+
hugePages: 0
317+
memory: 1479263Ki
318+
pods: 110
319+
System Info:
320+
Machine ID: 8e025a21a4254e11b028584d9d8b12c4
321+
System UUID: 349075D1-D169-4F25-9F2A-E886850C47E3
322+
Boot ID: 5cd18b37-c5bd-4658-94e0-e436d3f110e0
323+
Kernel Version: 4.4.0-31-generic
324+
OS Image: Debian GNU/Linux 8 (jessie)
325+
Operating System: linux
326+
Architecture: amd64
327+
Container Runtime Version: docker://1.12.5
328+
Kubelet Version: v1.6.9+a3d1dfa6f4335
329+
Kube-Proxy Version: v1.6.9+a3d1dfa6f4335
330+
ExternalID: 15233045891481496305
331+
Non-terminated Pods: (9 in total)
332+
Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits
333+
--------- ---- ------------ ---------- --------------- -------------
334+
......
335+
Allocated resources:
336+
(Total limits may be over 100 percent, i.e., overcommitted.)
337+
CPU Requests CPU Limits Memory Requests Memory Limits
338+
------------ ---------- --------------- -------------
339+
900m (60%) 2200m (146%) 1009286400 (66%) 5681286400 (375%)
340+
Events: <none>
341+
```
342+
343+
```shell
344+
kubectl get node kubernetes-node-861h -o yaml
345+
```
346+
347+
```yaml
348+
apiVersion: v1
349+
kind: Node
350+
metadata:
351+
creationTimestamp: 2015-07-10T21:32:29Z
352+
labels:
353+
kubernetes.io/hostname: kubernetes-node-861h
354+
name: kubernetes-node-861h
355+
resourceVersion: "757"
356+
uid: 2a69374e-274b-11e5-a234-42010af0d969
357+
spec:
358+
externalID: "15233045891481496305"
359+
podCIDR: 10.244.0.0/24
360+
providerID: gce://striped-torus-760/us-central1-b/kubernetes-node-861h
361+
status:
362+
addresses:
363+
- address: 10.240.115.55
364+
type: InternalIP
365+
- address: 104.197.0.26
366+
type: ExternalIP
367+
capacity:
368+
cpu: "1"
369+
memory: 3800808Ki
370+
pods: "100"
371+
conditions:
372+
- lastHeartbeatTime: 2015-07-10T21:34:32Z
373+
lastTransitionTime: 2015-07-10T21:35:15Z
374+
reason: Kubelet stopped posting node status.
375+
status: Unknown
376+
type: Ready
377+
nodeInfo:
378+
bootID: 4e316776-b40d-4f78-a4ea-ab0d73390897
379+
containerRuntimeVersion: docker://Unknown
380+
kernelVersion: 3.16.0-0.bpo.4-amd64
381+
kubeProxyVersion: v0.21.1-185-gffc5a86098dc01
382+
kubeletVersion: v0.21.1-185-gffc5a86098dc01
383+
machineID: ""
384+
osImage: Debian GNU/Linux 7 (wheezy)
385+
systemUUID: ABE5F6B4-D44B-108B-C46A-24CCE16C8B6E
386+
```
387+
388+
389+
390+
## {{% heading "whatsnext" %}}
391+
392+
以下のような追加のデバッグツールについて学びます:
393+
394+
* [Logging](/docs/concepts/cluster-administration/logging/)
395+
* [Monitoring](/docs/tasks/debug-application-cluster/resource-usage-monitoring/)
396+
* [Getting into containers via `exec`](/docs/tasks/debug-application-cluster/get-shell-running-container/)
397+
* [Connecting to containers via proxies](/docs/tasks/extend-kubernetes/http-proxy-access-api/)
398+
* [Connecting to containers via port forwarding](/docs/tasks/access-application-cluster/port-forward-access-application-cluster/)
399+
* [Inspect Kubernetes node with crictl](/docs/tasks/debug-application-cluster/crictl/)

0 commit comments

Comments
 (0)