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
I use this simple script to get a log from the pods of a deployment:
#!/usr/bin/env bash
DEPLOYMENT=$1
for p in $(kubectl get pods | grep ^${DEPLOYMENT}- | cut -f 1 -d ' '); do
echo ---------------------------
echo $p
echo ---------------------------
kubectl logs $p
done
Gist of the script
Usage: log_deployment.sh "deployment-name".
Script will then show log of all pods that start with that "deployment-name".