Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Capture a Pod's traffic and read the cause of a failure

By updated

Improve this page

To find out why a Pod client fails, you capture its packets with tcpdump and read what comes back after the first connection packet. The client's log only says "timeout" or "connection impossible", and three very different causes give this same kind of message. The capture tells them apart: a refusal sends back a rejection packet almost immediately, a loss lets the same packet go out again without a response, and a DNS failure never sends a connection packet. This lesson shows three ways to capture a Pod's traffic, on the node or from an ephemeral container, then teaches you to read these three signatures. It is aimed at readers who already know how to diagnose a Pod with kubectl and want to go down to the packet level.

What you will learn

  • Find on its node the interface that links a Pod to the host with ip route get, capture the traffic there with tcpdump, write it with -w and read it back with -r.
  • Name from the capture the cause of a failure: refusal, silent loss or DNS failure.
  • Enter a Pod's network namespace from its node with nsenter.
  • See that the capture shows the Service address on both sides of the Pod, and follow in iptables where it becomes a Pod's address.
  • Capture from an ephemeral container (a container added to an already running Pod) with kubectl debug, then read the capture with kubectl logs.
  • Choose the capture method that fits the situation.

Prerequisites

  • The lesson Pod Networking, which explains a Pod's address, a packet's path between two Pods and the role of kube-proxy.
  • The lesson Services, to know that a Service has its own address and a targetPort.
  • The lesson CoreDNS, to know how a Pod resolves a name.
  • The lesson Network Policies, to know that an ingress policy can drop packets.
  • The basics of TCP: the lesson TCP and UDP (in French) explains the three-way handshake. The filters and advanced options of tcpdump are detailed in tcpdump: observe network traffic and are not repeated here.
  • ssh access to the nodes with sudo, and a kubectl that administers the cluster.
  • The demonstration environment: the kubeadm cluster of the lab catalog (Kubernetes v1.37.2, containerd 2.2.1, kube-proxy in iptables mode, Calico with its iptables dataplane, iptables 1.8.10 in nf_tables, Ubuntu 24.04), with tcpdump 4.99.4 and crictl v1.37.0 on the nodes, and tcpdump 4.99.6 in the nicolaka/netshoot:v0.16 image. The outputs were collected on 15 and 16 November 2026.

Which situation does the demonstration use?

In the l2-mesure namespace, three clients each call a server every 2 seconds with curl -sS -m 3, that is, a maximum timeout of 3 seconds. The servers are hashicorp/http-echo:1.0.0 listening on port 5678. Each client has a different fault, set on purpose.

ClientTargetFault set
client-refusapi-mauvais-port ServicetargetPort: 5679, where nothing listens
client-pertestock Servicean ingress NetworkPolicy on stock only admits role: inventaire
client-dnsapi-ok-typono Service carries this name

Here is what the logs of the three clients say. It is all the application knows about its failure.

client-refus : curl: (7) Failed to connect to api-mauvais-port:80 after 1 ms: Could not connect to server
client-perte : curl: (28) Connection timed out after 3001 milliseconds
client-dns : curl: (28) Resolving timed out after 3001 milliseconds

The DNS client's message does not say "unknown name": with a 3-second timeout, curl gives up before the end of the resolution. The client indeed tries each search domain from its /etc/resolv.conf (l2-mesure.svc.cluster.local, svc.cluster.local, cluster.local, then lab), and the last one goes to the host's DNS. For a nonexistent name, the resolution took 5.0 s in the measurement. With a long enough timeout, curl ends up returning curl: (6) Could not resolve host: api-ok-typo; a name that exists resolves in 0.9 ms.

The logs therefore do not allow you to decide: you have to read the packets.

How do you find a Pod's interface on its node?

To capture what a Pod sends and receives, you listen on the interface that links it to its node, and the route to the Pod's address gives it. A Pod lives in its own network namespace, that is, a set of interfaces, addresses and routes that the kernel isolates from the node's. It sees an eth0 interface there, which is one of the two ends of a pair of virtual interfaces (a "veth" pair): the other end stays on the node, and Calico names it cali followed by 11 characters. Every packet that enters or leaves the Pod goes through this pair, hence through the cali interface.

First get the Pod's address and node with kubectl -n l2-mesure get pods -o wide, then run on that node:

Terminal window
ip route get 10.244.38.121 | grep -o 'dev [^ ]*'
dev calic7ab51f6efc

The route to the Pod's address leaves through calic7ab51f6efc: that is the interface to listen on. It is only found on the node that carries the Pod, which forces you to read the NODE column before connecting. Another CNI names its interfaces differently, but the command stays the same: it names the outgoing interface toward that address.

How do you capture with tcpdump on the node's interface?

You run tcpdump on the cali interface for a few seconds, write the packets to a file with -w, then read the file back with -r. Writing first lets you bring the capture back to a workstation and read it again as often as needed. On the node:

Terminal window
sudo timeout 12 tcpdump -i calic7ab51f6efc -nn -U -w /tmp/l2-captures/perte.pcap
sudo tcpdump -nn -r /tmp/l2-captures/perte.pcap

Each option serves a precise purpose:

  • -i chooses the interface to listen on;
  • -nn keeps addresses and ports as numbers, with no name resolution that would distort what you read;
  • -U writes each packet to the file without waiting for the buffer to fill, which keeps the capture readable if it is interrupted abruptly;
  • -w writes to a file, -r reads it back;
  • timeout 12 stops the capture after 12 seconds, enough to see several 2-second calls.

To copy the file to the control node, scp k8s-w1.lab:/tmp/l2-captures/perte.pcap ~/captures/perte.pcap works. Keeping all the packets, even those that do not seem related to the failure, matters: the DNS requests and the TCP packets explain each other.

How do you read a capture: refusal, loss or DNS?

Three questions are enough to read a capture: did the name resolve, did a connection SYN packet go out, and what came back, and how fast? A SYN is the first packet of a TCP connection, the one the client sends to ask for the connection to open. The three failures give three different answers.

A refusal: a SYN, then an immediate RST

In the client-refus capture, the name resolves, the SYN goes out, and a packet carrying the [R.] flag comes back almost immediately.

21:03:45.815099 IP 10.244.38.108.36153 > 10.96.0.10.53: 18780+ A? api-mauvais-port.l2-mesure.svc.cluster.local. (62)
21:03:45.815841 IP 10.96.0.10.53 > 10.244.38.108.36153: 18780*- 1/0/0 A 10.103.172.25 (122)
21:03:45.816061 IP 10.244.38.108.37188 > 10.103.172.25.80: Flags [S], seq 3595941848, win 64860, options [mss 1410,sackOK,TS val 922540428 ecr 0,nop,wscale 7], length 0
21:03:45.816104 IP 10.103.172.25.80 > 10.244.38.108.37188: Flags [R.], seq 0, ack 3595941849, win 0, length 0

Read the four lines in order. The first is the client's DNS question, the second the answer (A 10.103.172.25, the Service's address). The third is the SYN (Flags [S]) to that address. The last is the rejection: [R.] designates an RST (reset), the packet that cuts a connection and that here means "nobody is listening on this port". It arrives 43 microseconds after the SYN. A refusal is fast: the connection fails immediately, with no wait.

The RST seems to come from the Service's address (10.103.172.25) and not from the Pod that refused. The node undoes the Service's address translation when the packet returns: a capture taken on the client side never shows the real sender. To see it, you must capture on the server side. The section on the Service address, further down, shows where this translation happens.

The same capture contains noise unrelated to the failure: DNS ServFail answers (the DNS server signals an error) arriving after the client's socket was closed, followed by an ICMP ... udp port ... unreachable message (the client Pod tells the DNS server that nobody listens on this UDP port anymore).

21:03:45.862836 IP 10.96.0.10.53 > 10.244.38.108.37932: 634 ServFail- 0/0/0 (29)
21:03:45.862872 IP 10.244.38.108 > 10.96.0.10: ICMP 10.244.38.108 udp port 37932 unreachable, length 65

