登录Kubernetes以获取使用部署进行部署的Pod [英] Logs in Kubernetes for pods which are deployed using deployments

查看:90
本文介绍了登录Kubernetes以获取使用部署进行部署的Pod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将在下面尝试解释我的问题,

I will try to explain my problem below,

  1. 使用部署创建Pod,然后使用kubectl apply -f sampledep.yaml在其上再应用一个更新.

  1. Create a pod using deployment and then apply one more update on it using kubectl apply -f sampledep.yaml.

如果我们执行kubectl get pods,则Pod名称将会更改.

Pod name would have changed if we do kubectl get pods.

因此,我们在上一个窗格中拥有的所有日志将不再存在或可以检索.

So whatever logs we had in our previous pod no longer exist or can be retrieved.

我现在将在下面列出以下问题:

I will list down the questions below now:

  1. 是否有办法为该应用程序检索旧的pod日志?
  2. 有没有一种方法可以配置可用于Pod累积的日志大小?
  3. 如果日志积累过多并且没有剩余空间,pod会发生什么!
  4. 在kubernetes中查看/管理已部署Pod的日志的推荐方法是什么?

推荐答案

  1. 尝试运行kubectl get pods --show-all.如果可以在其中找到您的广告连播,则可以使用kubectl logs <pod name>.如果没有,我认为您无法再检索日志.

  1. Try to run kubectl get pods --show-all. If you can find your pod there you can just use kubectl logs <pod name>. If not, I don't think you can retrieve the logs anymore.

在k8s中管理日志的推荐方法是使用类似

The recommended way to manage logs in k8s is using an addon like fluentd-elasticsearch. This way, you never save logs on the pod FS itself, you just print logs from your container to STDOUT and fluentd will automatically ship the logs to Elasticsearch, which you can later on interrogate with Kibana. There's no need to limit accumulated logs for a pod since it is never accumulated on the pods itself.

这篇关于登录Kubernetes以获取使用部署进行部署的Pod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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