From 35600f9f0469d9beffbfe7587258900a2eef0900 Mon Sep 17 00:00:00 2001
From: Matteo Di Fazio <matteo.difazio@garr.it>
Date: Tue, 19 Sep 2023 15:28:40 +0200
Subject: [PATCH] edit lbaas_tutorial

---
 .../kb/openstack/lbaas_services_tutorial.rst  | 94 +++++++------------
 1 file changed, 32 insertions(+), 62 deletions(-)

diff --git a/web/support/kb/openstack/lbaas_services_tutorial.rst b/web/support/kb/openstack/lbaas_services_tutorial.rst
index 3581940f..7440dcb4 100644
--- a/web/support/kb/openstack/lbaas_services_tutorial.rst
+++ b/web/support/kb/openstack/lbaas_services_tutorial.rst
@@ -1,79 +1,49 @@
-How use OpenStack LBaaS for different services
-==============================================
+Create an Openstack LB
+======================
 
-This guide show you how configure the OpenStack LBaaS to optimize the use of floating ip. 
-The purpose is to allow users to take advantage of the LBaaS tool to optimize the number of their floating IPs by using the load balancer resources to access the VMs. Specifically it will be shown an example of how you can use a load balancer to access via SSH to different machines.
+This guide shows how to create and use an Openstack LB. We will create two VMs, a LB that will balance the load between these two VMs, and will test the LB with curl.
 
-**N.B.**: it can be assumed to access via SSH to three different VMs through the load balancer ports: 2021, 2022 and 2023.
+Create the VMs
+--------------
 
+Create two VMs in your Openstack project through the Dashboard or CLI. Name it, for example, test-vm-1 and test-vm-2.
 
-Install OpenStack and Neutron CLI and create the Application Credentials
-------------------------------------------------------------------------
+Create a new security group that enables network traffic on port 80 and associate it to the VMs.
 
-The first step is to install the OpenStack and Neutron CLI to execute the next operations::
+Create and associate a floating IP to each VM.
 
-	$ sudo apt install -y python3-dev python3-pip
-	$ sudo pip3 install python-openstackclient python-neutronclient
 
-Now it is necessary create an application credentials from the Openstack Dashboard as follow::
+Run a simple web server
+-----------------------
 
-	Identity -> Application Credentials -> Create Application Credentials
+On test-vm-1:
 
-once created the application credentials, you can download it from button: **Download openrc file**.
+1. ``ssh ubuntu@<floating-ip-srv1>``
+2. ``vim index.html`` -> <html>This is SERVER 1</html>
+3. ``sudo python3 -m http.server 80 &> /dev/null &``
 
-Open a console and run the follow command::
+On test-vm-2:
 
-	$ source <path/openrc_file>
+1. ``ssh ubuntu@<floating-ip-srv1>``
+2. ``vim index.html`` -> <html>This is SERVER 2</html>
+3. ``sudo python3 -m http.server 80 &> /dev/null &``
 
+Create a new LB
+---------------
 
-Creating a load balancer for the SSH service
---------------------------------------------
+1. ``openstack loadbalancer create --name test-lb --vip-subnet-id <subnet-id>``
+2. ``openstack loadbalancer listener create --name test-listener --protocol HTTP --protocol-port 80 test-lb``
+3. ``openstack loadbalancer pool create --name test-pool --lb-algorithm ROUND_ROBIN --listener test-listener --protocol HTTP``
+4. ``openstack loadbalancer member create --subnet-id <subnet-id> --address <test-vm-1-private-ip> --protocol-port 80 test-pool``
+5. ``openstack loadbalancer member create --subnet-id <subnet-id> --address <test-vm-2-private-ip> --protocol-port 80 test-pool``
+6. Get the loadbalancer vip port (vip_port_id) -> ``openstack loadbalancer show test-lb``
+7. Create a new floating ip through the Openstack Dashboard or CLI
+8. Associate the previous floating ip to the LB vip port-> ``openstack floating ip set --port <vip-port-id> <floating-ip>``
 
-This section show you how create and configure a load balancer for the SSH service.
+**Note**: now it is possibile to remove the floating ips from the two VMs.
 
-**N.B.**: the VMs must have already been created and associate to them a security group with the rule to enable the SSH port (22). Furthermore the VMs have only the private IP, the load balancer allow to use a single floating IP for the service.
+Test the LB
+-----------
 
-Creating the load balancer::
+``curl <LB-floating-ip>``
 
-	$ neutron lbaas-loadbalancer-create --name lb-ssh default-sub
-
-Get the load balancer vip port id, from the previous command, to set the load balancer port::
-
-	$ openstack port set --name lb-port <vip_port_id>
-
-Creating the load balancer security group::
-
-	$ openstack security group create lb-sec-group
-
-and add rules to the security group to enable the ports for each VM (you need enable a different port for each VM, example: 2021, 2022 and 2023). Repeat the command for all ports::
-
-	$ openstack security group rule create --ingress --protocol tcp --dst <port> --remote-ip 0.0.0.0/0 lb-sec-group
-
-now assign the security group to the load balancer port::
-
-	$ openstack port set --security-group lb-sec-group lb-port
-
-Creating the listeners for each port enabled in the security group (repeat the command for all ports)::
-
-	$ neutron lbaas-listener-create --name listener-vm<n> --loadbalancer lb-ssh --protocol TCP --protocol-port <port>
-
-Creating the pools and members for each listener (repeat the commands for all listeners)::
-
-	$ neutron lbaas-pool-create --name pool-vm<n> --lb-algorithm ROUND_ROBIN --listener listener-vm<n> --protocol TCP
-	$ neutron lbaas-member-create --subnet default-sub --address <vm-private-ip> --protocol-port 22 pool-vm<n>
-
-Creating a floating IP::
-
-	$ openstack floating ip create floating-ip
-
-and assign the IP to the load balancer port::
-
-	$ openstack floating ip set --port lb-port <floating_ip>
-
-
-Example test
-------------
-
-Now you can access to your VMs modifying the port in the SSH command line (example port: 2021, 2022 and 2023)::
-
-	$ ssh -i <path/ssh_key> <user>@<ip> -p <port>
-- 
GitLab