Kubernetes On-Prem Load Balancing implementation using MetalLB

Kubernetes pre-load balancing implementation using metallb.

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


  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: The above example was used from here

Validate deployments by executing the 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 the following values:

apiVersion: v1
kind: ConfigMap
    namespace: metallb-system
    name: config
  config: |
    - name: default
      protocol: layer2

Apply changes:

sudo kubectl apply -f metallb-config.yaml

And you are done!

Leave a Comment

Scroll to Top