Skip to content

Instantly share code, notes, and snippets.

@zhanghui9700
Created September 20, 2016 10:17
Show Gist options
  • Save zhanghui9700/2cf1258567bedfb748a1f7e999b345f4 to your computer and use it in GitHub Desktop.
Save zhanghui9700/2cf1258567bedfb748a1f7e999b345f4 to your computer and use it in GitHub Desktop.

Neutron LoadBalancer V2

1. create loadbalancer

1. create load balancer (name, subnet)
2. create listener
2. create listener
3. create pool
4. add member to pool
5. create health monitor

neutron commands

root@node-3:~# neutron lbaas-loadbalancer-show c9646493-cc1e-4bfc-baba-1c235bbf3053                                                                                                                          
+---------------------+------------------------------------------------+
| Field               | Value                                          |
+---------------------+------------------------------------------------+
| admin_state_up      | True                                           |
| description         | LB lb-80 created by portal                     |
| id                  | c9646493-cc1e-4bfc-baba-1c235bbf3053           |
| listeners           | {"id": "89603664-8890-45ed-95d9-13672e586f93"} |
| name                | lb-80                                          |
| operating_status    | ONLINE                                         |
| pools               | {"id": "8b40205b-b85d-434e-bb4f-e37218f7d6d9"} |
| provider            | haproxy                                        |
| provisioning_status | ACTIVE                                         |
| tenant_id           | f724754e765648548122e8c20e41d6cc               |
| vip_address         | 172.16.200.24                                  |
| vip_port_id         | 8fbf1513-aebf-4d45-81c1-dd73f67f2574           |
| vip_subnet_id       | f47e24dd-7679-4608-aa0e-5462274722b4           |
+---------------------+------------------------------------------------+

    
root@node-3:~# neutron lbaas-listener-show 89603664-8890-45ed-95d9-13672e586f93                                                                                                                              
+---------------------------+------------------------------------------------+
| Field                     | Value                                          |
+---------------------------+------------------------------------------------+
| admin_state_up            | True                                           |
| connection_limit          | -1                                             |
| default_pool_id           | 8b40205b-b85d-434e-bb4f-e37218f7d6d9           |
| default_tls_container_ref |                                                |
| description               | LB lb-80 listener                              |
| id                        | 89603664-8890-45ed-95d9-13672e586f93           |
| loadbalancers             | {"id": "c9646493-cc1e-4bfc-baba-1c235bbf3053"} |
| name                      | lb-80__listener                                |
| protocol                  | HTTP                                           |
| protocol_port             | 80                                             |
| sni_container_refs        |                                                |
| tenant_id                 | f724754e765648548122e8c20e41d6cc               |
+---------------------------+------------------------------------------------+

root@node-3:~# neutron lbaas-pool-show 8b40205b-b85d-434e-bb4f-e37218f7d6d9
+---------------------+------------------------------------------------+
| Field               | Value                                          |
+---------------------+------------------------------------------------+
| admin_state_up      | True                                           |
| description         | LB lb-80 pool                                  |
| healthmonitor_id    | 93c66ad8-3fcc-47ce-a9e2-153cafd394d6           |
| id                  | 8b40205b-b85d-434e-bb4f-e37218f7d6d9           |
| lb_algorithm        | ROUND_ROBIN                                    |
| listeners           | {"id": "89603664-8890-45ed-95d9-13672e586f93"} |
| loadbalancers       | {"id": "c9646493-cc1e-4bfc-baba-1c235bbf3053"} |
| members             | 1dac2daa-b0ea-435f-86bb-fb9e4a30ac37           |
|                     | 221d134c-3091-4c32-8498-bab2a1eb3097           |
| name                | lb-80__pool                                    |
| protocol            | HTTP                                           |
| session_persistence |                                                |
| tenant_id           | f724754e765648548122e8c20e41d6cc               |
+---------------------+------------------------------------------------+

