LoadBalancer: deploy
We exemplify here the procedures based on (1) Horizon Dashboard and (2) the Command Line Interface and the OpenStack Octavia plugin, for a simple use case: the deployment of a basic HTTP load balancer with an associated Floating IP.
For further details and additional use cases, including step-by-step examples, refer to the Octavia Basic Load Balancing Cookbook. This resource provides comprehensive instructions on applying the same procedure to various scenarios.
Important
The Octavia service is available but it is not enabled by default to all HPC Cloud projects.
If you want to use it, please request access sending an email to superc@cineca.it.
Once the tenant is enabled to the service by the User Support Team, all users of the tenant will be able to use the service.
In this section, we will walk you through the steps to create a setup where two instances running nginx servers are connected to an HTTP load balancer. The load balancer will use the round-robin algorithm to evenly distribute incoming HTTP traffic across the two servers.
Important
Before creating a load balancer, ensure that the following resources are available in your tenant:
1 network and subnet
1 router
Desired security groups for the VMs: at the minimum, the Ingress rules for HTTP (port 80) and SSH (port 22)
2 instances: in our example, these VMs host an nginx web server each
At least 2 floating IPs: one associated to one of the VMs and an additional one available to be associated to the load balancer. The internal IP of the second VM can be used to login from the first VM if needed for configuration. Note that an additional Floating IP could be directly associated to the second VM. However, this would entail using an additional (and not strictly necessary) resource, which we try to avoid.
1 KeyPair: an SSH public key is needed to access the instances for their configuration
You can setup a very simple nginx web server in each VM by logging into each of the VM and running the following commands on the shell:
sudo apt-get update
sudo apt-get install -y nginx && \
echo "Hello! This is $(hostname)" > /var/www/html/index.html
Create the loadbalancer by clicking on “Network → Load Balancers → Create Load Balancer” and setting the following information. Once all the details are provided, click on “Create Load Balancer”.
Load Balancer Details
Name.
Subnet. Select the desired subnet.
![]()
Listener Details
Name.
Protocol and Port. The protocol defines the type of network traffic the listener will handle, while the port specifies the network port on which the listener will accept incoming traffic. In our example we select protocol HTTP and port 80.
![]()
Pool Details
Name.
Algorithm. The algorithm determines how traffic is distributed across the members. We select ROUND_ROBIN.
![]()
Pool Members
Add members. Choose the desired members among those available. We add VM-1 and VM-2, the names of the VMs in our example.
Port. For each VM, specify the port number on which the member will receive traffic. In our case, we expose the nginx server on port 80.
Weight. The weight of the member for load balancing purposes. The weight determines the relative portion of requests the member should handle compared to others. We use the default value.
![]()
Monitor Details
Decide whether you’d like to create a Health Monitor. In this example, we will not make use of a monitor.
![]()
Associate a floating IP to the load balancer.
Move to the Network → Load Balancers” section
Display the options within the drop-down menu on the right side for the desired load balancer, and click on “Associate Floating IP”.
![]()
Select the floating IP among those suggested in the drop-down menu “Floating IP address or Pool” and click on “Associate”.
![]()
The floating IP associated to the load balancer appears in the overview of its characteristics. In order to see the properties, click on the name of your load balancer in the “Network → Load Balancers” section of the dashboard.
Test your load balancer.
Use the above floating IP to reach the nginx servers. The traffic will be managed by the load balancer following the algorithm ROUND_ROBIN.
Important
Follow the instructions on how to setup your cloud environment at Command Line Interface
Install the Octavia service plugin
pip install python-octaviaclient
Create a Load Balancer
openstack loadbalancer create --name <loadbalancer_name> --vip-subnet-id <subnet_id>
The <subnet_id> can be found through the Horizon Dashboard. On the main menu, select the Network → Networks tab. Then, click on your network and select the Subnets tab. Finally, click on the desired subnet. This information can also be gathered using the CLI.
Note: Wait until the creation is completed. It will take a while and the next steps will return an error if the load balancer is not available.
Create a Listener
openstack loadbalancer listener create --name <listener_name> --protocol HTTP --protocol-port 80 <loadbalancer_name>
Create a Pool
openstack loadbalancer pool create --name <pool_name> --lb-algorithm <algorithm_e.g.ROUND_ROBIN> --listener <listener_name> --protocol HTTP
Add Members to the pools
openstack loadbalancer member create --subnet-id <subnet_id> --address <ip_vm_1> --protocol-port 80 <pool_name>
openstack loadbalancer member create --subnet-id <subnet_id> --address <ip_vm_2> --protocol-port 80 <pool_name>
You can find the IPs of the VMs in the Compute → Instances section of the lateral menu of Horizon Dashboard. The IPs can also be gathered using the CLI.
Associate a Floating IP to the load balancer
openstack floating ip set --port <port_id> <floating_ip>
You can find the <port_id> if you navigate to the description of your load balancer on the Horizon Dashboard. Select the Network → Load Balancers section on the left-hand menu of the dashboard. Then, click on your load balancer and go to the Overview tab. You can also use the CLI to identify the value of the <port_id>.
Test your load balancer.
Finally, use this floating IP to reach the nginx servers. The traffic will be managed by the load balancer following the algorithm <algorithm_e.g.ROUND_ROBIN>.