Search code examples
loggingkubernetesgoogle-kubernetes-engine

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


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 created by a certain replication controller?


Solution

  • You can use labels

    kubectl logs -l app=elasticsearch
    

    And you'd probably want to specify --max-log-requests --all-containers --ignore-errors in order to:

    • Specify the number of concurrent log streams (default is 5)
    • Include logs from pods with multiple containers
    • Continue to next pod on fatal error (e.g. logs could not be retrieved)