Skip to content

Instantly share code, notes, and snippets.

@evrardjp
Last active October 3, 2019 09:36
Show Gist options
  • Save evrardjp/bffed8cab0aaa31972b1b203270dbd6c to your computer and use it in GitHub Desktop.
Save evrardjp/bffed8cab0aaa31972b1b203270dbd6c to your computer and use it in GitHub Desktop.
cilium-debug.sh
#!/bin/bash
if [ $# -ne 2 ]
then
echo "Usage: cilium-debug.sh <pod> <namespace>"
exit 1
fi
pod_node=$(kubectl get pods $1 -owide -n $2 | awk '{print $7}' | tail -n1)
echo "Pod location: ${pod_node}"
host_ip=$(kubectl get nodes -o wide | grep ${pod_node} | awk '{print $6}')
echo "Pod node IP: ${host_ip}"
pod_ip=$(kubectl get pods $1 -owide -n $2 |awk '{print $6}' | tail -n1 )
echo "Pod IP: ${pod_ip}"
cilium_pod=$(kubectl get pods -n kube-system -owide | grep cilium | grep ${pod_node} | awk '{print $1}')
echo "Cilium pod for your pod: ${cilium_pod}"
pod_endpoint=$(kubectl exec -it ${cilium_pod} -n kube-system cilium bpf endpoint list | grep ${pod_ip})
pod_mac_in_pod=$(echo ${pod_endpoint} | awk '{print tolower($5)}' | sed -e 's/mac=//')
pod_mac_in_host=$(echo ${pod_endpoint} | awk '{print tolower($6)}' | sed -e 's/nodemac=//')
echo "Pod mac addresses:"
echo "- veth in pod namespace: ${pod_mac_in_pod}"
echo "- veth in host namespace: ${pod_mac_in_host}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment