Upstream with service tags

Is there a way to tell upstream to connect to specific service with a tag? Something like the below?
“upstreams”: [{
“destination_name”:"<tag>.service_name"

We are using common Consul cluster for some environments and currently DNS can be queried using "dig @127.0.0.1 -p 8600 “<tag>.service_name.service.consul” which returns services with that tag. Want to use service mesh but connecting to services with specific tags. Is that possible with upstream configuration?

Thanks for the help!

Hi @pvyaka01,

You can achieve this by pointing the upstream to a prepared query destination which filters services based on this tag.

Here’s an example static prepared query.

{
  "Name": "tag_routing_query",
  "Service": {
    "Service": "static-webserver",
    "Connect": true,
    "Tags": ["v1"]
  }
}

See the Prepared Query HTTP Endpoint docs for details about these options and how to create, update, and delete queries.

Alternatively, you can also use a service-resolver.

Here’s an example.

Kind          = "service-resolver"
Name          = "web"
DefaultSubset = "v1"
Subsets = {
  "v1" = {
    filter = "\"v1\" in Service.Tags"
  }
}

Hope this helps. Let me know if you have any questions.