# Metallb Addon2

## Introduction

MetalLB is an open-source Load balancer implementation based on standard routing protocols for bare-metal Kubernetes. It specifically handles the `ServiceType: Loadbalancer` settings, which provides users with a more granular ability to control how IP addresses are assigned.

## Description

In our latest UI, users can modify the configuration for the IP Range at any stage of the cluster lifecycle. It provides:

* **Address Allocation – MetalLB** assigns and unassigning individual addresses to services as required, but only from IPs that are part of its defined pool.
* **External Announcement – After** MetalLB has assigned an external IP address to a service, it ensures the external network outside the cluster is aware that the IP resides within the cluster. MetalLB uses the typical routing protocols like ARP, NDP, or BGP to achieve this..

## Settings

MetalLB is enabled by default on BareOS clusters. To access and modify the settings, go to the Infrastructure page, check the radio button next to the cluster you wish to modify, then click edit.

<figure><img src="/files/YAwo12b7SzMfY29oQDdB" alt=""><figcaption></figcaption></figure>

This will open a new page where the addon can be enabled.

<figure><img src="/files/Iv7PCpyPfYkzxUeoJKDP" alt=""><figcaption></figcaption></figure>

Once enabled, you need to also specify the IP address pool(s) that MetalLB can use to allocate IP addresses to services that are created with type `LoadBalancer`. PMK will then deploy MetalLB as a Kubernetes application within the cluster, under the `metallb-system` namespace. A `configmap` is created under this namespace that configures MetalLB with the appropriate protocol, and the address pool(s) you have specified as part of cluster creation.

Scroll down the page past the Cluster Add-ons area to the MetalLB Configuration section.

<figure><img src="/files/yccD78q00KVzKPebXPBZ" alt=""><figcaption></figcaption></figure>

You can now add multiple IP ranges by clicking the **+ Add Address Pool Range** link.

{% hint style="danger" %}
**Note**

MetalLB is currently inoperative when used in BGP mode for IPv6. This is a limitation with MetalLB itself but is under active development. Additionally, In order for MetalLB to function correctly, privileged mode must be enabled for running containers on the cluster.
{% endhint %}

## YAML Specifications

{% tabs %}
{% tab title="YAML" %}

```yaml
apiVersion: sunpike.platform9.com/v1alpha2
kind: ClusterAddon
metadata:
  labels:
    sunpike.pf9.io/cluster: '<clsuuid>'
    type: metallb
  name: <clsuuid>-metallb
  namespace: default
spec:
  clusterID: '<clsuuid>'
  override:
    params:
    - name: MetallbIpRange
      value: '<ip range>'
    # Optional: if specified MetallbIpRange is not used
    - name: base64EncMetallbConfig
      value: 'base64 encoded entire metallb config'      
  type: metallb
  version: 0.9.7
  watch: true
```

{% endtab %}
{% endtabs %}

The *base64EncMetallbConfig* field can be added to any configuration that MetalLB supports. For example, if two address pools are required, then the following configuration can be applied.

{% tabs %}
{% tab title="YAML" %}

```yaml
address-pools:
- name: default
  protocol: layer2
  addresses:
   - 192.168.5.0-192.168.6.0
- name: pool
  protocol: layer2
  addresses:
   - 192.168.7.0-192.168.8.0
```

{% endtab %}
{% endtabs %}

Data can also be encoded as base64 and used as an override parameter, if needed.

{% tabs %}
{% tab title="YAML" %}

```yaml
override:
    params:
    - name: base64EncMetallbConfig  
      value: "YWRkcmVzcy1wb29sczoKLSBuYW1lOiBkZWZhdWx0CiAgcHJvdG9jb2w6IGxheWVyMgogIGFkZHJlc3NlczoKICAgLSAxOTIuMTY4LjUuMC0xOTIuMTY4LjYuMAotIG5hbWU6IHBvb2wKICBwcm90b2NvbDogbGF5ZXIyCiAgYWRkcmVzc2VzOgogICAtIDE5Mi4xNjguNy4wLTE5Mi4xNjguOC4wCg=="
```

{% endtab %}
{% endtabs %}

## Conclusion

Addons are updated along with the `pf9-kube` version and can be referenced in the [Support Matrix](https://docs.platform9.com/kubernetes/support-matrix) article. For additional assistance, contact our [support team](https://platform9.zendesk.com/hc/en-us/requests/new?ticket_form_id=360000924873). For additional assistance with this addon, contact our [support team](https://platform9.zendesk.com/hc/en-us/requests/new?ticket_form_id=360000924873).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.platform9.com/managed-kubernetes/5.9/platform9-managed-add-ons-overview/metallb-addon2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
