Skip to content

Metallb setup

We will use metallb to expose our services to the outside world.

Install metallb

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

Configure metallb

yml
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  name: default-pool
  namespace: metallb-system
spec:
  addresses:
    - 192.168.1.200-192.168.1.250
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
  name: default
  namespace: metallb-system
spec:
  ipAddressPools:
    - default-pool

Example of metallb service

yml
apiVersion: v1
kind: Namespace
metadata:
  name: my-ingresses-apps
---
apiVersion: v1
kind: Service
metadata:
  name: my-app
  namespace: my-ingresses-apps
  annotations:
    metallb.universe.tf/address-pool: default-pool
spec:
  type: LoadBalancer
  ports:
    - name: http
      port: 80
      targetPort: 80
      protocol: TCP
  selector:
    app: my-app

NAT

On your router, you need to set up a NAT rule to forward the traffic from the public IP to the metallb IP.

references