Node Metadata


Each node in your cluster has a metadata object that can be used to add special tags to the node for load balancing purposes. This is typically used with the applications nodeMetadataFilter object to match and filter out nodes when choosing where to start your session

Setting metadata on a node

You can set metadata using environment variables or using fastx.env. Note that these variables are always interpretted as strings

Any environment variable that starts with METADATA_ will be set on the node

When running the fastx4 service, you can set them in /etc/systemd/system/fastx4.service.d/override.conf

[Service]
Environment="METADATA_ENVIRONMENT=development"
Environment="METADATA_option2=myvalue"

In /etc/fastx/fastx.env

METADATA_ENVIRONMENT=development
METADATA_option2=myvalue

Default metadata variables

FastX sets some default metadata node variables

  • version — current FastX version running on the node
  • osId — os id taken from the ID field in /etc/os-release

filter_nodes function

FastX ships with a filter_nodes python function that does the heavy lifting of filtering out nodes for you based on a filter object. You can add this to your custom load balancing object for quick filtering

def filter_nodes(nodes, filter_obj):
    """
    Filter a list of node objects based on a filter object with enhanced matching:
    - "*" matches any truthy value
    - Array values match if any array item matches the node value
    - "!" prefix negates the match
    - If ANY filter object matches, the node is included (OR logic)
    
    Args:
        nodes (list): List of node objects
        filter_obj (dict): Filter criteria to apply
        
    Returns:
        list: Filtered list of node objects
    """

filter_obj special notes

  • * will match any truthy value
  • ! will negate the value (if the metadata does not contain the value)
  • [] an array will match any value in the array