Notifications
Clear all
Get Logs from each pods
This will retrieve a list of pods with the specified label in the specified namespace, extract the pod names using jq, and then pass each name to the kubectl logs command with the -n flag to specify the namespace.
ns="app-production"
label="app=super-app"
kubectl get pods -n $ns --show-labels
## Just echo statment
kubectl get pods -n $ns -l $label -o json | jq -r '.items[].metadata.name' | xargs -I {} echo "kubectl logs {} -n $ns"
kubectl get pods -n $ns -l $label -o json | jq -r '.items[].metadata.name' | xargs -I {} kubectl logs {} -n $ns
This topic was modified 3 years ago 2 times by Raju
Topic starter
Posted : 14/12/2022 10:11 pm