LBaaS is short for 'Load balancer as a Service' an in City Cloud we do offer the LBaaS version 2 that was first introduced in the OpenStack version named 'Kilo'. LBaaS version 1 was deprecated in OpenStack version 'Liberty' and in hence not available in City Cloud (current version is based on the 'Train' release).
The implementations use agents. The agents handle the HAProxy configuration and manage the HAProxy daemon. LBaaS v2 allows for configuring multiple listener ports on a single load balancer IP address.
Another LBaaS v2 implementation, further described at our Octavia page, has a separate API and separate worker processes that build load balancers within virtual machines on hypervisors that are managed by the Compute service. You do not need an agent for Octavia.
LBaaS v2 has some concepts to understand:
- Load balancer
The load balancer occupies a neutron network port and has an IP address assigned from a subnet.
Load balancers can listen for requests on multiple ports. Each one of those ports is specified by a listener.
A pool holds a list of members that serve content through the load balancer.
Members are servers that serve traffic behind a load balancer. Each member is specified by the IP address and port that it uses to serve traffic.
- Health monitor
Members may go offline from time to time and health monitors divert traffic away from members that are not responding properly. Health monitors are associated with pools.
LBaaS v2 has multiple implementations via different service plug-ins. The two most common implementations use either an agent or the Octavia services. Both implementations use the LBaaS v2 API
Building an LBaaS v2 load balancer
Start by creating a load balancer on a network. In this example, the private network is an isolated network with two web server instances:
You can view the load balancer status and IP address with the lbaas-loadbalancer-show command:
Update the security group to allow traffic to reach the new load balancer. Create a new security group along with ingress rules to allow traffic into the new load balancer. The neutron port for the load balancer is shown as vip_port_id above.
Create a security group and rules to allow TCP port 80, TCP port 443, and all ICMP traffic:
Apply the security group to the load balancer’s network port usingvip_port_idfrom thelbaas-loadbalancer-showcommand:
This load balancer is active and ready to serve traffic on 192.168.1.22.
Verify that the load balancer is responding to pings before moving further:
Adding an HTTP listener
With the load balancer online, you can add a listener for plaintext HTTP traffic on port 80:
You can begin building a pool and adding members to the pool to serve HTTP content on port 80. For this example, the web servers are192.168.1.16and192.168.1.17:
You can usecurlto verify connectivity through the load balancers to your web servers:
In this example, the load balancer uses the round robin algorithm and the traffic alternates between the web servers on the backend.
You can add a health monitor so that unresponsive servers are removed from the pool:
In this example, the health monitor removes the server from the pool if it fails a health check at two five-second intervals. When the server recovers and begins responding to health checks again, it is added to the pool once again.
Adding an HTTPS listener
You can add another listener on port 443 for HTTPS traffic. LBaaS v2 offers SSL/TLS termination at the load balancer, but this example takes a simpler approach and allows encrypted connections to terminate at each member server.
Start by creating a listener, attaching a pool, and then adding members:
You can also add a health monitor for the HTTPS pool:
The load balancer now handles traffic on ports 80 and 443.
Associating a floating IP address
Load balancers that are deployed on a public or provider network that are accessible to external clients do not need a floating IP address assigned. External clients can directly access the virtual IP address (VIP) of those load balancers.
However, load balancers deployed onto private or isolated networks need a floating IP address assigned if they must be accessible to external clients. To complete this step, you must have a router between the private and public networks and an available floating IP address.
You can use thelbaas-loadbalancer-showcommand from the beginning of this section to locate thevip_port_id. Thevip_port_idis the ID of the network port that is assigned to the load balancer. You can associate a free floating IP address to the load balancer usingfloatingip-associate:
Setting quotas for LBaaS v2
Quotas are available for limiting the number of load balancers and load balancer pools. By default, both quotas are set to 10.
You can adjust quotas using thequota-updatecommand:
A setting of -1 disables the quota for a tenant.
Retrieving load balancer statistics
The LBaaS v2 agent collects four types of statistics for each load balancer every six seconds. Users can query these statistics with the lbaas-loadbalancer-stats command:
The active_connections count is the total number of connections that were active at the time the agent polled the load balancer. The other three statistics are cumulative since the load balancer was last started. For example, if the load balancer restarts due to a system error or a configuration change, these statistics will be reset.