Skip to content

Service Labels support

Choose a tag to compare

@aatarasoff aatarasoff released this 03 May 16:27
· 22 commits to master since this release

Sometimes it is useful discover services that are advertising a specific capability; by API version for example:
Three versions of a service have been deployed, with the following Marathon service ids and labels:

/group1/path/app  "labels":{ "API_VERSION" : "V1" }
/group2/path/app  "labels":{ "API_VERSION" : "V2" }
/group3/path/app  "labels":{ "API_VERSION" : "V2" }

A client is configured to expect the "V2" API Version:

app:
    ribbon:
        <your settings are here>
        MetaDataFilter:
            API_VERSION: V2

Only service instances that contain "app" in the service id and have matching labels will be discovered & used by ribbon.

Where multiple values are specified for MetaDataFilter, all values must match service labels before ribbon will use the service instance:

app:
    ribbon:
        <your settings are here>
        MetaDataFilter:
            API_VERSION: V2
            ENVIRONMENT: UAT
            APPLICATION_OWNER: fred.bloggs@company.com

Combining the loose service id matching with service label filtering permits us to get creative with service discovery:

group.path:
    ribbon:
        <your settings are here>
        MetaDataFilter:
            CUSTOMER_ENTITY: V1

i.e. select any service deployed to /group/path that supports Version 1 of the Customer Entity

Thanks to @tegataiprime