Install MetalLB Operator

  1. Create the MetalLB Operator namespace:

    cat << EOF | oc apply -f -
    apiVersion: v1
    kind: Namespace
    metadata:
      name: metallb-system
    EOF
  2. Verify the namespace is created:

    oc get ns metallb-system  -o custom-columns=Name:.metadata.name,Status:.status.phase
    Sample output
    Name             Status
    metallb-system   Active
  3. Create the OperatorGroup:

    cat << EOF | oc apply -f -
    apiVersion: operators.coreos.com/v1
    kind: OperatorGroup
    metadata:
      name: metallb-operator
      namespace: metallb-system
    EOF
  4. Confirm the OperatorGroup is installed in the namespace:

    oc get operatorgroup -n metallb-system
    Sample Output
    NAME               AGE
    metallb-operator   5s
  5. Subscribe to the metallb Operator:

    cat << EOF| oc apply -f -
    apiVersion: operators.coreos.com/v1alpha1
    kind: Subscription
    metadata:
      name: metallb-operator-sub
      namespace: metallb-system
    spec:
      channel: stable
      name: metallb-operator
      source: redhat-operators
      sourceNamespace: openshift-marketplace
    EOF
  6. Confirm the metallb installplan is in the namespace:

    oc get installplan -n metallb-system
  7. Confirm the metallb operator is installed:

    oc get clusterserviceversion -n metallb-system -o custom-columns=Name:.metadata.name,Phase:.status.phase
  8. Repeat the query until the Phase is Succeeded.

    Sample Output
    Name                                    Phase
    metallb-operator.v4.13.0-202404030309   Succeeded

    Track the progress using below command:

    while ! (oc get clusterserviceversion -n metallb-system -o custom-columns=Name:.metadata.name,Phase:.status.phase | grep metallb-operator | grep Succeeded); do oc get clusterserviceversion -n metallb-system; sleep 5; done
  9. Create a single instance of a metallb resource:

    cat << EOF | oc apply -f -
    apiVersion: metallb.io/v1beta1
    kind: MetalLB
    metadata:
      name: metallb
      namespace: metallb-system
    EOF
  10. Verify that the deployment for the controller is running:

    oc get deployment -n metallb-system controller
  11. Repeat the command until AVAILABLE is 1

    Sample Output
    NAME         READY   UP-TO-DATE   AVAILABLE   AGE
    controller   1/1     1            1           21s
  12. Verify that the daemon set for the speaker is running:

    oc get daemonset -n metallb-system speaker
    Sample Output
    oc get daemonset -n metallb-system speaker
    NAME      DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR            AGE
    speaker   6         6         6       6            6           kubernetes.io/os=linux   55s

Reference: see Installing the MetalLB Operator in the RHOCP Networking guide