NetworkingLesson 4 of 8
  1. The pod network model, not reconciled
  2. Services, not reconciled
  3. EndpointSlices and kube-proxy, not reconciled
  4. Following a packet through the node, not reconciled
    1. Two ends of a veth
    2. Routes, not bridges
    3. The cluster IP is a rule
    4. conntrack remembers
    5. Leaving the cluster
    6. Policy on the path
    7. The nftables data path
    8. Predict, then read
  5. Cluster DNS with CoreDNS, not reconciled
  6. Gateway API and the frozen Ingress API, not reconciled
  7. NetworkPolicies, not reconciled
  8. gRPC, service mesh and mTLS, not reconciled

Following a packet through the node

Follow one request from a client pod to a Service on a kind node, through the veth, the routing table, kube-proxy's DNAT, conntrack, kindnet's policy queue and the masquerade rules, reading each with the command that shows it.

  • 24 min
  • 5 objectives
  • 8 scenes

Shows the lesson one block at a time. Arrow keys step, number keys jump to a scene, and Escape returns to the page where you were.

The Service lessons describe what happens to a request. This one watches it happen, on the node that sends it. The cluster runs three web pods behind the Service web, a client pod with network tools on kx-worker3, and a NetworkPolicy, web-ingress, that lets only app=client pods reach web on port 80. Every command runs on kx-worker3 unless it says otherwise.

Reconcile, in 8 scenes

Two ends of a veth

A pod’s network is a network namespace with one interface, eth0. The ptp plugin that kindnet configures creates a veth pair for each pod: one end becomes the pod’s eth0, the other stays in the node’s namespace with a name like veth3251d026. Seen from inside, the pod has an ordinary /24 address; seen from the node, the host end carries the node’s gateway address as a /32, the same on every host-side veth.

The client pod from both sides
kubectl get pods -o wide
NAME                   READY   STATUS    RESTARTS   AGE   IP           NODE         NOMINATED NODE   READINESS GATES
client                 1/1     Running   0          30s   10.244.3.2   kx-worker3   <none>           <none>
web-84cb89689b-dq87d   1/1     Running   0          30s   10.244.3.3   kx-worker3   <none>           <none>
web-84cb89689b-nshlv   1/1     Running   0          30s   10.244.2.2   kx-worker2   <none>           <none>
web-84cb89689b-pggpj   1/1     Running   0          30s   10.244.1.3   kx-worker    <none>           <none>
docker exec kx-worker3 ip -br addr
lo               UNKNOWN        127.0.0.1/8 ::1/128 
tunl0@NONE       DOWN           
gre0@NONE        DOWN           
gretap0@NONE     DOWN           
erspan0@NONE     DOWN           
ip_vti0@NONE     DOWN           
ip6_vti0@NONE    DOWN           
sit0@NONE        DOWN           
ip6tnl0@NONE     DOWN           
ip6gre0@NONE     DOWN           
eth0@if2033      UP             172.18.0.5/16 fc00:f853:ccd:e793::5/64 fe80::3cdd:17ff:febd:a391/64 
veth249012b5@if11 UP             10.244.3.1/32 fe80::208f:18ff:fefa:1c12/64 
vethf2213491@if11 UP             10.244.3.1/32 fe80::5cd0:7aff:fe62:5075/64
docker exec kx-worker3 sh -c 'nsenter -t $(pidof -s sleep) -n ip addr'
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host proto kernel_lo 
       valid_lft forever preferred_lft forever
2: tunl0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
    link/ipip 0.0.0.0 brd 0.0.0.0
3: gre0@NONE: <NOARP> mtu 1476 qdisc noop state DOWN group default qlen 1000
    link/gre 0.0.0.0 brd 0.0.0.0
4: gretap0@NONE: <BROADCAST,MULTICAST> mtu 1462 qdisc noop state DOWN group default qlen 1000
    link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
