I'm trying to wrap my head around exposing internal loadbalancing to outside world on bare metal k8s cluster.
Let's say we have a basic cluster:
Some master nodes and some worker nodes, that has two interfaces, one public facing (eth0) and one local(eth1) with ip within 192.168.0.0/16 network
Deployed MetalLB and configured 192.168.200.200-192.168.200.254 range for its internal ips
Ingress controller with its service with type LoadBalancer
MetalLB now should assign one of the ips from 192.168.200.200-192.168.200.254 to ingress service, as of my current understanding.
But I have some following questions:
On every node I could curl ingress controller externalIP (as long as they are reachable on eth1) with host header attached and get a response from a service thats configured in coresponding ingress resource or is it valid only on node where Ingress pods are currently placed?
What are my options to pass incoming external traffic to eth0 to an ingress listening on eth1 network?
Is it possible to forward requests saving source ip address or attaching X-Forwarded-For header is the only option?
Assuming that we are talking about
Metallb
usingLayer2
.Addressing the following questions:
Dividing the solution on the premise of preserving the source IP, this question could go both ways:
Preserve the source IP address
To do that you would need to set the
Service of type LoadBalancer
of yourIngress controller
to support "Local traffic policy" by setting (in yourYAML
manifest):.spec.externalTrafficPolicy: Local
This setup will be valid as long as on each
Node
there is replica of yourIngress controller
as all of the networking coming to your controller will be contained in a singleNode
.Citing the official docs:
Do not preserve the source IP address
If your use case does not require you to preserve the source IP address, you could go with the:
.spec.externalTrafficPolicy: Cluster
This setup won't require that the replicas of your
Ingress controller
will be present on eachNode
.Citing the official docs:
Addressing the 2nd question:
Metallb listen by default on all interfaces, all you need to do is to specify the address pool from this
eth
within Metallb config.You can find more reference on this topic by following:
An example of such configuration, could be following: