|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * support/gathering-cluster-data.adoc |
| 4 | + |
| 5 | +[id="support-collecting-host-network-trace_{context}"] |
| 6 | += Collecting a host network trace |
| 7 | + |
| 8 | +Sometimes, troubleshooting a network-related issue is simplified by tracing network communication and capturing packets on multiple nodes at the same time. |
| 9 | + |
| 10 | +You can use a combination of the `oc adm must-gather` command and the `registry.redhat.io/openshift4/network-tools-rhel8` container image to gather packet captures from nodes. |
| 11 | +Analyzing packet captures can help you troubleshoot network communication issues. |
| 12 | + |
| 13 | +The `oc adm must-gather` command is used to run the `tcpdump` command in pods on specific nodes. |
| 14 | +The `tcpdump` command records the packet captures in the pods. |
| 15 | +When the `tcpdump` command exits, the `oc adm must-gather` command transfers the files with the packet captures from the pods to your client machine. |
| 16 | + |
| 17 | +[TIP] |
| 18 | +==== |
| 19 | +The sample command in the following procedure demonstrates performing a packet capture with the `tcpdump` command. |
| 20 | +However, you can run any command in the container image that is specified in the `--image` argument to gather troubleshooting information from multiple nodes at the same time. |
| 21 | +==== |
| 22 | + |
| 23 | +.Prerequisites |
| 24 | + |
| 25 | +* You have access to the cluster as a user with the `cluster-admin` role. |
| 26 | + |
| 27 | +* You have installed the OpenShift CLI (`oc`). |
| 28 | + |
| 29 | +.Procedure |
| 30 | + |
| 31 | +. Run a packet capture from the host network on some nodes by running the following command: |
| 32 | ++ |
| 33 | +[source,terminal] |
| 34 | +---- |
| 35 | +$ oc adm must-gather \ |
| 36 | + --dest-dir /tmp/captures \ <.> |
| 37 | + --source-dir '/tmp/tcpdump/' \ <.> |
| 38 | + --image registry.redhat.io/openshift4/network-tools-rhel8:latest \ <.> |
| 39 | + --node-selector 'node-role.kubernetes.io/worker' \ <.> |
| 40 | + --host-network=true \ <.> |
| 41 | + --timeout 30s \ <.> |
| 42 | + -- \ |
| 43 | + tcpdump -i any \ <.> |
| 44 | + -w /tmp/tcpdump/%Y-%m-%dT%H:%M:%S.pcap -W 1 -G 300 |
| 45 | +---- |
| 46 | +<.> The `--dest-dir` argument specifies that `oc adm must-gather` stores the packet captures in directories that are relative to `/tmp/captures` on the client machine. You can specify any writable directory. |
| 47 | +<.> When `tcpdump` is run in the debug pod that `oc adm must-gather` starts, the `--source-dir` argument specifies that the packet captures are temporarily stored in the `/tmp/tcpdump` directory on the pod. |
| 48 | +<.> The `--image` argument specifies a container image that includes the `tcpdump` command. |
| 49 | +<.> The `--node-selector` argument and example value specifies to perform the packet captures on the worker nodes. As an alternative, you can specify the `--node-name` argument instead to run the packet capture on a single node. If you omit both the `--node-selector` and the `--node-name` argument, the packet captures are performed on all nodes. |
| 50 | +<.> The `--host-network=true` argument is required so that the packet captures are performed on the network interfaces of the node. |
| 51 | +<.> The `--timeout` argument and value specify to run the debug pod for 30 seconds. If you do not specify the `--timeout` argument and a duration, the debug pod runs for 10 minutes. |
| 52 | +<.> The `-i any` argument for the `tcpdump` command specifies to capture packets on all network interfaces. As an alternative, you can specify a network interface name. |
| 53 | + |
| 54 | +. Perform the action, such as accessing a web application, that triggers the network communication issue while the network trace captures packets. |
| 55 | + |
| 56 | +. Review the packet capture files that `oc adm must-gather` transferred from the pods to your client machine: |
| 57 | ++ |
| 58 | +[source,text] |
| 59 | +---- |
| 60 | +tmp/captures |
| 61 | +├── event-filter.html |
| 62 | +├── ip-10-0-192-217-ec2-internal <1> |
| 63 | +│ └── registry-redhat-io-openshift4-network-tools-rhel8-sha256-bca... |
| 64 | +│ └── 2022-01-13T19:31:31.pcap |
| 65 | +├── ip-10-0-201-178-ec2-internal <1> |
| 66 | +│ └── registry-redhat-io-openshift4-network-tools-rhel8-sha256-bca... |
| 67 | +│ └── 2022-01-13T19:31:30.pcap |
| 68 | +├── ip-... |
| 69 | +└── timestamp |
| 70 | +---- |
| 71 | ++ |
| 72 | +<1> The packet captures are stored in directories that identify the hostname, container, and file name. |
| 73 | +If you did not specify the `--node-selector` argument, then the directory level for the hostname is not present. |
0 commit comments