5: erspan0@NONE: <BROADCAST,MULTICAST> mtu 1450 qdisc noop state DOWN group default qlen 1000
    link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
6: ip_vti0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
    link/ipip 0.0.0.0 brd 0.0.0.0
7: ip6_vti0@NONE: <NOARP> mtu 1428 qdisc noop state DOWN group default qlen 1000
    link/tunnel6 :: brd :: permaddr 7c88:4891:177c::
8: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
    link/sit 0.0.0.0 brd 0.0.0.0
9: ip6tnl0@NONE: <NOARP> mtu 1452 qdisc noop state DOWN group default qlen 1000
    link/tunnel6 :: brd :: permaddr 877b:dff2:5287::
10: ip6gre0@NONE: <NOARP> mtu 1448 qdisc noop state DOWN group default qlen 1000
    link/gre6 :: brd :: permaddr f334:4898:78f3::
11: eth0@if12: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 65535 qdisc noqueue state UP group default qlen 1000
    link/ether 7e:3c:a8:61:15:66 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.244.3.2/24 brd 10.244.3.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::7c3c:a8ff:fe61:1566/64 scope link proto kernel_ll 
       valid_lft forever preferred_lft forever

nsenter -t <pid> -n runs a command in the network namespace of a process, here client’s sleep, using the node’s own ip binary, so it works whatever the pod’s image contains. The @if suffix pairs the two ends by interface index. Inside client, eth0@if12 names its host veth’s index in the node’s namespace; on the node, both veths read @if11, because each pod’s eth0 is interface 11 in its own namespace. No interface on the node, or anywhere, has the Service’s cluster IP.

Routes, not bridges

A packet leaves eth0 for the pod’s default gateway, which is the host end of its veth, and from there the node’s routing table decides where it goes.

Routes on both sides of the veth
docker exec kx-worker3 sh -c 'nsenter -t $(pidof -s sleep) -n ip route'
default via 10.244.3.1 dev eth0 
10.244.3.0/24 via 10.244.3.1 dev eth0 src 10.244.3.2 
10.244.3.1 dev eth0 scope link src 10.244.3.2
docker exec kx-worker3 ip route
default via 172.18.0.1 dev eth0 
10.244.0.0/24 via 172.18.0.2 dev eth0 
10.244.1.0/24 via 172.18.0.3 dev eth0 
10.244.2.0/24 via 172.18.0.4 dev eth0 
10.244.3.2 dev veth249012b5 scope host 
10.244.3.3 dev vethf2213491 scope host 
172.18.0.0/16 dev eth0 proto kernel scope link src 172.18.0.5

Inside the pod, everything goes via 10.244.3.1. On the node there are two kinds of routes. Each local pod has a /32 host route through its own veth, which the ptp plugin adds when the pod starts. Each other node has a /24 route to its pod range via that node’s eth0 address, which kindnet adds from the Node objects’ spec.podCIDR. All kind nodes are containers on one Docker network, so a packet for another node’s pod is routed to that node directly, with no tunnel and no encapsulation.

The cluster IP is a rule

client asks for web, and DNS answers with the cluster IP. The packet’s destination is that address, and the node has no route for the Service range other than the default. Before routing, in the nat table’s PREROUTING chain, kube-proxy’s rules rewrite it.

From cluster IP to a pod address
kubectl get service web
NAME   TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE
web    ClusterIP   10.98.108.133   <none>        80/TCP    30s
docker exec kx-worker3 sh -c 'iptables -t nat -S KUBE-SERVICES | grep default/web'
-A KUBE-SERVICES -d 10.98.108.133/32 -p tcp -m comment --comment "default/web:http cluster IP" -m tcp --dport 80 -j KUBE-SVC-CDGGSHYLG3RE2FKL
docker exec kx-worker3 iptables -t nat -S KUBE-SVC-CDGGSHYLG3RE2FKL
-N KUBE-SVC-CDGGSHYLG3RE2FKL
-A KUBE-SVC-CDGGSHYLG3RE2FKL ! -s 10.244.0.0/16 -d 10.98.108.133/32 -p tcp -m comment --comment "default/web:http cluster IP" -m tcp --dport 80 -j KUBE-MARK-MASQ
-A KUBE-SVC-CDGGSHYLG3RE2FKL -m comment --comment "default/web:http -> 10.244.1.3:80" -m statistic --mode random --probability 0.33333333349 -j KUBE-SEP-BHMTFEMIGCOTLSJP
-A KUBE-SVC-CDGGSHYLG3RE2FKL -m comment --comment "default/web:http -> 10.244.2.2:80" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-MODFGJMBXTNUPWPX
-A KUBE-SVC-CDGGSHYLG3RE2FKL -m comment --comment "default/web:http -> 10.244.3.3:80" -j KUBE-SEP-TN2664DP7XCOHO6B
docker exec kx-worker3 sh -c 'iptables-save -t nat | grep default/web:http | grep DNAT'
-A KUBE-SEP-BHMTFEMIGCOTLSJP -p tcp -m comment --comment "default/web:http" -m tcp -j DNAT --to-destination 10.244.1.3:80
-A KUBE-SEP-MODFGJMBXTNUPWPX -p tcp -m comment --comment "default/web:http" -m tcp -j DNAT --to-destination 10.244.2.2:80
-A KUBE-SEP-TN2664DP7XCOHO6B -p tcp -m comment --comment "default/web:http" -m tcp -j DNAT --to-destination 10.244.3.3:80

KUBE-SERVICES matches the cluster IP, protocol and port and jumps to the port’s KUBE-SVC-* chain. That chain draws one KUBE-SEP-* chain per connection with statistic --mode random, and the KUBE-SEP-* chain DNATs to one pod address and port. The rule ! -s 10.244.0.0/16 ... -j KUBE-MARK-MASQ marks packets to the cluster IP from outside the pod network for source NAT later, so their replies come back through this node. Traffic from host processes takes the same path through the OUTPUT chain. EndpointSlices and kube-proxy covers how these chains follow the endpoints.

conntrack remembers

Only the first packet of a connection meets those rules. The kernel’s connection tracker records the translation, and every later packet of the flow, in both directions, is rewritten from that record without touching the nat table again.

One request, one conntrack entry
kubectl exec client -- curl -s web | grep -e Hostname -e 'IP: 10'
Hostname: web-84cb89689b-dq87d
IP: 10.244.3.3
docker exec kx-worker3 conntrack -L -p tcp --dport 80
tcp      6 120 TIME_WAIT src=10.244.3.2 dst=10.98.108.133 sport=54383 dport=80 src=10.244.3.3 dst=10.244.3.2 sport=80 dport=54383 [ASSURED] mark=0 use=1
conntrack v1.4.8 (conntrack-tools): 1 flow entries have been shown.

An entry holds two tuples. The first is the connection as client sent it, to the cluster IP. The second is the reply the kernel expects, from the endpoint the rules picked, so the reply tuple’s src is the pod that answered, and it matches the IP that pod printed. When the reply comes back, conntrack rewrites its source to the cluster IP, so client sees an answer from the address it called. [ASSURED] means packets were seen both ways; TIME_WAIT and its countdown in seconds keep the entry for late packets after the connection closed.

Send a request from the dock, kubectl exec client -- curl -s web, then walk it: the cluster IP, the rule that drew the endpoint, the DNAT, the route to the pod, and the conntrack entry that carries the reply back.

ExplainerA packet through the node

client to Service web3 ready endpoints; send a request to draw one

kubectl exec client -- curl -s -m 2 -o /dev/null -w '%{http_code}\n' http://web

Resolve webLeave the podMatch the cluster IPDraw an endpointRewrite the destinationRoute on this nodeInto the endpoint's podThe reply finds its way back

kubectl exec client -- cat /etc/resolv.confdocker exec kx-worker3 ip routedocker exec kx-worker3 iptables-save -t natdocker exec kx-worker3 iptables-save -t natdocker exec kx-worker3 iptables-save -t natdocker exec kx-worker3 ip routedocker exec kx-worker3 ip routedocker exec kx-worker3 conntrack -L -p tcp -d 10.98.108.133

search default.svc.cluster.local svc.cluster.local cluster.local
nameserver 10.96.0.10
options ndots:5

curl in client asks the nameserver in its resolv.conf for web. The search list makes it web.default.svc.cluster.local, and CoreDNS answers with the Service's cluster IP, 10.98.108.133.The packet leaves eth0 inside the pod and comes out of veth249012b5 in kx-worker3's network namespace, addressed to 10.98.108.133:80. No interface anywhere holds that address.PREROUTING jumps to KUBE-SERVICES, where kube-proxy wrote one rule per Service port: 10.98.108.133 port 80 goes to KUBE-SVC-CDGGSHYLG3RE2FKL.KUBE-SVC-CDGGSHYLG3RE2FKL holds one rule per ready endpoint, 3 of them. Each rule but the last matches with probability 1/(remaining), so every endpoint is equally likely. Send a request: kube-proxy's draw happens once per connection.The winning rule jumps to the endpoint's KUBE-SEP chain, whose DNAT rewrites the destination to the pod's IP and port. Send a request: kube-proxy's draw happens once per connection.The rewritten packet is routed by its new destination. Send a request: kube-proxy's draw happens once per connection.The endpoint's node sends it down the pod's veth. Send a request: kube-proxy's draw happens once per connection.conntrack keeps one entry per connection, with the original destination and the reply's source. Send a request: kube-proxy's draw happens once per connection.

Step 1 of 8: Resolve web. curl in client asks the nameserver in its resolv.conf for web. The search list makes it web.default.svc.cluster.local, and CoreDNS answers with the Service's cluster IP, 10.98.108.133.

  1. Resolve web

    kubectl exec client -- cat /etc/resolv.conf

    search default.svc.cluster.local svc.cluster.local cluster.local
    nameserver 10.96.0.10
    options ndots:5
    

    curl in client asks the nameserver in its resolv.conf for web. The search list makes it web.default.svc.cluster.local, and CoreDNS answers with the Service's cluster IP, 10.98.108.133.

  2. Leave the pod

    docker exec kx-worker3 ip route

    default via 172.18.0.1 dev eth0 
    10.244.0.0/24 via 172.18.0.2 dev eth0 
    10.244.1.0/24 via 172.18.0.3 dev eth0 
    10.244.2.0/24 via 172.18.0.4 dev eth0 
    10.244.3.2 dev veth249012b5 scope host 
    10.244.3.3 dev vethf2213491 scope host 
    172.18.0.0/16 dev eth0 proto kernel scope link src 172.18.0.5 
    

    The packet leaves eth0 inside the pod and comes out of veth249012b5 in kx-worker3's network namespace, addressed to 10.98.108.133:80. No interface anywhere holds that address.

  3. Match the cluster IP

    docker exec kx-worker3 iptables-save -t nat

    -A PREROUTING -m comment --comment "kubernetes service portals" -j KUBE-SERVICES
    -A KUBE-SERVICES -d 10.98.108.133/32 -p tcp -m comment --comment "default/web:http cluster IP" -m tcp --dport 80 -j KUBE-SVC-CDGGSHYLG3RE2FKL
    

    PREROUTING jumps to KUBE-SERVICES, where kube-proxy wrote one rule per Service port: 10.98.108.133 port 80 goes to KUBE-SVC-CDGGSHYLG3RE2FKL.

  4. Draw an endpoint

    docker exec kx-worker3 iptables-save -t nat

    -A KUBE-SVC-CDGGSHYLG3RE2FKL ! -s 10.244.0.0/16 -d 10.98.108.133/32 -p tcp -m comment --comment "default/web:http cluster IP" -m tcp --dport 80 -j KUBE-MARK-MASQ
    -A KUBE-SVC-CDGGSHYLG3RE2FKL -m comment --comment "default/web:http -> 10.244.1.3:80" -m statistic --mode random --probability 0.33333333349 -j KUBE-SEP-BHMTFEMIGCOTLSJP
    -A KUBE-SVC-CDGGSHYLG3RE2FKL -m comment --comment "default/web:http -> 10.244.2.2:80" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-MODFGJMBXTNUPWPX
    -A KUBE-SVC-CDGGSHYLG3RE2FKL -m comment --comment "default/web:http -> 10.244.3.3:80" -j KUBE-SEP-TN2664DP7XCOHO6B
    

    KUBE-SVC-CDGGSHYLG3RE2FKL holds one rule per ready endpoint, 3 of them. Each rule but the last matches with probability 1/(remaining), so every endpoint is equally likely. Send a request: kube-proxy's draw happens once per connection.

  5. Rewrite the destination

    docker exec kx-worker3 iptables-save -t nat

    No lines match.

    The winning rule jumps to the endpoint's KUBE-SEP chain, whose DNAT rewrites the destination to the pod's IP and port. Send a request: kube-proxy's draw happens once per connection.

  6. Route on this node

    docker exec kx-worker3 ip route

    default via 172.18.0.1 dev eth0 
    10.244.0.0/24 via 172.18.0.2 dev eth0 
    10.244.1.0/24 via 172.18.0.3 dev eth0 
    10.244.2.0/24 via 172.18.0.4 dev eth0 
    10.244.3.2 dev veth249012b5 scope host 
    10.244.3.3 dev vethf2213491 scope host 
    172.18.0.0/16 dev eth0 proto kernel scope link src 172.18.0.5 
    

    The rewritten packet is routed by its new destination. Send a request: kube-proxy's draw happens once per connection.

  7. Into the endpoint's pod

    docker exec kx-worker3 ip route

    No lines match.

    The endpoint's node sends it down the pod's veth. Send a request: kube-proxy's draw happens once per connection.

  8. The reply finds its way back

    docker exec kx-worker3 conntrack -L -p tcp -d 10.98.108.133

    No lines match.

    conntrack keeps one entry per connection, with the original destination and the reply's source. Send a request: kube-proxy's draw happens once per connection.

Send a request from a pod to the Service, then step through what the node does with it: the cluster IP rule, kube-proxy's random draw between endpoints, the DNAT, the route to the endpoint's node and conntrack's rewrite of the reply. Each step shows the real lines from iptables-save, ip route and conntrack.

Leaving the cluster

Two sets of rules in the nat table’s POSTROUTING chain rewrite source addresses, and they answer different questions.

Who gets masqueraded
docker exec kx-worker3 sh -c 'iptables-save -t nat | grep KIND-MASQ'
:KIND-MASQ-AGENT - [0:0]
-A POSTROUTING -m addrtype ! --dst-type LOCAL -m comment --comment "kind-masq-agent: ensure nat POSTROUTING directs all non-LOCAL destination traffic to our custom KIND-MASQ-AGENT chain" -j KIND-MASQ-AGENT
-A KIND-MASQ-AGENT -d 10.244.0.0/16 -m comment --comment "kind-masq-agent: local traffic is not subject to MASQUERADE" -j RETURN
-A KIND-MASQ-AGENT -m comment --comment "kind-masq-agent: outbound traffic is subject to MASQUERADE (must be last in chain)" -j MASQUERADE
docker exec kx-worker3 iptables -t nat -S KUBE-POSTROUTING
-N KUBE-POSTROUTING
-A KUBE-POSTROUTING -m mark ! --mark 0x4000/0x4000 -j RETURN
-A KUBE-POSTROUTING -j MARK --set-xmark 0x4000/0x0
-A KUBE-POSTROUTING -m comment --comment "kubernetes service traffic requiring SNAT" -j MASQUERADE --random-fully

