How do I get logs from all pods of a Kubernetes replication controller?

前端 未结 14 1324
不思量自难忘°
不思量自难忘° 2021-01-29 23:14

Running kubectl logs shows me the stderr/stdout of one Kubernetes container.

How can I get the aggregated stderr/stdout of a set of pods, preferably those

14条回答
  •  礼貌的吻别
    2021-01-29 23:39

    Previously provided solutions are not that optimal. The kubernetes team itself has provided a solution a while ago, called stern.

    stern app1
    

    It is also matching regular expressions and does tail and -f (follow) by default. A nice benefit is, that it shows you the pod which generated the log as well.

    app1-12381266dad-3233c foobar log
    app1-99348234asd-959cc foobar log2
    

    Grab the go-binary for linux or install via brew for OSX.

    https://kubernetes.io/blog/2016/10/tail-kubernetes-with-stern/

    https://github.com/wercker/stern

提交回复
热议问题