How to create a Load Balancer via OSC

The following HowTo describes how to configure a simple HTTP Load Balancer (LB) in OpenStack OSC using a Floating IP. Please note the Disclaimer. Many more LB configuration examples see lb-basic-cookbook.

It may be advantageous to use a floating IP address when setting up the VIP of a load balancer to ensure that you retain control over the IP assigned as the floating IP if the load balancer needs to be destroyed, moved, or recreated.

Note

Note that with iPv6 load balancing is not possible with the following method because floating IPs do not work with iPv6.

Scenario description:

  • The backend servers 192.0.2.10 and 192.0.2.11 in the private-subnet subnet were configured with an HTTP application on TCP port 80.
  • These backend servers were configured with a health check under the URL path “/healthcheck”. See lb-health-monitor.
  • The Neutron Network public is a shared external network created by the cloud operator and accessible over the Internet.
  • We want to configure a basic load balancer that is accessible from the Internet, distributes web requests to the backend servers and checks the path “/healthcheck” to ensure the health of the backend members. Furthermore we want to do this with a floating IP address.

Solution:

  • Create the Load Balancer lb1 in the private-subnet.
  • Create a listener listener1.
  • Create the pool pool1 as the default pool of the listener1.
  • Create a health monitor on pool1 that tests the path “/healthcheck”.
  • Add the members 192.0.2.10 and 192.0.2.11 in the private-subnet to pool1.
  • Create a free floating IP address in the public-subnet.
  • Link this Floating IP with the VIP port of the lb1.

CLI commands:

openstack loadbalancer create --name lb1 --vip-subnet-id private-subnet
# Re-run the following until lb1 shows ACTIVE and ONLINE statuses:
openstack loadbalancer show lb1
openstack loadbalancer listener create --name listener1 --protocol HTTP --protocol-port 80 lb1
openstack loadbalancer pool create --name pool1 --lb-algorithm ROUND_ROBIN --listener listener1 --protocol HTTP
openstack loadbalancer healthmonitor create --delay 5 --max-retries 4 --timeout 10 --type HTTP --url-path /healthcheck pool1
openstack loadbalancer member create --subnet-id private-subnet --address 192.0.2.10 --protocol-port 80 pool1
openstack loadbalancer member create --subnet-id private-subnet --address 192.0.2.11 --protocol-port 80 pool1
openstack floating ip create public
# The following IDs should be visible in the output of previous commands
openstack floating ip set --port <load_balancer_vip_port_id> <floating_ip_id>