Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure metallb with kubernetes running on different vps servers

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    
like image 355
tarek salem Avatar asked Oct 17 '25 14:10

tarek salem


1 Answers

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.

like image 105
Mr.KoopaKiller Avatar answered Oct 20 '25 13:10

Mr.KoopaKiller



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!