I'm trying to figure out what the address 10.42.0.1 is resolving to ( or what it belongs to ). I have a very basic k3s cluster with all the defaults enabled ( so the default pod cidr is 10.42.0.0/24 I think ). None of my pods in the cluster are indicating they own that address. When I curl the address from a pod in side of my cluster, it seems to resolve to the traefik deployed load balancer, but I'm trying to figure out the mechanics behind this, mostly for curiosity.
For reference, this is what's currently in the cluster
NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
kube-system helm-install-traefik-crd-rrt22 0/1 Completed 0 19h <none> k8s-master <none> <none>
kube-system helm-install-traefik-lxtmr 0/1 Completed 1 19h <none> k8s-master <none> <none>
kube-system svclb-traefik-9fa171fb-26n2r 2/2 Running 2 (59m ago) 19h 10.42.0.11 k8s-master <none> <none>
kube-system traefik-64f55bb67d-5b4nv 1/1 Running 1 (59m ago) 19h 10.42.0.13 k8s-master <none> <none>
kube-system coredns-77ccd57875-dg92g 1/1 Running 1 (59m ago) 19h 10.42.0.10 k8s-master <none> <none>
kube-system local-path-provisioner-957fdf8bc-vjrxt 1/1 Running 2 (58m ago) 19h 10.42.0.12 k8s-master <none> <none>
kube-system metrics-server-648b5df564-btzmp 1/1 Running 2 (58m ago) 19h 10.42.0.9 k8s-master <none> <none>
kube-system svclb-traefik-9fa171fb-gkktp 2/2 Running 2 (53m ago) 19h 10.42.1.3 k8s-agent <none> <none>
istio-system istiod-5f859db56c-2nsbz 1/1 Running 0 51m 10.42.1.4 k8s-agent <none> <none>
kube-system svclb-istio-ingressgateway-8b3c00eb-zd5cw 0/3 Pending 0 51m <none> <none> <none> <none>
kube-system svclb-istio-ingressgateway-8b3c00eb-cbznb 0/3 Pending 0 51m <none> <none> <none> <none>
istio-system istio-ingressgateway-794b8468f5-pbd8z 1/1 Running 0 51m 10.42.0.14 k8s-master <none> <none>
default client-59f4b74cd-sxct5 2/2 Running 0 19m 10.42.1.6 k8s-agent <none> <none>
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
default kubernetes ClusterIP 10.43.0.1 <none> 443/TCP 19h <none>
kube-system kube-dns ClusterIP 10.43.0.10 <none> 53/UDP,53/TCP,9153/TCP 19h k8s-app=kube-dns
kube-system metrics-server ClusterIP 10.43.65.157 <none> 443/TCP 19h k8s-app=metrics-server
kube-system traefik LoadBalancer 10.43.95.159 10.0.0.4,10.0.0.5 80:31462/TCP,443:31401/TCP 19h app.kubernetes.io/instance=traefik-kube-system,app.kubernetes.io/name=traefik
istio-system istiod ClusterIP 10.43.169.1 <none> 15010/TCP,15012/TCP,443/TCP,15014/TCP 51m app=istiod,istio=pilot
istio-system istio-ingressgateway LoadBalancer 10.43.221.192 <pending> 15021:31385/TCP,80:31036/TCP,443:30469/TCP 51m app=istio-ingressgateway,istio=ingressgateway
default httpd ClusterIP 10.43.254.191 <none> 80/TCP 38m app=httpd
I recently began trying out k3s and wondered this as well.
Your laptop, the host, has a bridge network interface cni0 into the private network that the containers are running in.
Your host's IP is 10.42.0.1 on that private network.
$ ip addr show dev cni0
188: cni0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UP group default qlen 1000
link/ether 06:d3:9b:0c:ee:be brd ff:ff:ff:ff:ff:ff
inet 10.42.0.1/24 brd 10.42.0.255 scope global cni0
valid_lft forever preferred_lft forever
inet6 fe80::4d3:9bff:fe0c:eebe/64 scope link
valid_lft forever preferred_lft forever
Each of those containers have a namespace & routing table and their default gateway to any other IP is your host: 10.42.0.1
$ sudo ip -all netns exec route
...
netns: cni-bd52b5cc-b724-fd82-01c7-bcf0f0d97f49
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 10.42.0.1 0.0.0.0 UG 0 0 0 eth0
10.42.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.42.0.0 10.42.0.1 255.255.0.0 UG 0 0 0 eth0
So, you'll see that traffic will first go through your host, and then say, your home router, on the way to the internet.
$ kubectl exec -it dnsutils -- traceroute google.com.
traceroute to google.com (142.250.114.101), 30 hops max, 46 byte packets
1 10.42.0.1 (10.42.0.1) 0.017 ms 0.014 ms 0.013 ms
2 192.168.1.1 (192.168.1.1) 4.172 ms 1.658 ms 0.721 ms
3 * * *
4 * * *
5 * * *
6 * * *
7 * * *
8 syn-035-146-031-064.res.spectrum.com (35.146.31.64) 82.547 ms 94.083 ms 417.137 ms
9 lag-63.rcr01hstqtx02.netops.charter.com (24.164.209.122) 21.506 ms 523.018 ms 30.659 ms
10 syn-131-150-063-015.res.spectrum.com (131.150.63.15) 42.605 ms syn-024-093-037-083.inf.spectrum.com (24.93.37.83) 40.012 ms syn-131-150-063-015.res.spectrum.com (131.150.63.15) 39.808 ms
11 * * *
12 142.251.237.112 (142.251.237.112) 38.418 ms 72.14.237.46 (72.14.237.46) 45.226 ms 142.251.76.36 (142.251.76.36) 43.672 ms
13 108.170.233.119 (108.170.233.119) 28.496 ms 142.250.60.238 (142.250.60.238) 38.363 ms 108.170.228.91 (108.170.228.91) 28.948 ms
14 108.170.228.82 (108.170.228.82) 39.146 ms 108.170.233.119 (108.170.233.119) 80.752 ms 108.170.233.117 (108.170.233.117) 30.590 ms
15 142.251.76.47 (142.251.76.47) 39.273 ms 108.170.229.87 (108.170.229.87) 32.167 ms 142.250.233.171 (142.250.233.171) 34.306 ms
16 142.250.224.11 (142.250.224.11) 36.546 ms 216.239.43.144 (216.239.43.144) 32.527 ms 209.85.252.210 (209.85.252.210) 28.142 ms
17 142.250.224.27 (142.250.224.27) 40.756 ms 142.250.224.25 (142.250.224.25) 33.482 ms 142.250.224.13 (142.250.224.13) 32.428 ms
18 * * *
19 * * *
20 * * *
21 * * *
22 * * *
23 * * *
24 * * *
25 * * *
26 * * *
27 rr-in-f101.1e100.net (142.250.114.101) 30.500 ms * 36.067 ms
Services and pods have IP addresses.
$ kubectl get services -A
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default kubernetes ClusterIP 10.43.0.1 <none> 443/TCP 2d23h
kube-system kube-dns ClusterIP 10.43.0.10 <none> 53/UDP,53/TCP,9153/TCP 2d23h
kube-system metrics-server ClusterIP 10.43.3.140 <none> 443/TCP 2d23h
$ kubectl get pods -A -o=custom-columns=NAME:metadata.name,STATUS:status.phase,IP:status.podIP
NAME STATUS IP
dnsutils Running 10.42.0.16
coredns-ccb96694c-7vgbs Running 10.42.0.3
local-path-provisioner-5cf85fd84d-g5q46 Running 10.42.0.5
metrics-server-5985cbc9d7-9mkb6 Running 10.42.0.6
I found this YouTube video on this topic informative.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With