SHARE
TWEET

Untitled

a guest Oct 21st, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. if [ $# -ne 2  ]
  4. then
  5.         echo "Usage: cilium-debug.sh <pod> <namespace>"
  6.         exit 1
  7. fi
  8.  
  9. pod_node=$(kubectl get pods $1 -owide -n $2 | awk '{print $7}' | tail -n1)
  10. echo "Pod location: ${pod_node}"
  11.  
  12. host_ip=$(kubectl get nodes -o wide | grep ${pod_node} | awk '{print $6}')
  13. echo "Pod node IP: ${host_ip}"
  14.  
  15. pod_ip=$(kubectl get pods $1 -owide -n $2 |awk '{print $6}' | tail -n1 )
  16. echo "Pod IP: ${pod_ip}"
  17.  
  18. cilium_pod=$(kubectl get pods -n kube-system -owide | grep cilium | grep ${pod_node} | awk '{print $1}')
  19. echo "Cilium pod for your pod: ${cilium_pod}"
  20.  
  21. pod_endpoint=$(kubectl exec -it ${cilium_pod} -n kube-system cilium bpf endpoint list | grep ${pod_ip})
  22. pod_mac_in_pod=$(echo ${pod_endpoint} | awk '{print tolower($5)}' | sed -e  's/mac=//')
  23. pod_mac_in_host=$(echo ${pod_endpoint} | awk '{print tolower($6)}' | sed -e  's/nodemac=//')
  24. echo "Pod mac addresses:"
  25. echo "- veth in pod namespace: ${pod_mac_in_pod}"
  26. echo "- veth in host namespace: ${pod_mac_in_host}"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top