Configure metallb with kubernetes running on different vps servers

2k Views Asked by At

I have a running Kubernetes cluster consists of 3 nodes and one mater running on a VPS server, each node and master has its own public IP and floating IP also assigned to it and all these IPs are different from other

I am trying to configure metallb as a load balancer for my Kubernetes cluster but I don't know how can I set the metalLb IPs to range in the configuration file

here are the IPs examples of my servers

  • 115.203.150.255
  • 94.217.238.58
  • 46.12.5.65
  • 76.47.79.44

as you can see here, each IP is different so how can I set the Ip ranges in metallb config map?

Here an example of a config map

apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
    - name: default
      protocol: layer2
      addresses:
      - PUBLIC_IP-PUBLIC_IP    
2

There are 2 best solutions below

2
On BEST ANSWER

In the Metallb documentation there is a mention you can use certain IPs metallb.universe.tf/address-pool. See here

apiVersion: v1
kind: Service
metadata:
  name: nginx
  annotations:
    metallb.universe.tf/address-pool: production-public-ips
spec:
  ports:
  - port: 80
    targetPort: 80
  selector:
    app: nginx
  type: LoadBalancer

The production-public-ips must be configured as showed here.

To configure MetalLB, you should create a configmap with your ips. Since you don't have the range, you can set /32 as subnet for your ips, like the example below.

apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
    - name: production-public-ips
      protocol: layer2
      addresses:
      - 115.203.150.255/32
      - 94.217.238.58/32
      - 46.12.5.65/32
      - 76.47.79.44/32

It should work for your scenario.

1
On

I have the same problem with VPS in different countries, but NGINX ingress controller bare metal considerations doesn't allow IP NODE as IP/32 range in "addresses".

https://kubernetes.github.io/ingress-nginx/deploy/baremetal/

MetalLB requires a pool of IP addresses in order to be able to take ownership of the ingress-nginx Service. This pool can be defined in a ConfigMap named config located in the same namespace as the MetalLB controller. This pool of IPs must be dedicated to MetalLB's use, you can't reuse the Kubernetes node IPs or IPs handed out by a DHCP server.