- It appears that
top999.nearest.of.<app>.internalwill return an ordered list. - There is an API to set metadata for a machine: Dynamic machine metadata; and
<value>.<key>.kv._metadata.<appname>.internalcan be used to query it.
Assuming #1 holds AND the total number of machines is not humongous, with two DNS queries and a set intersection you can get a list of machines in an arbitrary subgroup ordered by distance.