Skip to content

Instantly share code, notes, and snippets.

@gswallow
Last active February 2, 2023 21:24
Show Gist options
  • Save gswallow/ff53998ad13007652182975e662481a5 to your computer and use it in GitHub Desktop.
Save gswallow/ff53998ad13007652182975e662481a5 to your computer and use it in GitHub Desktop.
Get events by pod name (or a fragment thereof)
#!/bin/bash
pod_name=$1
while true; do
kubectl get events --sort-by='.lastTimestamp' \
-ojson \
| jq -r '.items[] | select((.involvedObject.name | contains("'$pod_name'")) and (.involvedObject.kind=="Pod")) | "\(.lastTimestamp) [\(.count)] \(.message)"'
echo
echo "---------"
echo
sleep 2
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment