Configure node selector for MetalLB speaker¶
By default, MetalLB speakers are deployed on all Kubernetes nodes. You can configure MetalLB to run its speakers on a particular set of nodes. This decreases the number of nodes that should be connected to external network. In this scenario, only a few nodes are exposed for ingress traffic from the outside world.
To customize the MetalLB speaker node selector:
Using
kubeconfig
of the management cluster, open theCluster
object of the managed cluster for editing:kubectl --kubeconfig <pathToManagementClusterKubeconfig> -n <TargetClusterProjectName> edit cluster <TargetClusterName>
In the
spec:providerSpec:value:helmReleases
section, add thespeaker.nodeSelector
field formetallb
:spec: ... providerSpec: value: ... helmReleases: - name: metallb values: ... speaker: nodeSelector: metallbSpeakerEnabled: "true"
The
metallbSpeakerEnabled: "true"
parameter in this example is the label on Kubernetes nodes where MetalLB speakers will be deployed. It can be an already existing node label or a new one.You can add user-defined labels to nodes using the
nodeLabels
field.List of node labels to be attached to a node for the user to run certain components on separate cluster nodes. The list of allowed node labels is located in the
Cluster
object statusproviderStatus.releaseRef.current.allowedNodeLabels
field.If the
value
field is not defined inallowedNodeLabels
, a label can have any value.Before or after a machine deployment, add the required label from the allowed node labels list with the corresponding value to
spec.providerSpec.value.nodeLabels
inmachine.yaml
. For example:nodeLabels: - key: stacklight value: enabled
The addition of a node label that is not available in the list of allowed node labels is restricted.