cluster-metallb
by startxfr
Configure the MetalLB operator and the load balancer address pools, layer 2 and BGP advertisements of a bare metal cluster
About this chart
Cluster Chart : MetalLB
Configure the MetalLB operator and the load balancer address pools, layer 2 and BGP advertisements of a bare metal cluster.
This chart is part of the cluster-xxx startx helm chart series that doesn't necessarily deploy pods but rather represent a cluster configuration state orchestrated by gitops tools like ArgoCD.
MetalLB gives an external IP address to the services of type LoadBalancer on the clusters that have no cloud load balancer
(bare metal, vSphere). This chart installs the Red Hat metallb-operator operator and manages:
- the MetalLB instance (
MetalLBCR): the controller deployment allocating the addresses and the speaker daemonset announcing them - the address pools (
IPAddressPool): the IP ranges MetalLB is allowed to assign - the layer 2 advertisements (
L2Advertisement): the addresses are announced with ARP and NDP on the network of the nodes - the BGP configuration (
BGPPeer,BGPAdvertisement,BFDProfile,Community): the addresses are announced to routers - the secrets referenced by these resources (password of a BGP session), from values or through an
ExternalSecret
Requirements and guidelines
Read the startx helm-repository homepage for more information on how to use these resources.
Prerequisites
- An OpenShift cluster installed on bare metal, VMware vSphere, IBM Z or IBM Power. MetalLB is not supported on the cloud provider platforms (AWS, Azure, Google Cloud), which provide their own load balancers
- Free IP addresses for the pools: in the subnet of the nodes for the layer 2 mode, or any range routed by your routers for the BGP mode. Never list an address already in use (gateway, nodes, API and ingress virtual IP, DHCP range)
- Access to the
redhat-operatorscatalog of the software catalog cluster-adminprivileges- MetalLB and IP failover are incompatible: remove the IP failover configuration of the cluster before installing the operator
The operator only supports the AllNamespaces install mode and is installed in the metallb-system namespace, created by the
project sub-chart with the openshift.io/cluster-monitoring label (required to collect the BGP and BFD metrics). MetalLB runs in the
namespace of its operator and only reads its configuration there: every resource of this chart is created in this namespace, and the
instance must be named metallb.
Layer 2 or BGP
| Mode | How the address is announced | Network requirement | Behavior to know |
|---|---|---|---|
| Layer 2 | One speaker answers the ARP (IPv4) and NDP (IPv6) requests | Pool in the subnet of the nodes, no equipment to set up | One node receives all the traffic of an address; after a node failure the clients must refresh their ARP cache |
| BGP | Every speaker announces a route to the address to the BGP routers | A BGP session between the nodes and the routers | The routers balance the traffic between the nodes; the loss of a session resets the connections |
A pool is not reachable until an advertisement announces it: always declare an L2Advertisement or a BGPAdvertisement
together with an IPAddressPool. An advertisement with an empty spec announces every pool.
Nodes with several networks
By default an address is announced from every network interface of the speaker nodes. When the nodes are attached to several networks or VLAN:
- restrict the announcement with
spec.interfaces(layer 2) andspec.nodeSelectorsof the advertisement - when the pool belongs to a network that is not the one of the default route of the nodes (VLAN or secondary interface), the nodes
must forward the traffic received on this interface: set
gatewayConfig.ipForwardingtoGlobalin the cluster network operator configuration (network.operator.openshift.io/cluster), or enable the forwarding for this interface only with aMachineConfig. This setting is not managed by this chart - the interfaces and VLAN themselves can be declared with the cluster-nmstate chart
Deploy this helm chart on openshift
1. Connect to your Openshift cluster
oc login -t <token> <cluster-url>
2. Install the repository
helm repo add startx https://helm-repository.readthedocs.io/en/latest/repos/stable/
3. Get information about this chart
helm show chart startx/cluster-metallb
4. Install this chart
Default values
The default values keep every feature disabled and render nothing: the address pools are specific to each cluster and must be provided in a values file.
- No MetalLB instance, no pool and no advertisement are created
- The operator subscription and namespace are managed separately via the
operatorandprojectsub-charts (both disabled by default)
# base configuration running default configuration
helm install cluster-metallb startx/cluster-metallb
Full deployment with operator and project
Helm cannot create a custom resource before its API exists: install the namespace and the operator first, approve its
InstallPlan (the subscription uses installPlanApproval: Manual), then enable the MetalLB instance, a pool and its advertisement.
# 1. namespace and operator
helm install cluster-metallb startx/cluster-metallb \
--set project.enabled=true \
--set operator.enabled=true
oc -n metallb-system get installplan
oc -n metallb-system patch installplan <name> --type merge -p '{"spec":{"approved":true}}'
# 2. MetalLB instance, layer 2 pool and advertisement, once the operator is running
cat > my-metallb.yaml <<EOF
metallb:
enabled: true
ipAddressPools:
enabled: true
list:
- name: default
spec:
addresses:
- 192.0.2.240-192.0.2.250
l2Advertisements:
enabled: true
list:
- name: default
spec:
ipAddressPools:
- default
EOF
helm upgrade cluster-metallb startx/cluster-metallb -f my-metallb.yaml \
--set project.enabled=true \
--set operator.enabled=true
Replace 192.0.2.240-192.0.2.250 (documentation range) with free addresses of the network of your nodes. A service of type
LoadBalancer then gets an address of the pool; it selects a pool with the metallb.io/address-pool annotation and a given
address with the metallb.io/loadBalancerIPs annotation.
BGP deployment
The addresses are announced to a router with BGP and BFD; the password of the session is read from an external store (see External secrets):
externalSecretDefaults:
secretStoreRef:
name: vault-backend
metallb:
enabled: true
ipAddressPools:
enabled: true
list:
- name: default
spec:
addresses:
- 198.51.100.0/27
bfdProfiles:
enabled: true
list:
- name: default
spec:
transmitInterval: 300
receiveInterval: 300
bgpPeers:
enabled: true
list:
- name: router-1
spec:
myASN: 64512
peerASN: 64500
peerAddress: 192.0.2.1
bfdProfile: default
passwordSecret:
name: bgp-router-1
bgpAdvertisements:
enabled: true
list:
- name: default
spec:
ipAddressPools:
- default
peers:
- router-1
secrets:
enabled: true
list:
- name: bgp-router-1
type: kubernetes.io/basic-auth
externalSecret:
enabled: true
remoteRefs:
password:
key: ocp/metallb/bgp-router-1
property: password
Other available values
- startx : MetalLB instance with the controller on the infra nodes and the operator on the infra nodes; a
startxpool and its layer 2 advertisement are declared with a documentation range and left disabled (see values-startx.yaml) - startx_noinfra : same deployment without infra nodes placement (see values-startx_noinfra.yaml)
helm install cluster-metallb startx/cluster-metallb -f https://raw.githubusercontent.com/startxfr/helm-repository/master/charts/cluster-metallb/values-startx.yaml
Values files
Example values files shipped with the chart, to use with helm install -f <file> :
- startx : context
startx/default/infra; againstvalues.yaml: differ on 22 keys, by top-level key:project(6),metallb(5),operator(5),context(4), ... (see values-startx.yaml) - startx_noinfra : context
startx/default/infra; againstvalues-startx.yaml: differ onmetallb.spec.controllerNodeSelector.node-role.kubernetes.io/infra,metallb.spec.controllerTolerations,operator.subscription.operator.config.infra(true → false) (see values-startx_noinfra.yaml) examples/argocd/: 5 example manifest(s) (see the ArgoCD or usage sections)
helm install cluster-metallb startx/cluster-metallb -f https://raw.githubusercontent.com/startxfr/helm-repository/master/charts/cluster-metallb/values-startx.yaml
Values dictionary
context values dictionary
| Key | Default | Description |
|---|---|---|
| context.scope | myscope | Name of the global scope for this application |
| context.cluster | default | Name of the cluster running this application |
| context.environment | myenv | Name of the environment (dev, factory, preprod, prod) |
| context.component | mycomponent | Component name of this application |
| context.app | default-metallb | Application name |
| context.version | 4.22.0 | Version name of this application |
externalSecretDefaults values dictionary
| Key | Default | Description |
|---|---|---|
| externalSecretDefaults.apiVersion | external-secrets.io/v1 | API version of the ExternalSecret CRD |
| externalSecretDefaults.refreshInterval | 1h | How often the Secret is refreshed from the external store |
| externalSecretDefaults.secretStoreRef.name | "" | Name of the (Cluster)SecretStore, required as soon as a secret uses externalSecret |
| externalSecretDefaults.secretStoreRef.kind | ClusterSecretStore | Kind of the store (ClusterSecretStore or SecretStore) |
metallb values dictionary
| Key | Default | Description |
|---|---|---|
| metallb.enabled | false | Enable the creation of the MetalLB CR (sync-wave 15) |
| metallb.hooked | false | Activate the resource as a helm hook |
| metallb.name | metallb | Name of the instance (the operator only reconciles metallb) |
| metallb.spec | {} | Specification of the instance, rendered as is |
| metallb.spec.logLevel | info | Verbosity of the controller and of the speakers (all, debug, info, warn, error, none) |
| metallb.spec.nodeSelector | every node | Node selector of the speaker daemonset (only these nodes announce the addresses) |
| metallb.spec.speakerTolerations | Tolerations of the speaker daemonset | |
| metallb.spec.controllerNodeSelector | Node selector of the controller deployment | |
| metallb.spec.controllerTolerations | Tolerations of the controller deployment | |
| metallb.spec.loadBalancerClass |
Deploy cluster-metallb with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has cluster-metallb on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartcluster-metallb is pinned at v21.3.418 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply