Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 12. Grouping Load-balancing service objects by using tags
Tags are are arbitrary strings that you can add to Red Hat OpenStack Platform Load-balancing service (octavia) objects for the purpose of classifying them into groups. Tags do not affect the functionality of load-balancing objects: load balancers, listeners, pools, members, health monitors, rules, and polices. You can add a tag when you create the object, or add or remove a tag after the object has been created.
By associating a particular tag with load-balancing objects, you can run list commands to filter objects that belong to one or more groups. Being able to filter objects into one or more groups can be a starting point in managing usage, allocation, and maintenance of your load-balancing service resources. The ability to tag objects can also be leveraged by automated configuration management tools.
The topics included in this section are:
12.1. Adding tags when creating Load-balancing service objects
You can add a tag of your choice when you create a Red Hat OpenStack Load-balancing service (octavia) object. When the tags are in place, you can filter load balancers, listeners, pools, members, health monitors, rules, and policies by using their respective loadbalancer list
commands.
Procedure
Source your credentials file.
Example
$ source ~/overcloudrc
Add a tag to a load-balancing object when you create it by using the
--tag <tag>
option with the appropriatecreate
command for the object:- openstack loadbalancer create --tag <tag> …
- openstack loadbalancer listener create --tag <tag> …
- openstack loadbalancer pool create --tag <tag> …
- openstack loadbalancer member create --tag <tag> …
- openstack loadbalancer healthmonitor create --tag <tag> …
- openstack loadbalancer l7policy create --tag <tag> …
openstack loadbalancer l7rule create --tag <tag> …
NoteA tag can be any valid unicode string with a maximum length of 255 characters.
$ openstack loadbalancer create --name lb1 \ --vip-subnet-id public_subnet --tag Finance --tag Sales
NoteLoad-balancing service objects can have one or more tags. Repeat the
--tag <tag>
option for each additional tag that you want to add.$ openstack loadbalancer listener create --name listener1 --protocol HTTP --protocol-port 80 --tag Sales lb1
$ openstack loadbalancer pool create --name pool1 \ --lb-algorithm ROUND_ROBIN --listener listener1 \ --protocol HTTP --tag Sales
$ openstack loadbalancer member create --name member1 \ --subnet-id private_subnet --address 192.0.2.10 --protocol-port 80 \ --tag Sales pool1
$ openstack loadbalancer healthmonitor create --name healthmon1 \ --delay 15 --max-retries 4 --timeout 10 --type HTTP --url-path / \ --tag Sales pool1
$ openstack loadbalancer l7policy create --action REDIRECT_PREFIX \ --redirect-prefix https://www.example.com/ \ --name policy1 http_listener --tag Sales
$ openstack loadbalancer l7rule create --compare-type STARTS_WITH \ --type PATH --value / --tag Sales policy1
Verification
Confirm that object that you created exists, and contains the tag that you added by using the appropriate
show
command for the object.Example
In this example, the
show
command is run on the loadbalancer,lb1
:$ openstack loadbalancer show lb1
Sample output
+---------------------+--------------------------------------+ | admin_state_up | True | | availability_zone | None | | created_at | 2022-08-26T19:34:15 | | description | | | flavor_id | None | | id | 7975374b-3367-4436-ab19-2d79d8c1f29b | | listeners | | | name | lb1 | | operating_status | ONLINE | | pools | | | project_id | 2eee3b86ca404cdd977281dac385fd4e | | provider | amphora | | provisioning_status | ACTIVE | | updated_at | 2022-08-30T13:30:17 | | vip_address | 172.24.3.76 | | vip_network_id | 4c241fc4-95eb-491a-affe-26c53a8805cd | | vip_port_id | 9978a598-cc34-47f7-ba28-49431d570fd1 | | vip_qos_policy_id | None | | vip_subnet_id | e999d323-bd0f-4469-974f-7f66d427e507 | | tags | Finance | | | Sales | +---------------------+--------------------------------------+
- loadbalancer create in the Command line interface reference
- loadbalancer show in the Command line interface reference
12.2. Adding or removing tags on pre-existing Load-balancing service objects
You can add and remove tags of your choice on Red Hat OpenStack Load-balancing service (octavia) objects after they have been created. When the tags are in place, you can filter load balancers, listeners, pools, members, health monitors, rules, and polices by using the their respective loadbalancer list
commands.
Procedure
Source your credentials file.
Example
$ source ~/overcloudrc
Do one of the following:
Add a tag to a pre-existing load-balancing object by using the
--tag <tag>
option with the appropriateset
command for the object:-
openstack loadbalancer set --tag <tag> <load_balancer_name_or_ID>
-
openstack loadbalancer listener set --tag <tag> <listener_name_or_ID>
-
openstack loadbalancer pool set --tag <tag> <pool_name_or_ID>
-
openstack loadbalancer member set --tag <tag> <pool_name_or_ID> <member_name_or_ID>
-
openstack loadbalancer healthmonitor set --tag <tag> <healthmon_name_or_ID>
-
openstack loadbalancer l7policy set --tag <tag> <l7policy_name_or_ID>
openstack loadbalancer l7rule set --tag <tag> <l7policy_name_or_ID> <l7rule_ID>
NoteA tag can be any valid unicode string with a maximum length of 255 characters.
Example
In this example the tags,
Finance
andSales
, are added to the load balancer,lb1
:$ openstack loadbalancer set --tag Finance --tag Sales lb1
NoteLoad-balancing service objects can have one or more tags. Repeat the
--tag <tag>
option for each additional tag that you want to add.
-
Remove a tag from a pre-existing load-balancing object by using the
--tag <tag>
option with the appropriateunset
command for the object:-
openstack loadbalancer unset --tag <tag> <load_balancer_name_or_ID>
-
openstack loadbalancer listener unset --tag <tag> <listener_name_or_ID>
-
openstack loadbalancer pool unset --tag <tag> <pool_name_or_ID>
-
openstack loadbalancer member unset --tag <tag> <pool_name_or_ID> <member_name_or_ID>
-
openstack loadbalancer healthmonitor unset --tag <tag> <healthmon_name_or_ID>
-
openstack loadbalancer l7policy unset --tag <tag> <policy_name_or_ID>
openstack loadbalancer l7rule unset --tag <tag> <policy_name_or_ID> <l7rule_ID>
Example
In this example, the tag,
Sales
, is removed from the load balancer,lb1
:$ openstack loadbalancer unset --tag Sales lb1
-
Remove all tags from a pre-existing load-balancing object by using the
--no-tag
option with the appropriateset
command for the object:-
openstack loadbalancer set --no-tag <load_balancer_name_or_ID>
-
openstack loadbalancer listener set --no-tag <listener_name_or_ID>
-
openstack loadbalancer pool set --no-tag <pool_name_or_ID>
-
openstack loadbalancer member set --no-tag <pool_name_or_ID> <member_name_or_ID>
-
openstack loadbalancer healthmonitor set --no-tag <healthmon_name_or_ID>
-
openstack loadbalancer l7policy set --no-tag <l7policy_name_or_ID>
openstack loadbalancer l7rule set --no-tag <l7policy_name_or_ID> <l7rule_ID>
Example
In this example, all tags are removed from the load balancer,
lb1
:$ openstack loadbalancer set --no-tag lb1
-
Verification
Confirm that you have added or removed one or more tags on the load-balancing object, by using the appropriate
show
command for the object.Example
In this example, the
show
command is run on the loadbalancer,lb1
:$ openstack loadbalancer show lb1
Sample output
+---------------------+--------------------------------------+ | admin_state_up | True | | availability_zone | None | | created_at | 2022-08-26T19:34:15 | | description | | | flavor_id | None | | id | 7975374b-3367-4436-ab19-2d79d8c1f29b | | listeners | | | name | lb1 | | operating_status | ONLINE | | pools | | | project_id | 2eee3b86ca404cdd977281dac385fd4e | | provider | amphora | | provisioning_status | ACTIVE | | updated_at | 2022-08-30T13:30:17 | | vip_address | 172.24.3.76 | | vip_network_id | 4c241fc4-95eb-491a-affe-26c53a8805cd | | vip_port_id | 9978a598-cc34-47f7-ba28-49431d570fd1 | | vip_qos_policy_id | None | | vip_subnet_id | e999d323-bd0f-4469-974f-7f66d427e507 | | tags | Finance | | | Sales | +---------------------+--------------------------------------+
- loadbalancer set in the Command line interface reference
- loadbalancer show in the Command line interface reference
12.3. Filtering Load-balancing service objects by using tags
You can use the Red Hat OpenStack Load-balancing service (octavia) to create lists of objects. For the objects that are tagged, you can create filtered lists: lists that include or exclude objects based on whether your objects contain one or more of the specified tags. Being able to filter load balancers, listeners, pools, members, health monitors, rules, and policies using tags can be a starting point in managing usage, allocation, and maintenance of your load-balancing service resources.
Procedure
Source your credentials file.
Example
$ source ~/overcloudrc
Filter the objects that you want to list by running the appropriate
loadbalancer list
command for the objects with one of the tag options:Table 12.1. Tag options for filtering objects In my list, I want to… Examples include objects that match all specified tags.
$ openstack loadbalancer list --tags Sales,Finance
$ openstack loadbalancer listener list --tags Sales,Finance
$ openstack loadbalancer l7pool list --tags Sales,Finance
$ openstack loadbalancer member list --tags Sales,Finance pool1
$ openstack loadbalancer healthmonitor list --tags Sales,Finance
$ openstack loadbalancer l7policy list --tags Sales,Finance
$ openstack loadbalancer l7rule list --tags Sales,Finance policy1
include objects that match one or more specified tags.
$ openstack loadbalancer list --any-tags Sales,Finance
$ openstack loadbalancer listener list --any-tags Sales,Finance
$ openstack loadbalancer l7pool list --any-tags Sales,Finance
$ openstack loadbalancer member list --any-tags Sales,Finance pool1
$ openstack loadbalancer healthmonitor list --any-tags Sales,Finance
$ openstack loadbalancer l7policy list --any-tags Sales,Finance
$ openstack loadbalancer l7rule list --any-tags Sales,Finance policy1
exclude objects that match all specified tags.
$ openstack loadbalancer list --not-tags Sales,Finance
$ openstack loadbalancer listener list --not-tags Sales,Finance
$ openstack loadbalancer l7pool list --not-tags Sales,Finance
$ openstack loadbalancer member list --not-tags Sales,Finance pool1
$ openstack loadbalancer healthmonitor list --not-tags Sales,Finance
$ openstack loadbalancer l7policy list --not-tags Sales,Finance
$ openstack loadbalancer l7rule list --not-tags Sales,Finance policy1
exclude objects that match one or more specified tags.
$ openstack loadbalancer list --not-any-tags Sales,Finance
$ openstack loadbalancer listener list --not-any-tags Sales,Finance
$ openstack loadbalancer l7pool list --not-any-tags Sales,Finance
$ openstack loadbalancer member list --not-any-tags Sales,Finance pool1
$ openstack loadbalancer healthmonitor list --not-any-tags Sales,Finance
$ openstack loadbalancer l7policy list --not-any-tags Sales,Finance
$ openstack loadbalancer l7rule list --not-any-tags Sales,Finance policy1
NoteWhen specifying more than one tag, separate the tags by using a comma.
Additional resources
- loadbalancer list in the Command line interface reference