如何跟踪 Kubernetes 集群中的所有日志 [英] How to tail all logs in a kubernetes cluster

查看:31
本文介绍了如何跟踪 Kubernetes 集群中的所有日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过这个命令:

kubectl logs --tail

我收到此错误/帮助输出:

I got this error/help output:

Error: flag needs an argument: --tail


Aliases:
logs, log

Examples:
  # Return snapshot logs from pod nginx with only one container
  kubectl logs nginx

  # Return snapshot logs for the pods defined by label app=nginx
  kubectl logs -lapp=nginx

  # Return snapshot of previous terminated ruby container logs from pod web-1
  kubectl logs -p -c ruby web-1

  # Begin streaming the logs of the ruby container in pod web-1
  kubectl logs -f -c ruby web-1

  # Display only the most recent 20 lines of output in pod nginx
  kubectl logs --tail=20 nginx

  # Show all logs from pod nginx written in the last hour
  kubectl logs --since=1h nginx

  # Return snapshot logs from first container of a job named hello
  kubectl logs job/hello

  # Return snapshot logs from container nginx-1 of a deployment named nginx
  kubectl logs deployment/nginx -c nginx-1

嗯,我只是想看看所有的日志,这不是很常见的事情吗?如何跟踪集群的所有日志?

ummm I just want to see all the logs, isn't this a common thing to want to do? How can I tail all the logs for a cluster?

推荐答案

如果你不介意使用第三方工具,kail 完全符合您的描述.

If you don't mind using a third party tool, kail does exactly what you're describing.

从所有匹配的 pod 的所有容器中流式传输日志.[...] 没有参数,kail 匹配集群中的所有 pod.

Streams logs from all containers of all matched pods. [...] With no arguments, kail matches all pods in the cluster.

这篇关于如何跟踪 Kubernetes 集群中的所有日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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