In this tutorial I will go over how to install and setuo MetalLB for on-prem implementation.

Pre-req

  1. Kubernetes cluster either K8S or K3S.

Installing MetalLB

kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.4/manifests/namespace.yaml
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.4/manifests/metallb.yaml
kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"

NOTE: Above example was used from here

Validate deployments by executing below command:

kubectl get pods -n metallb-system
NAME                          READY   STATUS    RESTARTS   AGE
controller-5854d49f77-p6q5w   1/1     Running   0          106s
speaker-tt29h                 1/1     Running   0          106s
speaker-fggsk                 1/1     Running   0          106s
speaker-wb4nl                 1/1     Running   0          106s
speaker-8gjtj                 1/1     Running   0          106s

Apply network configurations

Create a file called metallb-config.yaml and enter below values:

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

Apply changes:

sudo kubectl apply -f metallb-config.yaml

And you are done!