is there a way to check multiple pods in one kubectl command?

The kubectl logs can’t print logs from multiple pods specified by names.

Although, you can use the -l, --selector='' flag as a label query to filter on. e.g.:

# Return snapshot logs from all containers in pods defined by label app=nginx
kubectl logs -lapp=nginx --all-containers=true

If you need to print logs from multiple different pods, there are some projects that can help:

  • Kubetail: Bash script that enables you to aggregate (tail/follow) logs from multiple pods into one stream. This is the same as running kubectl logs -f but for multiple pods.
  • Kubelogs: It is a bash script that uses your current kubectl context to interactively select namespaces and multiple pods to download logs from. It basically runs kubectl logs in a loop for all containers, redirecting the logs to local files.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top