Chapter 11. Grouping Load-balancing service objects by using tags


Tags are arbitrary strings that you can add to Red Hat OpenStack Services on OpenShift (RHOSO) 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 policies. 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.

You can add a tag of your choice when you create a Red Hat OpenStack Services on OpenShift (RHOSO) 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 loadbalancer list commands.

Prerequisites

  • The administrator has created a project for you and has provided you with a clouds.yaml file for you to access the cloud.
  • The python-openstackclient package is on your workstation.

    $ dnf list installed python-openstackclient

Procedure

  1. Confirm that the system OS_CLOUD variable is set for your cloud:

    $ echo $OS_CLOUD
    my_cloud

    Reset the variable if necessary:

    $ export OS_CLOUD=my_other_cloud

    As an alternative, you can specify the cloud name by adding the --os-cloud <cloud_name> option each time you run an openstack command.

  2. Add a tag to a load-balancing object when you create it by using the --tag <tag> option with the appropriate create command for the object:

    Note

    A tag can be any valid Unicode string with a maximum length of 255 characters.

    Example - creating and tagging a load balancer

    In this example a load balancer, lb1, is created with two tags, Finance and Sales:

    $ openstack loadbalancer create --name lb1 \
    --vip-subnet-id public_subnet --tag Finance --tag Sales --wait
    Note

    Load-balancing service objects can have one or more tags. Repeat the --tag <tag> option for each additional tag that you want to add.

    Example - creating and tagging a listener

    In this example a listener, listener1, is created with a tag, Sales:

    $ openstack loadbalancer listener create --name listener1 --protocol HTTP --protocol-port 80 --tag Sales lb1 --wait
    Example - creating and tagging a pool

    In this example a pool, pool1, is created with a tag, Sales:

    $ openstack loadbalancer pool create --name pool1 \
    --lb-algorithm ROUND_ROBIN --listener listener1 \
    --protocol HTTP --tag Sales --wait
    Example - creating a member in a pool and tagging it

    In this example a member, 192.0.2.10, is created in pool1 with a tag, Sales:

    $ openstack loadbalancer member create --name member1 \
    --subnet-id private_subnet --address 192.0.2.10 --protocol-port 80 \
    --tag Sales pool1 --wait
    Example - creating and tagging a health monitor

    In this example a health monitor, healthmon1, is created with a tag, Sales:

    $ openstack loadbalancer healthmonitor create --name healthmon1 \
    --delay 15 --max-retries 4 --timeout 10 --type HTTP --url-path / \
    --tag Sales pool1 --wait
    Example - creating and tagging an L7 policy

    In this example an L7 policy, policy1, is created with a tag, Sales:

    $ openstack loadbalancer l7policy create --action REDIRECT_PREFIX \
    --redirect-prefix https://www.example.com/ \
    --name policy1 http_listener --tag Sales --wait
    Example - creating and tagging an L7 rule

    In this example an L7 rule, rule1, is created with a tag, Sales:

    $ openstack loadbalancer l7rule create --compare-type STARTS_WITH \
    --type PATH --value / --tag Sales policy1 --wait

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          | 2024-08-06T19: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          | 2024-08-07T13: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                                |
    +---------------------+--------------------------------------+

You can add and remove tags on Load-balancing service (octavia) objects. When the tags are in place, you can filter load balancers, listeners, pools, members, health monitors, rules, and policies by using their loadbalancer list commands.

You can create a new security group to apply to instances and ports within a project in a RHOSO environment.

Prerequisites

  • The administrator has created a project for you and has provided you with a clouds.yaml file for you to access the cloud.
  • The python-openstackclient package is on your workstation.

    $ dnf list installed python-openstackclient

Procedure

  1. Confirm that the system OS_CLOUD variable is set for your cloud:

    $ echo $OS_CLOUD
    my_cloud

    Reset the variable if necessary:

    $ export OS_CLOUD=my_other_cloud

    As an alternative, you can specify the cloud name by adding the --os-cloud <cloud_name> option each time you run an openstack command.

  2. Do one of the following:

    • Add a tag to a pre-existing load-balancing object by using the --tag <tag> option with the appropriate set 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>

        Note

        A tag can be any valid Unicode string with a maximum length of 255 characters.

        Example

        In this example the tags, Finance and Sales, are added to the load balancer, lb1:

        $ openstack loadbalancer set --tag Finance --tag Sales lb1
        Note

        Load-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 appropriate unset 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 appropriate set 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          | 2024-08-06T19: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          | 2024-08-07T13: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                                |
    +---------------------+--------------------------------------+

The Load-balancing service (octavia) lets you use tags to filter object lists. Use tags to filter load balancers, listeners, pools, members, health monitors, rules, and policies. Use the filtered lists for usage tracking, resource allocation, and maintenance.

Prerequisites

  • The administrator has created a project for you and has provided you with a clouds.yaml file for you to access the cloud.
  • The python-openstackclient package is on your workstation.

    $ dnf list installed python-openstackclient

Procedure

  1. Confirm that the system OS_CLOUD variable is set for your cloud:

    $ echo $OS_CLOUD
    my_cloud

    Reset the variable if necessary:

    $ export OS_CLOUD=my_other_cloud

    As an alternative, you can specify the cloud name by adding the --os-cloud <cloud_name> option each time you run an openstack command.

  2. Filter the objects that you want to list by running the appropriate loadbalancer list command for the objects with one of the tag options:

    Expand
    Table 11.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

    Note

    When specifying more than one tag, separate the tags by using a comma.

Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat Documentation

Legal Notice

Theme

© 2026 Red Hat
Back to top