-
Hi everyone ! I am fairly new to K8s and began recently playing with K3s.
I am trying to understand what does ServiceLB actually do.
So I've dived a bit in how the traefik Service is implemented. But I cannot make sense of what I've found in my cluster.
My external IPs are 10.13.37.1, 10.13.37.2, 10.13.37.3 (not declared in k3s systemd unit, so not printed in the above output).
But when I look at the iptables NAT rules on my k3s host, regarding this service, I get the following (shortened to ease reading):
So this can be sum-up with : when there is a packet for 10.13.37.2:443, it is DNATed to 10.0.3.42:8443 the traefik pod IP. So I wondered what is in the svclb-traefik pods ?
So I can see that those rules are the ones created by the entry script in the container image of ServiceLB and are also the ones mentioned in the doc quoted at the beginning of this post ("These Pods use iptables to forward traffic from the Pod's NodePort, to the Service's ClusterIP address and port"). So this brings me to my final question : Thank you for reading my (way too long) post ! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
ServiceLB exists to make LoadBalancer services work. Without it, or another LoadBalancer controller, services of this type would remain pending. The pods occupy the service's ports on the host, and forward traffic to the service's ClusterIP address, or to the local NodePort, depending on configuration. The IPs of hosts running the svclb pods are advertised in the loadbalancer status. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your answer, your explanation match what I've been able to understand so far. |
Beta Was this translation helpful? Give feedback.
I think your observation is correct, and actually answers your initial question.
The ServiceLB pods never handle TCP/UDP traffic themselves, that's not their purpose. Their entire purpose as I understand it is to set up those DNAT iptables rules on the node. Once the iptables rules are set up, the pod's purpose is fulfilled but they stick around to watch for changes in the service and to remove the rules when the corresponding K8s service is deleted.
kube-proxy
is only responsible for creating iptables rules to handle traffic within the cluster. ServiceLB is an add-on (mostly specific to K3s), only adding a couple of extra rules per LoadBalanced service to handle external traffic.In the …