Kubernetes的Pod日志文件在哪里? [英] Where are Kubernetes' pods logfiles?

查看:5946
本文介绍了Kubernetes的Pod日志文件在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我跑步时

$ kubectl logs <container>

我得到了豆荚的日志.

但是这些日志的文件在哪里?

But where are the files for those logs?

某些消息来源说/var/log/containers/,其他消息来源说/var/lib/docker/containers/,但是我找不到我的实际应用程序或pod的日志.

Some sources says /var/log/containers/ others says /var/lib/docker/containers/ but I couldn't find my actual application's or pod's log.

推荐答案

磁盘上文件名来自

docker inspect $pod_name_or_sha | jq -r '.[0].LogPath'

假定docker守护程序的配置是默认的{"log-driver": "json-file"},如果kubectl logs行为正确,几乎可以保证它是正确的.

assuming the docker daemon's configuration is the default {"log-driver": "json-file"}, which is almost guaranteed to be true if kubectl logs behaves correctly.

这也可能不言而喻,但是您必须位于计划用于docker inspect的Pod的节点上,或者在磁盘上嗅探日志文件的存在,以进行任何有用的操作. kubectl describe pod $pod_name将呈现节点名称,或者,如果您希望以编程方式获取它,您可能会怀疑它会出现在kubectl get -o json pod $pod_name中.

This may also go without saying, but you must be on the Node upon which the Pod was scheduled for either docker inspect, or sniffing around for the presence of log files on disk, to do anything helpful. kubectl describe pod $pod_name will render the Node name, or as you might suspect it'll be in kubectl get -o json pod $pod_name if you wish to acquire it programmatically.

这篇关于Kubernetes的Pod日志文件在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