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

前端 未结 14 1328
不思量自难忘°
不思量自难忘° 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:52

    You can get help from kubectl logs -h and according the info,

    kubectl logs -f deployment/myapp -c myapp --tail 100
    

    -c is the container name and --tail will show the latest num lines,but this will choose one pod of the deployment, not all pods. This is something you have to bear in mind.

    kubectl logs -l app=myapp -c myapp --tail 100
    

    If you want to show logs of all pods, you can use -l and specify a lable, but at the same time -f won't be used.

提交回复
热议问题