1
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 1 year has passed since last update.

k8s Podが標準出力に出したログは、どの様にEKSノード上のログファイルとして記録されるのか?

Posted at

#はじめに
k8s Podが標準出力に出したログは、どの様にEKSノード上のログファイルとして記録されるのかのメモ。
WEBで調べて見たけれど余り情報が見当らなかっため、EKSクラスタ作って確認してみた。

#前提の環境

  • kubernetes version: 1.20
  • eksctl version: 0.62.0
  • EKSノードはマネージド型ノードグループとして作成
  • EKSノードのOS: AmazonLinux2/1.20

#ログディレクトリ階層、ファイル名
ディレクトリは大きく2つある模様。

##1. /var/log/containers
各Podのログのシンボリックリンクが張ってある。
ファイル名は #{Pod名}#{Namespace名}#{サービス名}-#{乱数?}.log

[root@ip-192-168-0-204 containers]# pwd
/var/log/containers
[root@ip-192-168-0-204 containers]# ll
total 0
lrwxrwxrwx 1 root root  92 Dec 14 03:13 aws-node-r78x8_kube-system_aws-node-44d7e9da5a56fa07c48e2bdc45aa084548fa6264b9a400387d4c4a4188122b20.log -> /var/log/pods/kube-system
_aws-node-r78x8_3e054baa-fecb-4e2f-a269-73124c95603b/aws-node/0.log
lrwxrwxrwx 1 root root 100 Dec 14 03:13 aws-node-r78x8_kube-system_aws-vpc-cni-init-a24558268ada64ab26ff14e159cf7b3010a8361726cadc4437c4dcd163f23db1.log -> /var/log/pods/kub
e-system_aws-node-r78x8_3e054baa-fecb-4e2f-a269-73124c95603b/aws-vpc-cni-init/0.log
lrwxrwxrwx 1 root root 101 Dec 14 03:13 coredns-54bc78bc49-662nj_kube-system_coredns-95f68db2920b5330a65dbeda2c5014474e0f26eb17066ec9a86582b92fe0fa04.log -> /var/log/pods/ku
be-system_coredns-54bc78bc49-662nj_295cc684-7a66-4c4b-ae97-5c728ba6593e/coredns/0.log
lrwxrwxrwx 1 root root  96 Dec 14 03:13 kube-proxy-9ccf5_kube-system_kube-proxy-4b44b5636b348fbb2f78d8160b40caeddc3bcc0617a9af168a929719d05c501c.log -> /var/log/pods/kube-sy
stem_kube-proxy-9ccf5_6b606d7f-e139-4b04-81cb-9cf81d39bb62/kube-proxy/0.log
lrwxrwxrwx 1 root root 113 Dec 14 04:00 linkerd-destination-56578b6779-g8zbx_linkerd_destination-245ef82fd72e3a651e6f18ef28d0db9faca7b0dbb8e7a0f782158db83639583c.log -> /var
/log/pods/linkerd_linkerd-destination-56578b6779-g8zbx_906680d6-0c01-4edb-8234-f51639980d1e/destination/0.log
lrwxrwxrwx 1 root root 114 Dec 14 04:00 linkerd-destination-56578b6779-g8zbx_linkerd_linkerd-init-454de82e2ee42cb3451eccdda6c8bea20a1d57d26b44ef496c48b7baaf39a147.log -> /va
r/log/pods/linkerd_linkerd-destination-56578b6779-g8zbx_906680d6-0c01-4edb-8234-f51639980d1e/linkerd-init/0.log
lrwxrwxrwx 1 root root 115 Dec 14 04:00 linkerd-destination-56578b6779-g8zbx_linkerd_linkerd-proxy-9eefba5eedf7d83d842393bc85fd5091aa0824a39e70f37c0f802c4ba0928706.log -> /v
ar/log/pods/linkerd_linkerd-destination-56578b6779-g8zbx_906680d6-0c01-4edb-8234-f51639980d1e/linkerd-proxy/0.log
lrwxrwxrwx 1 root root 117 Dec 14 04:00 linkerd-proxy-injector-7674b595d5-bpftr_linkerd_linkerd-init-f95bf5de058035dcbf3c6f904e4c8e231d8f42d5fa190fca47d8f0cbaec8beda.log -> 
/var/log/pods/linkerd_linkerd-proxy-injector-7674b595d5-bpftr_04183c88-0434-4afa-80d7-028326362101/linkerd-init/0.log
lrwxrwxrwx 1 root root 118 Dec 14 04:00 linkerd-proxy-injector-7674b595d5-bpftr_linkerd_linkerd-proxy-1352d4689479590f4f7b76b9f411c8def71efa1ce5e8f799d8c128d2d2a73caf.log ->
 /var/log/pods/linkerd_linkerd-proxy-injector-7674b595d5-bpftr_04183c88-0434-4afa-80d7-028326362101/linkerd-proxy/0.log
