Home How to install and configure MetalLB
Post
Cancel

How to install and configure MetalLB

MetalLB is a load-balancer implementation for bare metal Kubernetes clusters, using standard routing protocols

Instal MetalLB using kubernetes manifest:

1
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.14.8/config/manifests/metallb-native.yaml

Configure MetatlLB IP range:

In order to assign an IP to the services, MetalLB must be instructed to do so via the IPAddressPool CR.

1
2
3
4
5
6
7
8
9
10
cat <<EOF | kubectl apply -f -
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  name: first-pool
  namespace: metallb-system
spec:
  addresses:
  - 192.168.229.80-192.168.229.90
EOF

Announce The Service IPs:

Layer 2 mode is the simplest to configure: in many cases, you don’t need any protocol-specific configuration, only IP addresses.

1
2
3
4
5
6
7
8
9
10
cat <<EOF | kubectl apply -f -
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
  name: example
  namespace: metallb-system
spec:
  ipAddressPools:
  - first-pool
EOF

Check if all the resources are deployed in metallb-system namespace:

1
kubectl get all -n metallb-system

Test if LB is assiging the ips:

1
2
kubectl run webapp --image=nginx
kubectl expose pod webapp --port=80 --type=LoadBalancer
This post is licensed under CC BY 4.0 by the author.