// docs / Kubernetes / MetalLB

MetalLB

Now MetalLB, a load balancer for the cluster.

MetalLB brings LoadBalancer-type networking to my bare-metal cluster. It assigns IPs from a reserved range on my LAN, allowing services to:

  • Receive traffic directly
  • Be exposed to other machines on the network via standard IPs and ports

MetalLB makes things like internal dashboards and external web apps easy to access.


helm repo add metallb https://metallb.github.io/metallb
helm repo update
helm install metallb metallb/metallb --namespace metallb-system --create-namespace


kubectl apply -f metallb/local/ipaddresspool.yaml -n metallb-system
kubectl apply -f metallb/local/l2advertisement.yaml -n metallb-system

###############################
# IPAddressPool for MetalLB
###############################
---
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  name: homelab-local-iprange
  namespace: metallb-system
spec:
  addresses:
  - 192.168.56.110-192.168.56.199

###############################
# L2Advertisement for MetalLB
###############################
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
  name: homelab-local-l2advertisement
  namespace: metallb-system

Check the LB works by exposing a service, such as the Longhorn frontend. Create a DNS entry in your provider.

  • longhorn.home.olirowan.local -> 192.168.56.111

Then apply the service manifest


kubectl apply -f longhorn/local/longhorn_service.yaml

###############################
# Service for Longhorn
###############################
---
apiVersion: v1
kind: Service
metadata:
  name: longhorn-frontend-svc
  namespace: longhorn-system
spec:
  selector:
    app: longhorn-ui
  type: LoadBalancer
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 8000
  loadBalancerIP: 192.168.56.111

Check the URL and you should see the Longhorn frontend.