$ oc get packagemanifests -n openshift-marketplace metallb-operator
As a cluster administrator, you can add the MetallB Operator so that the Operator can manage the lifecycle for an instance of MetalLB on your cluster.
The installation procedures use the metallb-system
namespace.
You can install the Operator and configure custom resources in a different namespace.
The Operator starts MetalLB in the same namespace that the Operator is installed in.
MetalLB and IP failover are incompatible. If you configured IP failover for your cluster, perform the steps to remove IP failover before you install the Operator.
As a cluster administrator, you can install the MetalLB Operator by using the OKD web console.
Log in to the OKD web console.
Optional: Create the required namespace for the MetalLB Operator:
You can choose to create the namespace at this stage or you can create it when you start the MetalLB Operator install. From the Installed Namespace list you can create the project. |
Navigate to Administration → Namespaces and click Create Namespace.
Enter metallb-system
in the Name field, and click Create.
Install the MetalLB Operator:
In the OKD web console, click Operators → OperatorHub.
Type metallb
into the Filter by keyword field to find the MetalLB Operator, and then click Install.
You can also filter options by Infrastructure Features. For example, select Disconnected if you want to see Operators that work in disconnected environments, also known as restricted network environments.
On the Install Operator page, select a specific namespace on the cluster. Select the namespace created in the earlier section or choose to create the metallb-system
project, and then click Install.
To verify that the MetalLB Operator installed successfully:
Navigate to the Operators → Installed Operators page.
Ensure that MetalLB Operator is listed in the metallb-system project with a Status of Succeeded.
During installation, an Operator might display a Failed status. If the installation later succeeds with an Succeeded message, you can ignore the Failed message. |
If the Operator installation does not succeed, you can troubleshoot further:
Navigate to the Operators → Installed Operators page and inspect the Operator Subscriptions and Install Plans tabs for any failure or errors under Status.
Navigate to the Workloads → Pods page and check the logs for pods in the metallb-system
project.
Instead of using the OKD web console, you can install an Operator from OperatorHub using the CLI. Use the oc
command to create or update a Subscription
object.
Install the OpenShift CLI (oc
).
Log in as a user with cluster-admin
privileges.
Confirm that the MetalLB Operator is available:
$ oc get packagemanifests -n openshift-marketplace metallb-operator
NAME CATALOG AGE
metallb-operator Red Hat Operators 9h
Create the metallb-system
namespace:
$ cat << EOF | oc apply -f -
apiVersion: v1
kind: Namespace
metadata:
name: metallb-system
EOF
Optional: To ensure BGP and BFD metrics appear in Prometheus, you can label the namespace as in the following command:
$ oc label ns metallb-system "openshift.io/cluster-monitoring=true"
Create an Operator group custom resource in the namespace:
$ cat << EOF | oc apply -f -
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: metallb-operator
namespace: metallb-system
spec:
targetNamespaces:
- metallb-system
EOF
Confirm the Operator group is installed in the namespace:
$ oc get operatorgroup -n metallb-system
NAME AGE
metallb-operator 14m
Subscribe to the MetalLB Operator.
Run the following command to get the OKD major and minor version. You use the values to set the channel
value in the next
step.
$ OC_VERSION=$(oc version -o yaml | grep openshiftVersion | \
grep -o '[0-9]*[.][0-9]*' | head -1)
To create a subscription custom resource for the Operator, enter the following command:
$ cat << EOF| oc apply -f -
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: metallb-operator-sub
namespace: metallb-system
spec:
channel: "${OC_VERSION}"
name: metallb-operator
source: redhat-operators
sourceNamespace: openshift-marketplace
EOF
Confirm the install plan is in the namespace:
$ oc get installplan -n metallb-system
NAME CSV APPROVAL APPROVED
install-wzg94 metallb-operator.4.10.0-nnnnnnnnnnnn Automatic true
To verify that the Operator is installed, enter the following command:
$ oc get clusterserviceversion -n metallb-system \
-o custom-columns=Name:.metadata.name,Phase:.status.phase
Name Phase
metallb-operator.4.10.0-nnnnnnnnnnnn Succeeded
After you install the Operator, you need to configure a single instance of a MetalLB custom resource. After you configure the custom resource, the Operator starts MetalLB on your cluster.
Install the OpenShift CLI (oc
).
Log in as a user with cluster-admin
privileges.
Install the MetalLB Operator.
Create a single instance of a MetalLB custom resource:
$ cat << EOF | oc apply -f -
apiVersion: metallb.io/v1beta1
kind: MetalLB
metadata:
name: metallb
namespace: metallb-system
EOF
Confirm that the deployment for the MetalLB controller and the daemon set for the MetalLB speaker are running.
Check that the deployment for the controller is running:
$ oc get deployment -n metallb-system controller
NAME READY UP-TO-DATE AVAILABLE AGE
controller 1/1 1 1 11m
Check that the daemon set for the speaker is running:
$ 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 18m
The example output indicates 6 speaker pods. The number of speaker pods in your cluster might differ from the example output. Make sure the output indicates one pod for each node in your cluster.
By default, when you start MetalLB with the MetalLB Operator, the Operator starts an instance of a speaker
pod on each node in the cluster.
Only the nodes with a speaker
pod can advertise a load balancer IP address.
You can configure the MetalLB
custom resource with a node selector to specify which nodes run the speaker
pods.
The most common reason to limit the speaker
pods to specific nodes is to ensure that only nodes with network interfaces on specific networks advertise load balancer IP addresses.
Only the nodes with a running speaker
pod are advertised as destinations of the load balancer IP address.
If you limit the speaker
pods to specific nodes and specify local
for the external traffic policy of a service, then you must ensure that the application pods for the service are deployed to the same nodes.
apiVersion: metallb.io/v1beta1
kind: MetalLB
metadata:
name: metallb
namespace: metallb-system
spec:
nodeSelector: (1)
node-role.kubernetes.io/worker: ""
speakerTolerations: (2)
- key: "Example"
operator: "Exists"
effect: "NoExecute"
1 | The example configuration specifies to assign the speaker pods to worker nodes, but you can specify labels that you assigned to nodes or any valid node selector. |
2 | In this example configuration, the pod that this toleration is attached to tolerates any taint that matches the key value and effect value using the operator . |
After you apply a manifest with the spec.nodeSelector
field, you can check the number of pods that the Operator deployed with the oc get daemonset -n metallb-system speaker
command.
Similarly, you can display the nodes that match your labels with a command like oc get nodes -l node-role.kubernetes.io/worker=
.
You can optionally allow the node to control which speaker pods should, or should not, be scheduled on them by using affinity rules. You can also limit these pods by applying a list of tolerations. For more information about affinity rules, taints, and tolerations, see the additional resources.
For more information about node selectors, see Placing pods on specific nodes using node selectors.
For more information about taints and tolerations, see Understanding taints and tolerations.