Created
April 16, 2021 18:55
-
-
Save nyrahul/c18cf5f4478b35b0e1592204c54cb549 to your computer and use it in GitHub Desktop.
tcpdump for pod controlled by cilium
This file contains hidden or 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 | |
# Usage: $0 <pod> [tcpdump-filter] | |
[[ "$1" == "" ]] && echo "Usage: $0 <pod> [tcpdump-filter]" && exit 1 | |
ep_id=`kubectl get cep -A -o jsonpath="{.items[?(@.metadata.name==\"$1\")].status.id}"` | |
iface=`cilium endpoint get $ep_id -o jsonpath="{[*].status.networking.interface-name}"` | |
shift | |
[[ "$iface" != lxc* ]] && echo "Could not get interface for pod=[$1]" && exit 2 | |
echo "Executing: tcpdump -i $iface $*" | |
tcpdump -i $iface $* |
FYI: This script will work only within cilium development env.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🚀