Kubernetes在Pod中的日志位置 [英] Kubernetes log location in pod

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

问题描述

我只是想在吊舱中找到日志位置.

I am just trying to find the log location in the pod.

我刚刚按如下所示登录了广告连播.

I just logged into the pod as below.

kubectl exec -it POD_NAME bash

kubectl exec -it POD_NAME bash

但是,日志在/var/logs下不可用.不确定实际的日志位置是什么,以及如何更改它.

But, the logs are not available under /var/logs. Not sure what is the actual log location and how to change that.

谢谢

推荐答案

如果您的应用程序正在将日志写入文件,则该日志文件在容器中的位置取决于您的应用程序.日志文件在主机上的位置取决于您是否在主机上安装了日志目录.

If your application is writing logs to file, then the location of that log file within the container depends on your application. The location of the log file on the host depends on whether you've mounted the log directory on the host.

如果您的应用程序正在将日志写入stdout,则您的容器运行时将捕获每一行并将其存储在主机上.对于Docker,它存储在/var/lib/docker/containers目录中.

If your application is writing logs to stdout, then your container runtime would capture each line and store it on the host. For Docker, this is stored in the /var/lib/docker/containers directory.

但是,通过将相关日志文件符号链接到/var/log/pods/<namespace>_<pod_name>_<pod_id>/<container_name>/,Kubernetes也使您更容易在Kubernetes节点上找到日志文件.

But Kubernetes also makes it easier for you to find the log files on the Kubernetes node, by symlinking the relevant log file to /var/log/pods/<namespace>_<pod_name>_<pod_id>/<container_name>/.

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

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