Last active
October 9, 2023 17:51
-
-
Save borsna/c217d9ee6c835128e057acb034f827fe to your computer and use it in GitHub Desktop.
Tail log for kubernetes pod by geting list of pods and filter by substring
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
namespace=mynamespace | |
pods=$(kubectl get po -n $namespace -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{end}') | |
for i in $(echo $pods | sed "s/\t/ /g") | |
do | |
case $i in *"$1"*) | |
kubectl logs -n $namespace $i --follow;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Got bored of listing kubernetes pods and then geting the generated name to get a tail log.
call script by:
sh kubectl-log-tail.sh some-service