These two lines do not signal a client failure: the answer arrived too late. Do not confuse them with the cause.

A loss: the same SYN goes out again, nothing comes back

In the client-perte capture, the name also resolves, but the SYN goes out again several times with no response at all.

21:03:46.084601 IP 10.96.0.10.53 > 10.244.38.121.52175: 23422*- 1/0/0 A 10.103.109.125 (100)
21:03:46.084686 IP 10.244.38.121.36654 > 10.103.109.125.80: Flags [S], seq 3748015123, ...
21:03:47.132406 IP 10.244.38.121.36654 > 10.103.109.125.80: Flags [S], seq 3748015123, ...
21:03:48.156460 IP 10.244.38.121.36654 > 10.103.109.125.80: Flags [S], seq 3748015123, ...

The source port (36654) and the sequence number (seq 3748015123) are identical on the three [S] lines: it is the same packet, which TCP retransmits at 1.05 s then 1.02 s intervals. No SYN-ACK (the answer of a server that accepts the connection) and no RST comes back. A loss is read from what is missing, and it is this silence that explains the client's Connection timed out message.

The capture does not say who drops the packet. Here, it is the NetworkPolicy: Calico drops the packet without warning the sender. A firewall between the nodes would give the same capture: to confirm the cause, list the policies of the target's namespace with kubectl get networkpolicy.

A DNS failure: NXDomain answers and no SYN

In the client-dns capture, the client queries each search domain, and the first answers are NXDomain, the DNS answer that says "this name does not exist".

21:03:46.738617 IP 10.244.38.109.58456 > 10.96.0.10.53: 21041+ A? api-ok-typo.l2-mesure.svc.cluster.local. (57)
21:03:46.739526 IP 10.96.0.10.53 > 10.244.38.109.58456: 21041 NXDomain*- 0/1/0 (150)
21:03:46.739571 IP 10.244.38.109.33333 > 10.96.0.10.53: 63658+ A? api-ok-typo.svc.cluster.local. (47)
21:03:46.740008 IP 10.96.0.10.53 > 10.244.38.109.33333: 63658 NXDomain*- 0/1/0 (140)
21:03:46.740022 IP 10.244.38.109.45235 > 10.96.0.10.53: 62448+ A? api-ok-typo.cluster.local. (43)
21:03:46.740324 IP 10.96.0.10.53 > 10.244.38.109.45235: 62448 NXDomain*- 0/1/0 (136)
21:03:46.740355 IP 10.244.38.109.54421 > 10.96.0.10.53: 2488+ A? api-ok-typo.lab. (33)

The name is tried four times, with each search domain, and the first three attempts receive an NXDomain. The fourth, api-ok-typo.lab., has no answer in the capture: it goes to the host's DNS, which explains the 5 seconds measured above. Above all, no Flags [S] line appears: the client never had an address to reach, so it attempted no connection.

The table summarizes the three signatures.

CauseDoes the name resolve?Does a SYN go out?What comes back
Refusalyesyesan [R.] almost immediately
Lossyesyes, several times, identicalnothing
DNSnonoNXDomain answers

How do you capture inside the Pod's network namespace with nsenter?

When you prefer to see the Pod from the inside, nsenter runs the node's tcpdump in the container's network namespace, without installing anything in the Pod's image. nsenter -t <pid> -n runs a command in the network namespace of process <pid>, the Pod's. You therefore need the container's PID, which crictl gives from the node (see CRICTL (in French)). The tool is presented in more detail in A container by hand with unshare and nsenter. These commands require root rights: prefix them with sudo, or open a root shell on the node first.

