consul icon indicating copy to clipboard operation
consul copied to clipboard

Service resolver not visible in UI

Open kochen opened this issue 8 months ago • 0 comments

Overview of the Issue

Service resolvers added to a tagged service with multiple instances (different tags) is not completely shown in the (routing) UI of the service.


Reproduction Steps

End goal is to be able to connect from a Nomad Job to a specifically tagged instance of the service (i,e the primary - see steps to reproduce)

Steps to reproduce this issue:

  1. Have a service with multiple instances, each instance tagged with a different tag. In this case, we have a patroni cluster consisting of (at least) 2 instances, one instances tagged as primary the other tagged as replica - service name is postgres-16.
  2. Add service resolvers to be able to target a specific tag of the service. Based on these example: https://discuss.hashicorp.com/t/how-to-reach-a-service-subset-from-the-service-mesh/45162/2 create 2 service resolvers:
Kind = "service-resolver"
Name = "postgres-16"
DefaultSubset = "replica-16"
Subsets = {
  "primary-16" = {
    filter = "\"primary\" in Service.Tags"
  }
  "replica-16" = {
    filter = "\"replica\" in Service.Tags"
  }
}
Kind = "service-resolver"
Name = "replica-16"
Redirect {
  Service = "postgres-16"
  ServiceSubset = "replica-16"
}
Kind = "service-resolver"
Name = "primary-16"
Redirect {
  Service = "postgres-16"
  ServiceSubset = "primary-16"
}
  1. verify all 3 service resolvers are written into configuration:
$ consul config list -kind service-resolver
postgres-16
primary-16
replica-16
  1. looking at the Consul UI - service routing: image

(shows the main resolver and the default subset)

Trying to access the services from a Nomad Job, works only for the main postgres-16 service but not the tagged/filtered services:

      connect {
        sidecar_service {
          proxy {
            upstreams {
              destination_name = "postgres-16"
              local_bind_port  = 5432
            }
            upstreams {
              destination_name = "primary-16"
              local_bind_port  = 5433
            }
            upstreams {
              destination_name = "replica-16"
              local_bind_port  = 5434
            }
          }
        }
      }

kochen avatar Jun 06 '24 08:06 kochen