Capturing a network trace in a pod

Procedure

  1. Get the name of the pod.
     kubectl get pods 
  2. Start a shell session in the pod. Issue the below command, and make the following substitutions:
    kubectl exec -it <podname> --container=<container name> -- bash 
    podname
    The name of the pod.
    container_name
    is the name of the container. If the pod only has one container you can omit this parameter.
    For example, if the pod name is jitsi-74d95d6d49-k5nts and the container name is jigasi, then the resulting command is:
    kubectl exec -it jitsi-74d95d6d49-k5nts --container=jigasi --bash
  3. Update the repositories by issuing the below command:
    apt-get update 
  4. Install tcpdump by issuing the below command:
    apt-get install tcpdump 
  5. Capture the network data, by issuing the command:
    tcpdump -i any -w <filename>.pcap 
  6. Reproduce the problem.
  7. To stop and save the capture press Ctrl+C.