Terminal window
id=$(crictl ps --name curl -q --label io.kubernetes.pod.name=client-perte | head -1)
pid=$(crictl inspect --output go-template --template '{{.info.pid}}' "$id")
nsenter -t "$pid" -n ip -br addr
timeout 8 nsenter -t "$pid" -n tcpdump -i eth0 -nn 'tcp[tcpflags] & (tcp-syn|tcp-rst) != 0'
lo UNKNOWN 127.0.0.1/8 ::1/128
eth0@if238 UP 10.244.38.121/32 fe80::c8bf:aaff:fe2a:70aa/64
21:04:46.172234 IP 10.244.38.121.49500 > 10.103.109.125.80: Flags [S], seq 3925980862, ...
21:04:47.228391 IP 10.244.38.121.49500 > 10.103.109.125.80: Flags [S], seq 3925980862, ...
21:04:48.252463 IP 10.244.38.121.49500 > 10.103.109.125.80: Flags [S], seq 3925980862, ...

The eth0@if238 line reads like this: in the Pod's network namespace, the interface is called eth0, and @if238 indicates that the other end of the veth pair, on the node side, is the interface with index 238, that is, the cali. The address carries a /32 mask: the Pod is alone on its network, and everything goes through its node's route. The tcp[tcpflags] & (tcp-syn|tcp-rst) != 0 filter only keeps the connection start and end packets, which is enough to recognize the three signatures. You find the same SYN retransmitted at 1-second intervals, the signature of a loss, seen this time from inside the Pod.

The tcpdump used is the node's, not the image's: a minimal image, with no shell or tools, can still be captured.

Which address does the capture show when the Pod calls a Service?

On both sides of the Pod, the capture still shows the Service's address: the translation to a server Pod's address happens further on, in the node's iptables rules. This translation is called a DNAT (destination NAT): the kernel replaces the packet's destination address with that of a Pod chosen among those of the Service. To check it, the measurement in this section uses a test client, client, which calls the echo Service (10.111.11.160, port 80). This Service has a single Pod behind it, hashicorp/http-echo:1.0.0 on 10.244.38.120, port 5678. The client and its server run on the same node, k8s-w1.

You capture at the same time in the Pod (eth0@if46, with nsenter) and on its node-side interface (cali58921064873), for a single curl http://echo request. The filter is tcp port 80 or tcp port 5678 and the -S option displays absolute sequence numbers, which lets you recognize the same packet.

On the diagram, follow the packet from left to right, then downward. The two red frames are the two capture points: at these two places, the destination is still the Service's address. The DNAT only happens afterwards, in the KUBE-SEP-… chain: that is where the destination becomes the server Pod's address.

Path of a packet from the client Pod to the server Pod. It leaves the client Pod's eth0 interface, first capture point, goes through the veth pair and arrives on the node's caliXXXX interface, second capture point. Until then, its destination is the Service IP. It then goes through the iptables chains KUBE-SERVICES, which recognizes the Service, KUBE-SVC-…, which chooses a Pod, then KUBE-SEP-…, where the DNAT replaces the destination with the server Pod's IP, for example 10.244.38.120:5678.     Client Pod: eth0     CAPTURE 1veth pair Service IP Node: caliXXXXCAPTURE 2 Service IP KUBE-SERVICESmatches the Service destination:Service IP KUBE-SVC-…picks a PodKUBE-SEP-…DNATServer Pod destination:server Pod IP10.244.38.120:5678 
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %
Pod side 12:42:52.947545 IP 10.244.38.114.35530 > 10.111.11.160.80: Flags [S], seq 216194490, ...
node side 12:42:52.947548 IP 10.244.38.114.35530 > 10.111.11.160.80: Flags [S], seq 216194490, ...
Pod side 12:42:52.947622 IP 10.244.38.114.35530 > 10.111.11.160.80: Flags [P.], seq 216194491:216194559, ... HTTP: GET / HTTP/1.1
node side 12:42:52.947623 IP 10.244.38.114.35530 > 10.111.11.160.80: Flags [P.], seq 216194491:216194559, ... HTTP: GET / HTTP/1.1
Pod side 12:42:52.947847 IP 10.111.11.160.80 > 10.244.38.114.35530: Flags [P.], seq 2588631567:2588631731, ... HTTP/1.1 200 OK
node side 12:42:52.947845 IP 10.111.11.160.80 > 10.244.38.114.35530: Flags [P.], seq 2588631567:2588631731, ... HTTP/1.1 200 OK

