blob: 5d96ca7d742c86595be5f64ed65a0c2e8d4147ce [file] [log] [blame]
Michael Johnson8b9864d2019-01-24 10:49:35 -08001Devstack with Octavia Load Balancing
2====================================
Aishwarya Thangappa7c573062015-02-18 01:51:13 -08003
Michael Johnson8b9864d2019-01-24 10:49:35 -08004Starting with the OpenStack Pike release, Octavia is now a standalone service
5providing load balancing services for OpenStack.
Aishwarya Thangappa7c573062015-02-18 01:51:13 -08006
Michael Johnson8b9864d2019-01-24 10:49:35 -08007This guide will show you how to create a devstack with `Octavia API`_ enabled.
8
Andreas Jaeger0fc6b2c2019-07-30 17:52:55 +02009.. _Octavia API: https://docs.openstack.org/api-ref/load-balancer/v2/index.html
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080010
11Phase 1: Create DevStack + 2 nova instances
12--------------------------------------------
13
Richard Theis7e550682015-10-13 07:51:05 -050014First, set up a vm of your choice with at least 8 GB RAM and 16 GB disk space,
Michael Johnson8b9864d2019-01-24 10:49:35 -080015make sure it is updated. Install git and any other developer tools you find
16useful.
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080017
18Install devstack
19
David Rabelc77c9492018-04-05 20:56:22 +020020::
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080021
Matt Riedemann9b6d2f22019-06-18 10:43:16 -040022 git clone https://opendev.org/openstack/devstack
Michael Johnson8b9864d2019-01-24 10:49:35 -080023 cd devstack/tools
24 sudo ./create-stack-user.sh
25 cd ../..
26 sudo mv devstack /opt/stack
27 sudo chown -R stack.stack /opt/stack/devstack
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080028
Michael Johnson8b9864d2019-01-24 10:49:35 -080029This will clone the current devstack code locally, then setup the "stack"
30account that devstack services will run under. Finally, it will move devstack
31into its default location in /opt/stack/devstack.
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080032
Michael Johnson8b9864d2019-01-24 10:49:35 -080033Edit your ``/opt/stack/devstack/local.conf`` to look like
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080034
David Rabelc77c9492018-04-05 20:56:22 +020035::
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080036
37 [[local|localrc]]
Matt Riedemann9b6d2f22019-06-18 10:43:16 -040038 enable_plugin octavia https://opendev.org/openstack/octavia
Michael Johnson8b9864d2019-01-24 10:49:35 -080039 # If you are enabling horizon, include the octavia dashboard
Matt Riedemann9b6d2f22019-06-18 10:43:16 -040040 # enable_plugin octavia-dashboard https://opendev.org/openstack/octavia-dashboard.git
Michael Johnson8b9864d2019-01-24 10:49:35 -080041 # If you are enabling barbican for TLS offload in Octavia, include it here.
Andreas Jaeger8dd89e52019-08-11 16:00:12 +020042 # enable_plugin barbican https://opendev.org/openstack/barbican
Michael Johnson8b9864d2019-01-24 10:49:35 -080043
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080044 # ===== BEGIN localrc =====
45 DATABASE_PASSWORD=password
46 ADMIN_PASSWORD=password
47 SERVICE_PASSWORD=password
Michael Johnson8b9864d2019-01-24 10:49:35 -080048 SERVICE_TOKEN=password
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080049 RABBIT_PASSWORD=password
50 # Enable Logging
51 LOGFILE=$DEST/logs/stack.sh.log
52 VERBOSE=True
53 LOG_COLOR=True
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080054 # Pre-requisite
55 ENABLED_SERVICES=rabbit,mysql,key
Michael Johnson8b9864d2019-01-24 10:49:35 -080056 # Horizon - enable for the OpenStack web GUI
57 # ENABLED_SERVICES+=,horizon
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080058 # Nova
Matt Riedemann62e27d32019-04-23 13:44:37 -040059 ENABLED_SERVICES+=,n-api,n-crt,n-cpu,n-cond,n-sch,n-api-meta,n-sproxy
Michael Johnson8b9864d2019-01-24 10:49:35 -080060 ENABLED_SERVICES+=,placement-api,placement-client
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080061 # Glance
Takashi Kajinamic3db92b2020-06-04 23:57:18 +090062 ENABLED_SERVICES+=,g-api
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080063 # Neutron
Michael Johnson8b9864d2019-01-24 10:49:35 -080064 ENABLED_SERVICES+=,q-svc,q-agt,q-dhcp,q-l3,q-meta,neutron
Richard Theis7e550682015-10-13 07:51:05 -050065 ENABLED_SERVICES+=,octavia,o-cw,o-hk,o-hm,o-api
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080066 # Cinder
67 ENABLED_SERVICES+=,c-api,c-vol,c-sch
68 # Tempest
69 ENABLED_SERVICES+=,tempest
Michael Johnson8b9864d2019-01-24 10:49:35 -080070 # Barbican - Optionally used for TLS offload in Octavia
71 # ENABLED_SERVICES+=,barbican
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080072 # ===== END localrc =====
73
74Run stack.sh and do some sanity checks
75
David Rabelc77c9492018-04-05 20:56:22 +020076::
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080077
Michael Johnson8b9864d2019-01-24 10:49:35 -080078 sudo su - stack
79 cd /opt/stack/devstack
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080080 ./stack.sh
81 . ./openrc
82
Armando Migliaccio4f11ff32016-10-27 06:15:23 -070083 openstack network list # should show public and private networks
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080084
85Create two nova instances that we can use as test http servers:
86
David Rabelc77c9492018-04-05 20:56:22 +020087::
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080088
89 #create nova instances on private network
Michael Johnson8b9864d2019-01-24 10:49:35 -080090 openstack server create --image $(openstack image list | awk '/ cirros-.*-x86_64-.* / {print $2}') --flavor 1 --nic net-id=$(openstack network list | awk '/ private / {print $2}') node1
Lucas Xuf745a0a2019-05-30 20:49:29 +000091 openstack server create --image $(openstack image list | awk '/ cirros-.*-x86_64-.* / {print $2}') --flavor 1 --nic net-id=$(openstack network list | awk '/ private / {print $2}') node2
Michael Johnson8b9864d2019-01-24 10:49:35 -080092 openstack server list # should show the nova instances just created
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080093
Richard Theis7e550682015-10-13 07:51:05 -050094 #add secgroup rules to allow ssh etc..
Armando Migliaccio4f11ff32016-10-27 06:15:23 -070095 openstack security group rule create default --protocol icmp
96 openstack security group rule create default --protocol tcp --dst-port 22:22
97 openstack security group rule create default --protocol tcp --dst-port 80:80
Aishwarya Thangappa7c573062015-02-18 01:51:13 -080098
Michael Johnson8b9864d2019-01-24 10:49:35 -080099Set up a simple web server on each of these instances. ssh into each instance (username 'cirros', password 'cubswin:)' or 'gocubsgo') and run
Aishwarya Thangappa7c573062015-02-18 01:51:13 -0800100
David Rabelc77c9492018-04-05 20:56:22 +0200101::
Aishwarya Thangappa7c573062015-02-18 01:51:13 -0800102
103 MYIP=$(ifconfig eth0|grep 'inet addr'|awk -F: '{print $2}'| awk '{print $1}')
104 while true; do echo -e "HTTP/1.0 200 OK\r\n\r\nWelcome to $MYIP" | sudo nc -l -p 80 ; done&
105
Michael Johnson8b9864d2019-01-24 10:49:35 -0800106Phase 2: Create your load balancer
107----------------------------------
108
109Make sure you have the 'openstack loadbalancer' commands:
Aishwarya Thangappa7c573062015-02-18 01:51:13 -0800110
David Rabelc77c9492018-04-05 20:56:22 +0200111::
Aishwarya Thangappa7c573062015-02-18 01:51:13 -0800112
Michael Johnson8b9864d2019-01-24 10:49:35 -0800113 pip install python-octaviaclient
Aishwarya Thangappa7c573062015-02-18 01:51:13 -0800114
Michael Johnson8b9864d2019-01-24 10:49:35 -0800115Create your load balancer:
116
117::
118
119 openstack loadbalancer create --name lb1 --vip-subnet-id private-subnet
120 openstack loadbalancer show lb1 # Wait for the provisioning_status to be ACTIVE.
121 openstack loadbalancer listener create --protocol HTTP --protocol-port 80 --name listener1 lb1
122 openstack loadbalancer show lb1 # Wait for the provisioning_status to be ACTIVE.
123 openstack loadbalancer pool create --lb-algorithm ROUND_ROBIN --listener listener1 --protocol HTTP --name pool1
124 openstack loadbalancer show lb1 # Wait for the provisioning_status to be ACTIVE.
125 openstack loadbalancer healthmonitor create --delay 5 --timeout 2 --max-retries 1 --type HTTP pool1
126 openstack loadbalancer show lb1 # Wait for the provisioning_status to be ACTIVE.
127 openstack loadbalancer member create --subnet-id private-subnet --address <web server 1 address> --protocol-port 80 pool1
128 openstack loadbalancer show lb1 # Wait for the provisioning_status to be ACTIVE.
129 openstack loadbalancer member create --subnet-id private-subnet --address <web server 2 address> --protocol-port 80 pool1
130
131Please note: The <web server # address> fields are the IP addresses of the nova
132servers created in Phase 1.
133Also note, using the API directly you can do all of the above commands in one
134API call.
135
136Phase 3: Test your load balancer
137--------------------------------
138
139::
140
141 openstack loadbalancer show lb1 # Note the vip_address
142 curl http://<vip_address>
143 curl http://<vip_address>
144
145This should show the "Welcome to <IP>" message from each member server.