Using multiple metallb IP address pools with Traefik

I have metallb installed and providing 2 IP address pools:

---
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  name: pool-b
  namespace: metallb
spec:
  addresses:
  - 172.16.1.100/32
---
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  name: pool-b
  namespace: metallb
spec:
  addresses:
  - 172.16.2.100/32
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
  name: l2advert
  namespace: metallb
spec:
   ipAddressPools:
   - pool-a
   - pool-b

There are different dns names associated with each pool's address - i.e. a.example.com -> pool-a and b.example.com -> pool-b.

I can't work out how to set up traefik to use both pools, and then be able to set up IngressRoutes which reference either or both of them.

If I run kubectl get services -n traefik I see it has bound to pool-a so I know the basics are working, but I'm obviously missing the 'next step' to use both pools.

Any advice appreciated!

I eventually worked this one out, and it's actually relatively simple.

The solution is to create 2 services which reference the traefik deployment - i.e.:

apiVersion: v1
kind: Service
metadata:
  annotations:
    # Set different pool names in each service  
    metallb.universe.tf/address-pool: pool-a
  name: traefik-pool-a
  namespace: traefik
spec:
  ports:
  - name: web
    port: 80
    protocol: TCP
    targetPort: web
  - name: websecure
    port: 443
    protocol: TCP
    targetPort: websecure
  selector:
    app.kubernetes.io/name: traefik
    # Optionally set a specific ip in the pool
    # loadBalancerIP: 129.215.215.158
  type: LoadBalancer

Each service will then redirect traffic from "it's" ip address to the pod, where the IngressRoute can look at the Host etc values as usual.

Note: if you are deploying traefik using Helm then you may want to disable the 'default' service and expressly create both services yourself. You can do this by changing the Helm values.yaml to have:

service:
  enabled: false

(Otherwise you will need to update values such as deployment.annotations to match the above).

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.