Metal LB

Quick examples on configuring this operator. I’m assuming the operator is installed.

  1. From the OCP Console select Operators ‣ OperatorHub. In the search box type “metallb”.

    ../_images/metallb-operatorhub.png
  2. Click Install. Leave defaults and Click Install again.

    ../_images/metallb-install.png ../_images/metallb-install2.png
  3. After operator installation completes, click “View Operator”.

  4. Click “Create instance” to create the Metal LB instance.

    ../_images/metallb-instance.png
  5. Accept the defaults and click “Create” at the bottom of the page.

    ../_images/metallb-instance2.png

L2

Tip

To expose the VIP with a service see: Quick App Deployment

There you’ll find how to deploy a generic httpd service and expose a LoadBalancer Service.

Important

You need a LoadBalancer Service for this to work.

  1. Create the IP Address Pool

    cat << EOF | oc create -f -
    apiVersion: metallb.io/v1beta1
    kind: IPAddressPool
    metadata:
      name: ipaddrpool-v132
      namespace: metallb-system
    spec:
      addresses:
      - 192.168.132.225-192.168.132.229
    EOF
    
  2. Create the L2 Advertisement

    cat << EOF | oc create -f -
    kind: L2Advertisement
    apiVersion: metallb.io/v1beta1
    metadata:
      name: l2-adv-v132
      namespace: metallb-system
    spec:
      ipAddressPools:
      - ipaddrpool-v132
    EOF
    

BGP

  1. Create the IP Address Pool

    cat << EOF | oc create -f -
    apiVersion: metallb.io/v1beta1
    kind: IPAddressPool
    metadata:
      name: ipaddrpool-v245
      namespace: metallb-system
    spec:
      addresses:
      - 192.168.245.201-192.168.245.225
    EOF
    
  2. Create the BGP Peer

    cat << EOF | oc create -f -
    kind: BGPPeer
    apiVersion: metallb.io/v1beta2
    metadata:
      name: bgp-peer-v245
      namespace: metallb-system
    spec:
      myASN: 64512
      peerASN: 64512
      peerAddress: 192.168.132.1
    EOF
    
  3. Creat the BGP Advertisement

    cat << EOF | oc create -f -
    kind: BGPAdvertisement
    apiVersion: metallb.io/v1beta1
    metadata:
      name: bgp-adv-v245
      namespace: metallb-system
    spec:
      ipAddressPools:
      - ipaddrpool-v245
      peers:
      - bgp-peer-v245
    EOF