lrwxrwxrwx 1 root root 119 Dec 14 04:00 linkerd-proxy-injector-7674b595d5-bpftr_linkerd_proxy-injector-648674ba1b2d04c575c38183400c4722520c5047a009ff9a1cad64db831d4110.log -

/var/log/pods/linkerd_linkerd-proxy-injector-7674b595d5-bpftr_04183c88-0434-4afa-80d7-028326362101/proxy-injector/0.log
lrwxrwxrwx 1 root root 115 Dec 14 04:00 linkerd-sp-validator-5d7bb655ff-7rc45_linkerd_linkerd-init-b13957cebd22f3c463ab33c6b912677de6419c0a4c10f3188730796d208becf6.log -> /v
ar/log/pods/linkerd_linkerd-sp-validator-5d7bb655ff-7rc45_ba4033e6-2a0f-46de-9196-ed2922b4a0e2/linkerd-init/0.log
lrwxrwxrwx 1 root root 116 Dec 14 04:00 linkerd-sp-validator-5d7bb655ff-7rc45_linkerd_linkerd-proxy-43b35927841430cf894d67681cf59f5e30d4de73a0eb82ad3e2fcd02c9e2f525.log -> /
var/log/pods/linkerd_linkerd-sp-validator-5d7bb655ff-7rc45_ba4033e6-2a0f-46de-9196-ed2922b4a0e2/linkerd-proxy/0.log
lrwxrwxrwx 1 root root 115 Dec 14 04:00 linkerd-sp-validator-5d7bb655ff-7rc45_linkerd_sp-validator-84832e412886dcca3a6bfb4b62e56749850efeab439e0fead7e3328f9af0917f.log -> /v
ar/log/pods/linkerd_linkerd-sp-validator-5d7bb655ff-7rc45_ba4033e6-2a0f-46de-9196-ed2922b4a0e2/sp-validator/0.log
lrwxrwxrwx 1 root root  95 Dec 14 04:01 web-79469b946f-mdhhn_emojivoto_web-svc-d1854f07b48bed71480e80b3b070c6d6a652ba610185b231626eaee66ae694ac.log -> /var/log/pods/emojivot
o_web-79469b946f-mdhhn_c8feaa9b-152d-4d00-836b-61677f146179/web-svc/0.log

##2. /var/log/pods/#{Namespace名_Pod名_UUID}/#{サービス名}
上シンボリックリンクの実体
ファイル名は0.log

[root@ip-192-168-0-204 pods]# pwd
/var/log/pods
[root@ip-192-168-0-204 pods]# ll
total 0
drwxr-xr-x 3 root root 21 Dec 14 04:01 emojivoto_web-79469b946f-mdhhn_c8feaa9b-152d-4d00-836b-61677f146179
drwxr-xr-x 4 root root 46 Dec 14 03:13 kube-system_aws-node-r78x8_3e054baa-fecb-4e2f-a269-73124c95603b
drwxr-xr-x 3 root root 21 Dec 14 03:13 kube-system_coredns-54bc78bc49-662nj_295cc684-7a66-4c4b-ae97-5c728ba6593e
drwxr-xr-x 3 root root 24 Dec 14 03:13 kube-system_kube-proxy-9ccf5_6b606d7f-e139-4b04-81cb-9cf81d39bb62
drwxr-xr-x 5 root root 66 Dec 14 04:00 linkerd_linkerd-destination-56578b6779-g8zbx_906680d6-0c01-4edb-8234-f51639980d1e
drwxr-xr-x 5 root root 69 Dec 14 04:00 linkerd_linkerd-proxy-injector-7674b595d5-bpftr_04183c88-0434-4afa-80d7-028326362101
drwxr-xr-x 5 root root 67 Dec 14 04:00 linkerd_linkerd-sp-validator-5d7bb655ff-7rc45_ba4033e6-2a0f-46de-9196-ed2922b4a0e2
1
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
1
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?