Application Load Balancing for BareOS

This document describes the concept of creating services of type LoadBalancer on your BareOS Kubernetes clusters. Understanding of Kubernetes concepts of Service type LoadBalancer and External LoadBalancers is recommended.

Kubernetes offers a concept of running services of type LoadBalancer with the ability to map them to an external load balancer specific to the environment on which you are running the cluster on. However, the network loadbalancers that Kubernetes ships with out of box today are limited to those that integrate with public clouds only such as AWS, GCP, Azure. There isn’t any default implementation available today for a network loadbalancer for bare metal clusters.

MetalLB addresses this issue by offering an open source network load balancer implementation for bare metal Kubernetes clusters. MetalLB integrates with your standard networking equipment that is usually available in a typical data center. This enables you to create externally facing services on your bare metal Kubernetes cluster.

For more information on MetalLB, refer to the MetalLB documentation.

PMK ships with and supports configuration of MetalLB for your BareOS clusters.

Creating a PMK Cluster with MetalLB Enabled

MetalLB Configuration

MetalLB uses standard address discovery and routing protocols to advertise the external IP of a service on rest of your network. MetalLB can be configured to operate in Layer-2 Mode or BGP Mode.

PMK configures MetalLB to operate in Layer-2 Mode]( because of it’s universal applicability - ie it can work on any ethernet network, with no special hardware required.

Creating a PMK Cluster with MetalLB Enabled

During cluster creation, PMK provides the option to enable MetalLB for the cluster.

If selected, 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.

Creating Services of type LoadBalancer

To expose a service externally on a BareOS cluster that is configured to use MetalLB, simply create the service with spec.type set to LoadBalancer. MetalLB will do the rest.

For more information about the features MetalLB exposes that services can utilize, refer to Using MetalLB

Troubleshooting Issues with MetalLB

MetalLB attaches informational events to the services that it’s controlling. If your LoadBalancer is misbehaving, run kubectl describe service <service name> and check the Kubernetes event log.

Requesting Specific IPs for a Service

MetalLB respects the spec.loadBalancerIP parameter, so if you want your service to be set up with a specific address, you can request it by setting that parameter. If MetalLB does not own the requested address, or if the address is already in use by another service, assignment will fail and MetalLB will log a warning event visible in kubectl describe service <service name>.