kindnet’s KIND-MASQ-AGENT chain handles traffic leaving the pod network. Packets for any address in 10.244.0.0/16 return early and keep the pod’s source address, so a pod on another node, and that node’s NetworkPolicy, see the real client. Everything else headed off the node, to the internet or to the Docker network, is masqueraded to the node’s address, because nothing outside the cluster has a route back to 10.244.0.0/16.

kube-proxy’s KUBE-POSTROUTING masquerades only packets that KUBE-MARK-MASQ marked with 0x4000: traffic to a cluster IP from outside the pod network, node port traffic with externalTrafficPolicy: Cluster, and hairpin traffic from a pod to itself through its own Service. Pod-to-cluster-IP traffic carries no mark, which is why web sees client’s own address.

Policy on the path

kindnet enforces NetworkPolicy with the nftables table inet kindnet-network-policies. The set podips-v4 holds this node’s pods that some policy isolates, here the web pod; the chains queue the first packet of each connection to or from those addresses to NFQUEUE 101, where kindnet decides in user space, and mark accepted connections with ct label 28 so their later packets are accepted in the kernel.

One client allowed, one dropped
docker exec kx-worker3 sh -c 'nft list table inet kindnet-network-policies | head -5'
table inet kindnet-network-policies {
	set podips-v4 {
		type ipv4_addr
		elements = { 10.244.3.3 }
	}
docker exec kx-worker3 sh -c 'nft list table inet kindnet-network-policies | grep hook'
		type filter hook postrouting priority srcnat - 5; policy accept;
		type filter hook input priority srcnat + 1; policy accept;
		type filter hook prerouting priority dstnat + 5; policy accept;
kubectl run intruder --image=nicolaka/netshoot:v0.16 -- sleep infinity
pod/intruder created
kubectl wait --for=condition=Ready pod/intruder --timeout=60s
pod/intruder condition met
kubectl exec intruder -- curl -s -m 3 web
command terminated with exit code 28
kubectl exec client -- curl -s -m 3 web | grep Hostname
Hostname: web-84cb89689b-nshlv

Where the verdict happens matters. The postrouting chain hooks in at priority srcnat - 5: after kube-proxy’s DNAT in prerouting and after the routing decision, before any source NAT. The packet it judges has pod addresses at both ends, so a policy must name the pods behind a Service, never the Service. Each node judges traffic to and from its own isolated pods, so intruder’s connection is dropped on the node of whichever web pod the rules picked, and curl reports nothing but exit code 28, its timeout. A dropped packet looks like a slow network, not a refusal. Network policies covers writing the policies themselves.

The nftables data path

kube-proxy’s nftables mode, GA since 1.33, does the same job with one lookup instead of a walk through rules. It writes table ip kube-proxy, where a verdict map, service-ips, keyed by destination address, protocol and port, jumps straight to a service-* chain for the Service port; that chain picks an endpoint with numgen random mod N vmap, and each endpoint-* chain does the dnat to. The cost of a lookup stays flat as Services grow, where KUBE-SERVICES is a list that the first packet of every connection walks in order. conntrack, the routes, kindnet’s masquerade and its policy table are the same in either mode.

This lesson’s cluster runs kube-proxy in iptables mode, so nft list table ip kube-proxy finds nothing here. On your own machine, a kind cluster created with networking.kubeProxyMode: nftables shows the table, and nft list map ip kube-proxy service-ips the map.

Predict, then read

A curl through a Service tells you which pod answered, and conntrack on the client’s node tells you which endpoint the rules picked. They must agree. Run the request, read the pod’s IP line, predict the reply tuple’s src, then check it.

Predict the endpoint, then read it in conntrack

  1. kubectl --context kind-kx create deployment echo --image=traefik/whoami:v1.12 --replicas=3 --port=80
  2. kubectl --context kind-kx expose deployment echo --port=80
  3. kubectl --context kind-kx run probe --image=nicolaka/netshoot:v0.16 -- sleep infinity
  4. kubectl --context kind-kx rollout status deployment echo
  5. kubectl --context kind-kx wait --for=condition=Ready pod/probe --timeout=60s
  6. kubectl --context kind-kx get pods -l app=echo -o wide
  7. kubectl --context kind-kx exec probe -- curl -s echo | grep -e Hostname -e 'IP: 10'
  8. docker exec $(kubectl --context kind-kx get pod probe -o jsonpath='{.spec.nodeName}') conntrack -L -p tcp --dport 80
  9. kubectl --context kind-kx delete deployment echo
  10. kubectl --context kind-kx delete service echo
  11. kubectl --context kind-kx delete pod probe --now

For your own kind cluster kx: copy a command and paste it into your terminal. Run in the simulator runs the same command in this page's simulated cluster instead; nothing on this page touches your machine. The conntrack command runs on whichever node probe landed on. The entry's first tuple goes to echo's cluster IP; the second comes from the pod address curl printed. Run the curl a few times and each new connection may draw a different endpoint.

Actual state

Check your understanding

5 checks

Your first answer to each check is the one that counts. After a miss you can answer again; passing every check reconciles the lesson.

  1. Check 1 of 5

    On a node, ip -br addr lists veth1a2b3c4d@if11 with 10.244.3.1/32. What is it?

  2. Check 2 of 5

    Check runs your command on a private cluster; what it prints shows here.

  3. Check 3 of 5

    Why does the second packet of a TCP connection to a cluster IP not walk the KUBE-SVC rules again?

  4. Check 4 of 5

    A pod on kind sends a packet to another node's pod, and another to an address outside the cluster. Which leaves the node with the node's address as its source?

  5. Check 5 of 5

    kindnet's policy chain runs at postrouting priority srcnat - 5. What address does it see as the destination of a connection to a cluster IP?

Lesson not yet reconciled

Desired: 5 objectives, 0 metReconciled: 5 of 5 objectives met

  • Find a pod's network namespace from the node and match its eth0 to the host's veth. (not yet met)
  • Read a node's routes for local pods and for other nodes' pod ranges. (not yet met)
  • Trace a cluster IP through KUBE-SERVICES, KUBE-SVC and KUBE-SEP to a DNAT. (not yet met)
  • Read a connection's original and reply tuples in conntrack and name the endpoint it reached. (not yet met)
  • Say which traffic kindnet masquerades and where on the path NetworkPolicy is judged. (not yet met)

Pass every check above to reconcile this lesson.

Every check has passed, so the desired state is met. First-try accuracy: 0 of 5. This lesson's review cards are in your queue.

Sources

Checked against kubernetes.io, kernel.org and upstream source for Kubernetes 1.37 on .

  1. kubernetes.io/docs/reference/networking/virtual-ips
  2. kubernetes.io/docs/concepts/services-networking/service
  3. kubernetes.io/docs/concepts/services-networking/network-policies
  4. kubernetes.io/docs/concepts/cluster-administration/networking
  5. kind.sigs.k8s.io/docs/user/configuration#kube-proxy-mode
  6. github.com/kubernetes/kubernetes/blob/v1.37.0/pkg/proxy/iptables/proxier.go
  7. github.com/kubernetes/kubernetes/blob/v1.37.0/pkg/proxy/nftables/proxier.go
  8. github.com/kubernetes-sigs/kind/tree/v0.33.0/images/kindnetd
  9. github.com/kubernetes-sigs/kube-network-policies
  10. github.com/containernetworking/plugins/blob/main/plugins/main/ptp/ptp.go
  11. conntrack-tools.netfilter.org/manual.html

Following a packet through the node

↓ ↑ step, 1 to 8 scene, Esc leave

kind cluster kxLast command: Nothing run yet