3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

KubernetesのServiceとPodのログを見る

Last updated at Posted at 2020-04-21

Podのログが見たい!

kubectl logs -n [nameSpace] [podName]が基本のコマンドです。

EnvoyがサイドカーとしてPodの中に入っている場合は、
kubectl logs -n [nameSpace] [podName] -c [コンテナ名(アプリ名)]で直接指定。

逆にEnvoyのログが見たい場合は
kubectl logs -n [nameSpace] [podName] -c istio-proxyでサイドカーのEnvoyのログが見える。

Serviceのログが見たい!

例えばIstioのingressGatewayのServiceにトラフィックが届いているのか確認したい場合に使えます。

kubectl logs -n istio-system service/istio-ingressgateway

よくサンプルで使われるbookinfoの場合はこのようになります。

kubectl logs -n default service/productpage

kubectl logsの使えるオプション

  • kubectl logs -f -n [nameSpace] [podName]
    tail -fと同じ挙動。常時流しておきたい場合に使用する。

  • kubectl logs --tail=10 -n [nameSpace] [podName]
    tail -10と同じ挙動。最後の10行だけ読みたい場合に使用する。

  • kubectl logs --since=1h -n [nameSpace] [podName]
    直近1時間のログを表示。時間で限定したい場合に使用する。他に-since=3mで3分前までのログを指定できる。

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?