root@node-3:~# neutron lbaas-member-list 8b40205b-b85d-434e-bb4f-e37218f7d6d9
+--------------------------------------+------+--------------+---------------+--------+--------------------------------------+----------------+
| id                                   | name | address      | protocol_port | weight | subnet_id                            | admin_state_up |
+--------------------------------------+------+--------------+---------------+--------+--------------------------------------+----------------+
| 1dac2daa-b0ea-435f-86bb-fb9e4a30ac37 |      | 172.16.200.6 |          8000 |    100 | f47e24dd-7679-4608-aa0e-5462274722b4 | True           |
| 221d134c-3091-4c32-8498-bab2a1eb3097 |      | 172.16.200.7 |          8000 |    100 | f47e24dd-7679-4608-aa0e-5462274722b4 | True           |
+--------------------------------------+------+--------------+---------------+--------+--------------------------------------+----------------+

root@node-3:~# neutron lbaas-healthmonitor-show 93c66ad8-3fcc-47ce-a9e2-153cafd394d6
+----------------+------------------------------------------------+
| Field          | Value                                          |
+----------------+------------------------------------------------+
| admin_state_up | True                                           |
| delay          | 5                                              |
| id             | 93c66ad8-3fcc-47ce-a9e2-153cafd394d6           |
| max_retries    | 3                                              |
| name           | lb-80__monitor                                 |
| pools          | {"id": "8b40205b-b85d-434e-bb4f-e37218f7d6d9"} |
| tenant_id      | f724754e765648548122e8c20e41d6cc               |
| timeout        | 5                                              |
| type           | PING                                           |
+----------------+------------------------------------------------+

root@node-3:~# neutron lbaas-healthmonitor-show a924e56a-959e-45ab-9f2e-b2773f26f1b1
+----------------+------------------------------------------------+
| Field          | Value                                          |
+----------------+------------------------------------------------+
| admin_state_up | True                                           |
| delay          | 5                                              |
| expected_codes | 202                                            |
| http_method    | HEAD                                           |
| id             | a924e56a-959e-45ab-9f2e-b2773f26f1b1           |
| max_retries    | 3                                              |
| name           | mysql-lb__monitor                              |
| pools          | {"id": "14c7ac0e-25c6-41c6-9193-f871f6ffd5f9"} |
| tenant_id      | f724754e765648548122e8c20e41d6cc               |
| timeout        | 5                                              |
| type           | HTTP                                           |
| url_path       | /status                                        |
+----------------+------------------------------------------------+

loadbalancer status

root@node-3:~# neutron lbaas-loadbalancer-status 956258e4-e280-4387-8c6c-c21efc728ab9
{
    "loadbalancer": {
        "name": "lb-test", 
        "provisioning_status": "ACTIVE", 
        "listeners": [
            {
                "name": "lb-test-listener", 
                "provisioning_status": "ACTIVE", 
                "pools": [
                    {
                        "name": "Pool 1", 
                        "provisioning_status": "ACTIVE", 
                        "healthmonitor": {}, 
                        "members": [
                            {
                                "name": "", 
                                "provisioning_status": "ACTIVE", 
                                "address": "10.10.0.10", 
                                "protocol_port": 80, 
                                "id": "48b331a6-a7c3-4a94-a26a-04c6422a5254", 
                                "operating_status": "ONLINE"
                            }
                        ], 
                        "id": "b47b74ed-5ee7-4b73-b042-47ec3d2c3df2", 
                        "operating_status": "ONLINE"
                    }
                ], 
                "l7policies": [], 
                "id": "3c88564e-d083-4a0a-974d-08c973f55d45", 
                "operating_status": "ONLINE"
            }
        ], 
        "pools": [
            {
                "name": "Pool 1", 
                "provisioning_status": "ACTIVE", 
                "healthmonitor": {}, 
                "members": [
                    {
                        "name": "", 
                        "provisioning_status": "ACTIVE", 
                        "address": "10.10.0.10", 
                        "protocol_port": 80, 
                        "id": "48b331a6-a7c3-4a94-a26a-04c6422a5254", 
                        "operating_status": "ONLINE"
                    }
                ], 
                "id": "b47b74ed-5ee7-4b73-b042-47ec3d2c3df2", 
                "operating_status": "ONLINE"
            }
        ], 
        "id": "956258e4-e280-4387-8c6c-c21efc728ab9", 
        "operating_status": "ONLINE"
    }
}

Ref: Load Balancer Object Model

<LoadBalancer: {
u'description': u'account-web-server-80', 
u'provisioning_status': u'ACTIVE', 
u'tenant_id': u'e2d57ff4d8734bf98e45e920db11ed3c', 
u'admin_state_up': True, 
u'provider': u'haproxy', 
'floating_ip': {}, 
u'pools': [{u'id': u'44af2451-aa55-4516-9cfd-d4a1d3818770'}], 
u'listeners': [{u'id': u'0c50cb34-395c-4317-b10d-cddd112b8bbf'}], 
u'vip_port_id': u'0d53ea6a-ad8e-4c69-bc51-6622aa53fb1b', 
u'vip_address': u'10.10.0.101', 
u'vip_subnet_id': u'3c0e1727-5bcf-4142-ae4e-8c4678873c17', 
'admin_state': 'UP', 
u'id': u'4847a4cc-130e-4bde-8c62-f4f8fbc87973', 
u'operating_status': u'ONLINE', 
u'name': u'first-lb'}>

<LoadBalancerListener: {
u'default_pool_id': u'b47b74ed-5ee7-4b73-b042-47ec3d2c3df2', 
u'protocol': u'HTTP', 
u'description': u'', 
u'default_tls_container_ref': None, 
u'admin_state_up': True, 
u'loadbalancers': [{u'id': u'956258e4-e280-4387-8c6c-c21efc728ab9'}], 
u'tenant_id': u'e2d57ff4d8734bf98e45e920db11ed3c', 
u'sni_container_refs': [], 
u'connection_limit': -1, 
'admin_state': 'UP', 
u'protocol_port': 80, 
u'id': u'3c88564e-d083-4a0a-974d-08c973f55d45', 
u'name': u'lb-test-listener'}>

<LoadBalancerPool: {
u'lb_algorithm': u'LEAST_CONNECTIONS', 
u'protocol': u'HTTP', 
u'description': u'first-lb-pool-desc', 
u'admin_state_up': True, 
u'loadbalancers': [{u'id': u'4847a4cc-130e-4bde-8c62-f4f8fbc87973'}], 
u'tenant_id': u'e2d57ff4d8734bf98e45e920db11ed3c',
u'session_persistence': None, 
u'healthmonitor_id': u'11537dbc-9f12-44b4-99eb-cabd88c7f5f0', 
u'listeners': [{u'id': u'0c50cb34-395c-4317-b10d-cddd112b8bbf'}], 
'admin_state': 'UP', 
u'members': [], 
u'id': u'44af2451-aa55-4516-9cfd-d4a1d3818770', 
u'name': u'first-lb-pool'}>
<LoadBalancerPool: {
u'lb_algorithm': u'ROUND_ROBIN', 
u'protocol': u'HTTP', 
u'description': u'', 
u'admin_state_up': True, 
u'loadbalancers': [{u'id': u'956258e4-e280-4387-8c6c-c21efc728ab9'}], 
u'tenant_id': u'e2d57ff4d8734bf98e45e920db11ed3c',
u'session_persistence': None, 
u'healthmonitor_id': None, 
u'listeners': [{u'id': u'3c88564e-d083-4a0a-974d-08c973f55d45'}], 
'admin_state': 'UP', 
u'members': [{u'id': u'48b331a6-a7c3-4a94-a26a-04c6422a5254'}], 
u'id': u'b47b74ed-5ee7-4b73-b042-47ec3d2c3df2', 
u'name': u'Pool 1'}>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment