I have a bare metal cluster with 3 servers which are publicly available but each one has a totally different ip address. I have my DNS entry to point to all 3 hosts - so traffic can received by any host. I have all of them connected via a vlan. Now I would like that traffic coming from internet is forwarded to the k8s node, where the service is running:
browse "mysrv.mydomain.com"
|
.-~|~-.
.- ~ ~-( | )_ _
/ v ~ -.
| | \
\ | .'
~- . _____|_______ . -~
|
| request can go to any service
|
+----------->--------------+------------>-------------+
v v v
| | |
| | |
+---------------------+ +---------------------+ +---------------------+
| host01 | | host02 | | host03 |
| k8s master | | k8s node | | k8s node |
| | | | | |
| Pub.Ip: x.x.x.x | | Pub.Ip: y.y.y.y | | Pub.Ip: z.z.z.z |
| | | | | |
| VlanIp: 192.168.0.1 |----| VlanIp: 192.168.0.2 |----| VlanIp: 192.168.0.3 |
+---------------------+ +---------------------+ +---------------------+
I understand that I have to use metallb, thus I followed the setup description here: https://kubernetes.github.io/ingress-nginx/deploy/baremetal/#a-pure-software-solution-metallb. I can successfully deploy the nginx load balancer but I am not user how to configure metallb.
apiVersion: v1
kind: ConfigMap
metadata:
namespace: metallb-system
name: config
data:
config: |
address-pools:
- name: default
protocol: layer2
addresses:
- x.x.x.x,y.y.y.y,z.z.z.z
- name: internal
protocol: layer2
addresses:
- 192.168.0.200-192.168.0.210
Using default
results in a nginx
services which never gets an external Ip
> kubectl get svc -n ingress-nginx ingress-nginx
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
ingress-nginx LoadBalancer 10.107.136.170 <pending> 80:30152/TCP,443:30276/TCP 43h
Using internal
works but only when I am connected to the internal vlan.
Any hint would be useful on how I can make my scenario work.
Your environment is not a good fit for MetalLB - you would need IPs that can be assigned to any node (floating IP / service IP). For your situation a reverse proxy, which is called Ingress in Kubernetes, would be a better solution.