metallb-cr

by somaz94

Helm chartv0.1.2App 0.16.1Apache-2.0Verified publisher

Custom resources for MetalLB — IPAddressPool, L2Advertisement, BGPAdvertisement, BGPPeer, Community, BFDProfile. Deployed alongside the upstream MetalLB chart, which intentionally does not template these config CRs.

About this chart

metallb-cr

Data-driven MetalLB configuration custom resources, deployed as a Helm release alongside the upstream MetalLB chart.

The upstream metallb/metallb chart installs the controller, speaker and CRDs but does not template config CRs (IPAddressPool, L2Advertisement, BGPPeer, ...) — those are left for you to apply out-of-band (typically kubectl apply -f in a post-install hook). This chart closes that gap so the MetalLB configuration is managed declaratively in Git, versioned, and rolled out with the same helm / helmfile flow as the operator.

What it deploys

ResourceAPICreated from
IPAddressPoolmetallb.io/v1beta1ipAddressPools[]
L2Advertisementmetallb.io/v1beta1l2Advertisements[]
BGPAdvertisementmetallb.io/v1beta1bgpAdvertisements[]
BGPPeermetallb.io/v1beta2bgpPeers[]
Communitymetallb.io/v1beta1communities[]
BFDProfilemetallb.io/v1beta1bfdProfiles[]

Every list defaults to empty, so an unconfigured helm install creates nothing.

Prerequisites

  • Kubernetes >= 1.25
  • MetalLB controller + speaker + CRDs already installed in the target namespace — typically via the upstream metallb/metallb chart. This chart only creates config CRs; it does not install MetalLB itself or its CRDs.

Install

OCI registry:

helm install metallb-config oci://ghcr.io/somaz94/charts/metallb-cr \
  --namespace metallb \
  -f my-values.yaml

Classic Helm repo:

helm repo add somaz94 https://charts.somaz.blog
helm install metallb-config somaz94/metallb-cr \
  --namespace metallb \
  -f my-values.yaml

Quick examples

L2 mode (the common bare-metal case)

ipAddressPools:
  - name: ip-pool
    addresses:
      - 192.0.2.10-192.0.2.50
    autoAssign: true

l2Advertisements:
  - name: l2-network
    ipAddressPools:
      - ip-pool

L2 advertised only from worker nodes

ipAddressPools:
  - name: ip-pool
    addresses:
      - 192.0.2.10-192.0.2.50

l2Advertisements:
  - name: l2-workers
    ipAddressPools:
      - ip-pool
    nodeSelectors:
      - matchLabels:
          node-role.kubernetes.io/worker: ""

BGP mode with BFD

ipAddressPools:
  - name: ip-pool
    addresses:
      - 192.0.2.0/24

bfdProfiles:
  - name: fast
    receiveInterval: 100
    transmitInterval: 100
    detectMultiplier: 3

bgpPeers:
  - name: tor-1
    myASN: 64512
    peerASN: 64512
    peerAddress: 203.0.113.254
    bfdProfile: fast

bgpAdvertisements:
  - name: bgp-default
    ipAddressPools:
      - ip-pool
    aggregationLength: 32

BGP requires a BGP backend (frrk8s.enabled / frr.enabled) in the upstream MetalLB chart.

Namespace-restricted pool

ipAddressPools:
  - name: prod-only
    addresses:
      - 203.0.113.0/28
    autoAssign: false
    serviceAllocation:
      priority: 50
      namespaces:
        - prod

Values reference

Metadata

KeyDefaultDescription
commonLabels{}Labels added to every resource.
commonAnnotations{}Annotations added to every resource.

IPAddressPools — ipAddressPools[]

FieldRequiredDescription
nameyesResource name.
addressesyesList of CIDRs or start-end ranges.
autoAssignnoAuto-assign from this pool (upstream default true).
avoidBuggyIPsnoSkip .0 / .255 (upstream default false).
serviceAllocationnoRestrict the pool to namespaces / services (priority, namespaces, namespaceSelectors, serviceSelectors).
labels / annotationsnoExtra metadata on this resource.
specExtranoArbitrary YAML merged into spec for unsurfaced fields.

L2Advertisements — l2Advertisements[]

FieldRequiredDescription
nameyesResource name.
ipAddressPoolsnoPool names to advertise.
ipAddressPoolSelectorsnoLabel selectors to pick pools.
nodeSelectorsnoLimit announcing nodes.
interfacesnoLimit announcing interfaces.
labels / annotations / specExtrano—

BGPAdvertisements — bgpAdvertisements[]

FieldRequiredDescription
nameyesResource name.
aggregationLengthnoIPv4 aggregation length (default 32).
aggregationLengthV6noIPv6 aggregation length (default 128).
localPrefnoBGP LOCAL_PREF.
communitiesnoBGP communities to attach.
ipAddressPoolsnoPool names to advertise.
ipAddressPoolSelectorsnoLabel selectors to pick pools.
nodeSelectorsnoLimit announcing nodes.
peersnoLimit to specific BGPPeer names.
labels / annotations / specExtrano—

BGPPeers — bgpPeers[]

FieldRequiredDescription
nameyesResource name.
myASNyesLocal AS number.
peerASNnoRemote AS number (mutually exclusive with dynamicASN).
dynamicASNnointernal / external instead of a fixed peerASN.
peerAddressnoNeighbor IP (mutually exclusive with interface).
interfacenoInterface for unnumbered BGP.
peerPortnoNeighbor port (default 179).
holdTime / keepaliveTime / connectTimenoSession timers.
routerID / sourceAddress / vrfno—
ebgpMultiHop / disableMP / enableGracefulRestartnoBoolean session options.
bfdProfilenoBFDProfile name to associate.
passwordnoPlaintext BGP MD5 password (prefer passwordSecret).
passwordSecretnoSecretReference ({ name, namespace }) for the password.
nodeSelectorsnoLimit which nodes peer.
labels / annotations / specExtrano—

Communities — communities[]

FieldRequiredDescription
nameyesResource name.
communitiesyesList of { name, value } alias entries.
labels / annotationsno—

BFDProfiles — bfdProfiles[]

FieldRequiredDescription
nameyesResource name.
receiveInterval / transmitInterval / detectMultiplier / echoIntervalnoTiming parameters.
echoMode / passiveModenoBoolean modes.
minimumTtlnoMinimum TTL for received packets.
labels / annotationsno—

License

Apache-2.0

Deploy metallb-cr with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has metallb-cr 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.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartmetallb-cr is pinned at v0.1.2 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. 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