The output is abridged to three packets of the request. In each pair of lines, the sequence number is identical and the time gap does not exceed a few microseconds: the packets are the same on both sides. The destination stays the Service's address, 10.111.11.160, and not 10.244.38.120, the server Pod's. The response comes back with the Service's address as source: the return is translated in the opposite direction before reaching the Pod's interface. That is why the RST of a refusal seems to come from the Service.

The translation is read in the nat table of iptables, on k8s-w1. The exact counters are obtained with -x, collected before then after a request. The output that follows is summarized: for each chain, it only keeps the rule that matters and its counter.

Terminal window
sudo iptables -t nat -L KUBE-SERVICES -n -v -x --line-numbers
sudo iptables -t nat -L KUBE-SVC-6YUOJRSQLA2RVKTP -n -v -x --line-numbers
sudo iptables -t nat -L KUBE-SEP-DDC6H4GETC7NS63A -n -v -x --line-numbers
KUBE-SERVICES, rule 6:
before 1 packet 60 bytes KUBE-SVC-6YUOJRSQLA2RVKTP tcp -- 0.0.0.0/0 10.111.11.160 /* l2-mesure/echo cluster IP */ tcp dpt:80
after 2 packets 120 bytes
KUBE-SVC-6YUOJRSQLA2RVKTP :
1 0 0 KUBE-MARK-MASQ tcp -- !10.244.0.0/16 10.111.11.160 /* l2-mesure/echo cluster IP */ tcp dpt:80
2 before 1/60, after 2/120 KUBE-SEP-DDC6H4GETC7NS63A /* l2-mesure/echo -> 10.244.38.120:5678 */
KUBE-SEP-DDC6H4GETC7NS63A :
1 0 0 KUBE-MARK-MASQ -- 10.244.38.120 0.0.0.0/0 /* l2-mesure/echo */
2 before 1/60, after 2/120 DNAT tcp /* l2-mesure/echo */ tcp to:10.244.38.120:5678

The KUBE-SVC-… and KUBE-SEP-… names are specific to each Service and each Pod: collect yours from the output of KUBE-SERVICES. The path is always the same: KUBE-SERVICES recognizes the Service's address, KUBE-SVC-… chooses a Pod, KUBE-SEP-… rewrites the destination with a DNAT to 10.244.38.120:5678.

The counters show that one request only adds one packet, from 1 to 2, to each rule. It is the SYN: only the first packet of a connection goes through these rules. conntrack, the kernel's connection tracking table, remembers the translation and then applies it to the following packets, in both directions.

How do you capture from an ephemeral container with kubectl debug?

When you have no session on the node, kubectl debug adds to the Pod an ephemeral container that shares its network and carries tcpdump, and you read the capture with kubectl logs. An ephemeral container is a container added to an already running Pod, to diagnose it. It shares the Pod's network namespace, so it sees the same eth0 as the other containers. The lesson Debugging a Kubernetes application presents the step in general; we apply it here to capture with an image that contains tcpdump. The measurement still uses the client of the l2-mesure namespace.

Terminal window
kubectl -n l2-mesure debug client --image=nicolaka/netshoot:v0.16@sha256:b09d9b21381f47a79b3cbcb30da25266dc17186ea00ae65e99fdc51396f48e70 \
--target=curl -- timeout 6 tcpdump -i any -nn -c 4 "tcp port 80"

The command returns immediately. It prints two lines, including Defaulting debug container name to debugger-xxxxx.: note this name, it is used to read the capture. The tcpdump output does not go through kubectl debug, it is in the ephemeral container's logs.

Terminal window
kubectl -n l2-mesure logs client -c debugger-xxxxx
listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes
12:40:32.823330 eth0 Out IP 10.244.38.114.43020 > 10.111.11.160.80: Flags [S], seq 425306490, ...
4 packets captured
10 packets received by filter
0 packets dropped by kernel

