Bare-metal OpenShift with MetalLB LoadBalancer

Jeganathan Swaminathan ( jegan@tektutor.org )

Jeganathan Swaminathan ( jegan@tektutor.org )
tektutor
6 min readMar 24, 2022

--

Bare-metal OpenShift with Metal LB

In a bare-metal OpenShift setup, the LoadBalancer Service will not work by default, unlike the AWS ROSA or Azure RedHat OpenShift.

This article assumes you already have a working RedHat OpenShift v4.x cluster. I used RedHat OpenShift v4.10.5.

My local RedHat OpenShift cluster looks as shown below

Let’s create a new project in OpenShift

Let’s create a simple deployment

The expected output is

Let’s list and check the nginx deployment status

Let’s scale the nginx deployment

The expected output is

Let’s check the pods

The expected output is

Let’s create a LoadBalancer service for the nginx deployment as shown below

Let’s check the LoadBalancer service details

The expected output is

In the output shown above, the External IP for the nginx LoadBalancer service is in Pending state. This will remain in Pending state forever, as there is no LoaderBalancer installed in OpenShift bare-metal setup by default. Hence, we need to install a LoadBalancer.

We need to create a namespace called metallb-system.

Let’s install MetalLB LoadBalancer as shown below. Let’s do this using RedHat OpenShift web console as an Administrator (kube-admin).

Once you select MetalLB Operator, your screen will look similar to the below screenshot.

Make sure you selected metallb-system namespace before installing MetalLB and Click on the Install button, then you will get a screen like shown below.

Click on Install button.

The MetalLB installation will take a few minutes to complete. Once the installation is complete, you will see a screen similar to the screenshot shown below.

We need to create a MetalLB LoadBalancer instance and start it on our cluster.

Create a file named metallb.yml

Let’s create the MetalLB instance

The expected output is

Let’s verify if the controller is running

The expected output is

Let’s verify if the daemonset speaker pods are running in all nodes

The expected output is

Now check the IP addresses of your OpenShift cluster nodes

The expected output is

Based on the above output, we can observe all the above VMs are in the subnet 192.168.122.0/24. Hence pick an IP range in the same subnet which isn’t taken already. I chose 192.168.122.90 to 192.168.122.100.

Let’s create an AddressPool that MetalLB can use

metallb-address-pool.yml

Let’s create the AddressPool from the above manifest file.

The expected output is

Now let’s check the nginx LoadBalancer service that we create earlier

The expected output is shown below. The nginx LoadBalancer service is now Load balanced by MetalLB Load Balancer at IP address 192.168.122.90.

Now, let us test if the LoadBalancer service is accessible at the external IP 192.168.122.90 as shown below

The expected output is

You can follow the author to get notified when he publishes new articles.

If you found this post helpful, please click the clap 👏 button below a few times to show your support for the author 👇

--

--

Jeganathan Swaminathan ( jegan@tektutor.org )
tektutor

Freelance Software Consultant & Corporate Trainer.I deliver training & provide consulting — DevOps,K8s, OpenShift,TDD/BDD,CI/CD,Microservices etc.