MetalLB

  • By Canonical Kubernetes
Channel Revision Published Runs on
latest/stable 16 17 Apr 2024
Ubuntu 22.04
latest/candidate 16 15 Apr 2024
Ubuntu 22.04
latest/beta 15 17 Apr 2024
Ubuntu 22.04
latest/edge 15 06 Mar 2024
Ubuntu 22.04
1.30/beta 15 19 Apr 2024
Ubuntu 22.04
1.30/edge 15 13 Mar 2024
Ubuntu 22.04
1.29/stable 16 17 Apr 2024
Ubuntu 22.04
1.29/candidate 16 15 Apr 2024
Ubuntu 22.04
1.29/beta 15 17 Apr 2024
Ubuntu 22.04
1.29/edge 15 06 Mar 2024
Ubuntu 22.04
1.28/stable 12 26 Sep 2023
Ubuntu 22.04
1.28/candidate 12 22 Sep 2023
Ubuntu 22.04
1.28/beta 4 07 Aug 2023
Ubuntu 22.04
1.28/edge 9 10 Aug 2023
Ubuntu 22.04
juju deploy metallb
Show information

Platform:

Ubuntu
22.04

Charmed MetalLB tutorial

The Charmed MetalLB Operator delivers automated operations management from day 0 to day 2 on the MetalLB Load Balancer Implementation for Bare Metal Kubernetes. It is an open source, production-ready charm on top of Juju

As a first step this tutorial shows you how to get Charmed MetalLB up and running, but the tutorial does not stop there. In this tutorial we will walk through how to:

  • Set up an environment using Kubernetes and Juju.
  • Deploy MetalLB using a single command.
  • Configure the IPAddressPool.

What you’ll need

While this tutorial intends to guide and teach you as you deploy Charmed MetalLB, it will be most beneficial if you already have a familiarity with:

  • Basic terminal commands.
  • MetalLB concepts.

Before we start, make sure you can meet the following requirements:

Represent the cloud in juju

Juju recognizes your MicroK8s cloud automatically. You can already see it if you run:

juju clouds
Cloud      Regions  Default    Type  Credentials  Source    Description
microk8s   1        localhost  k8s   1            built-in  A Kubernetes Cluster

If it is not there, you may add the cloud with:

KUBECONFIG=path/to/kubeconfig/file  juju add-k8s --client <k8s-cloud>

Deploy Charmed MetalLB

The best way to deploy MetalLB in Layer 2 mode on Charmed Kubernetes is with the MetalLB charm, which activates both the metallb controller Deployment and metallb speaker DaemonSet.

Run the following command, which will fetch the charm from Charmhub and deploy it to your model:

juju deploy metallb --channel 1.28/stable --trust

Juju will now fetch Charmed MetalLB and begin deploying it to the Kubernetes cluster. This process can take several minutes depending on how provisioned (RAM, CPU, etc) your machine is. You can track the progress by running:

juju status --watch 1s

This command is useful for checking the status of Charmed MetalLB and gathering information about the containers hosting Charmed MetalLB. Some of the helpful information it displays include IP addresses, ports, state, etc. The command updates the status of Charmed MetalLB every second and as the application starts you can watch the status and messages of Charmed MetalLB change. Wait until the application is ready - when it is ready, juju status will show:

Model         Controller       Cloud/Region                     Version  SLA          Timestamp
juju-metallb  overlord         k8s-cloud/default                3.1.5    unsupported  13:32:58-05:00

App      Version  Status  Scale  Charm    Channel      Rev  Address        Exposed  Message
metallb           active      1  metallb  1.28/stable  9    10.152.183.85  no       

Unit        Workload  Agent  Address       Ports  Message
metallb/0*  active    idle   192.168.0.15         

To exit the screen with juju status --watch 1s, enter Ctrl+c. If you want to further inspect juju logs, can watch for logs with juju debug-log. More info on logging at juju logs.

Configure MetalLB

You will need to change the IP addresses allocated to MetalLB to suit your environment. The IP addresses can be specified as a range, such as “192.168.1.88-192.168.1.89”, or as a comma-separated list of pools in CIDR notation, such as “192.168.1.240/28, 10.0.0.0/28”.

Configuring the IP addresses can be done either at time of deployment via single-line config or later by changing the charm config via Juju.

This will adjust the default IPAddressPool.spec.addresses created by the charm according to the specification

An example single-line config adjustment might look like:

juju deploy metallb --config iprange='192.168.1.88-192.168.1.89' --trust

Alternatively, you can change the config directly on the metallb charm at any time:

juju config metallb iprange="192.168.1.240/28, 10.0.0.0/28"