The SYN leaves through eth0 (Out) toward the Service's address, and the capture was read without leaving the workstation. --target=curl names the container whose process namespace you want to share. The image is pinned by its digest, and tcpdump is version 4.99.6 in it. The last three lines are tcpdump's summary: four packets captured, ten received by the filter, none dropped by the kernel.

This command has no --profile, so the default profile, general, applies. It only adds SYS_PTRACE, and the capture works anyway without the netadmin profile: containerd grants the NET_RAW capability to every container by default, and it is enough for tcpdump. With --profile=netadmin and the same image, the measurement gives the same results.

The netadmin profile adds NET_ADMIN and NET_RAW. It becomes useful when the runtime does not grant NET_RAW by default, or for a step that requires NET_ADMIN.

Run kubectl debug without -i, then read the capture in the logs of the ephemeral container with kubectl logs. The -i option indeed hides two pitfalls. With -i=false or no option, the container is created without standard input, and kubectl returns immediately. With -it=false, kubectl's option parser reads -i (true) then -t=false: the container is created with stdin: true, and kubectl attaches, printing If you don't see a command prompt, try pressing enter..

In neither case does tcpdump's output go through kubectl: the 4-packet capture finishes in one second, before the attachment. A slower capture may display in kubectl, but that is a race, not a guarantee.

The ephemeral container stays recorded in the Pod's spec.ephemeralContainers after it ends, with the terminated state and the Completed reason. You cannot remove it: only replacing the Pod erases it. Plan for it before debugging a Pod that you do not want to modify.

What does kubectl debug give in a Pod Security restricted namespace?

In a namespace labeled pod-security.kubernetes.io/enforce=restricted, no kubectl debug profile allows the capture. The measurement was made with a client compliant with this level and the same netshoot v0.16 image pinned by digest. The netadmin profile is refused at admission, with exit code 1. kubectl first prints a warning about the Pod's non-root user, then the API refuses the ephemeral container.

Warning: Non-root user is configured for the entire target Pod, and some capabilities granted by debug profile may not work. Please consider using "--custom" with a custom profile that specifies "securityContext.runAsUser: 0".
Error from server (Forbidden): pods "client" is forbidden: violates PodSecurity "restricted:latest": allowPrivilegeEscalation != false (container "debugger-cptzn" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container "debugger-cptzn" must set securityContext.capabilities.drop=["ALL"]; container "debugger-cptzn" must not include "NET_ADMIN", "NET_RAW" in securityContext.capabilities.add)

Read the end of the message: it names NET_ADMIN and NET_RAW as capabilities forbidden in securityContext.capabilities.add. The general profile, the default one, is refused the same way, with SYS_PTRACE instead. The restricted profile is the only one accepted, and it respects the level: the container has drop: ["ALL"], runAsNonRoot: true and a RuntimeDefault seccompProfile. But it no longer has NET_RAW, and tcpdump fails in the ephemeral container's logs.

tcpdump: eth0: You don't have permission to perform this capture on that device
(Attempt to create packet socket failed - CAP_NET_RAW may be required)

In a restricted namespace, the capture is therefore done on the node, with tcpdump on the cali interface or with nsenter, two methods that create nothing in the Pod.

Which capture method should you choose?

The choice depends on what you have: access to the node gives the first two methods, access to the Kubernetes API alone gives the third. The three show the same Pod packets, only the way of reaching them changes.

MethodWhere you workWhat you needWhat it leaves
tcpdump on the cali interfacethe Pod's nodesudo on the nodenothing in the Pod
nsenter in the network namespacethe Pod's nodesudo, crictlnothing in the Pod
kubectl debugthe workstationkubectl and an image with tcpdumpan ephemeral container in the Pod

The cali interface is the simplest for a long capture written to a file. nsenter fits when you want the Pod's interface names. kubectl debug is for when the node is unreachable, at the price of an ephemeral container that stays on the Pod; in a Pod Security restricted namespace, no profile fits, and node access remains.

Troubleshooting

Start by checking that you are listening to the right Pod, at its current address: it is the first cause of a capture that shows nothing useful.

SymptomLikely causeSolution
The capture contains no packet from the PodWrong node or wrong cali interfaceRe-read kubectl get pods -o wide, then run ip route get <pod-ip> on the indicated node
The packets carry an address that no longer existsCapture taken before a Pod restart, whose address changedGet the current address, then redo the capture
The .pcap file is empty or unreadableThe capture was interrupted abruptly before the buffer was writtenAdd -U to write each packet immediately
tcpdump refuses to open on the interfaceInsufficient rights on the node, or, with kubectl debug, a runtime that does not grant NET_RAW to the containerUse sudo on the node, or add --profile=netadmin to kubectl debug. In a Pod Security restricted namespace, no profile works (netadmin and general are refused, restricted leaves tcpdump without NET_RAW): capture on the node
kubectl debug returns without displaying packetstcpdump's output does not go through kubectlRead kubectl logs <pod> -c <debugger container>, with the name given by Defaulting debug container name to …
The first kubectl debug run captures 0 packetsPulling the image took longer than the test trafficRun again: the image is cached and the capture sees the traffic
The DNS client shows no complete NXDomainThe capture is too short: a DNS failure takes about 5 s to give upCapture at least 20 s
The RST seems to come from the ServiceThe Service's address translation is undone on returnCapture on the server side to see the real sender
scp to the control node failsThe session account has no key to the workerConnect with the session account, the one that opens ssh to the nodes

Put it into practice

The lab puts three clients of the boutique namespace in failure, with no explicit log: commandes calls catalogue, factures calls paiement and livraisons calls transport. You find each Pod's interface on its node, then you capture its traffic with tcpdump by one of the three methods. Let the capture run at least 20 seconds, to cover several calls, including the one that fails on DNS. You bring each capture back to the control node, in ~/captures/<client>.pcap (for example ~/captures/commandes.pcap), then you write in ~/captures/diagnostic.yaml the cause of each failure: refus (refusal), perte (loss) or dns, the lab expecting these exact French values. Nothing needs to be repaired.

The validation reads the captures back with tcpdump -r: each one must carry its Pod's current address and the signature of its failure (a reset, a SYN sent again without a response, or NXDomain answers). It then compares your diagnosis with the cluster's real failures, drawn at random at each launch, and refuses a diagnosis if a failure has been repaired.

Key points

  • A client's logs do not distinguish a refusal, a loss and a DNS failure: the packets do.
  • A Pod's node-side interface is found with ip route get <pod-ip>; with Calico, it is called cali followed by 11 characters.
  • tcpdump -i <interface> -nn -U -w file writes a capture; tcpdump -nn -r file reads it back.
  • nsenter -t <pid> -n runs the node's tcpdump in the Pod's network namespace, without installing anything in the image.
  • kubectl debug without -i captures without node access, and the capture is read with kubectl logs <pod> -c <debugger container>; it leaves an ephemeral container in the Pod.
  • The default profile is enough for tcpdump when the runtime grants NET_RAW; --profile=netadmin is for when it removes it. Under Pod Security restricted, no profile allows the capture: it is done on the node.
  • A refusal shows a SYN then an [R.] immediately; a loss shows the same SYN sent again with no response; a DNS failure shows NXDomain answers and no SYN.
  • A Pod's capture shows the Service's address on both sides; the DNAT to a Pod is read in iptables -t nat. A refusal's RST therefore seems to come from the Service: only a server-side capture shows the real sender.

Knowledge check

Eight reading and choice questions: finding a Pod's interface, recognizing a refusal, a loss and a DNS failure, capturing without touching the Pod, reading the destination address before the DNAT and capturing under Pod Security restricted.

Knowledge check

Check what you have learned with this interactive quiz

8 questions
8 min
70% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer