Nomad - Consul: Multiple services sharing one health check

Hi,

Is it possible to define multiple service stanzas in nomad but be able to share one health check between them?

Below is my use case. I have created a nomad job that starts a traefik instance with three entrypoints (traefik,internal,and external). I want to register all three as separate services in consul and all have the same healthcheck. However, this is causing consul to run the same check three times and if we spin up more traefik instances, this gets multiplied. Is there a way so that I can define one health check and all three services share it? So that consul does not need to do repeated work?

    service {
      name = "Traefik"
      port = "traefik"

      tags = [
        "traefik",
      ]

      check {
        type = "http"

        port     = "traefik"
        path     = "/ping"
        interval = "10s"
        timeout  = "2s"

        failures_before_critical = 0
        success_before_passing   = 1

        check_restart {
          limit = 5
          grace = "20s"
        }
      }
    }

    service {
      name = "Traefik"
      port = "external"

      tags = [
        "external",
      ]

      check {
        type = "http"

        port     = "traefik"
        path     = "/ping"
        interval = "10s"
        timeout  = "2s"

        failures_before_critical = 0
        success_before_passing   = 1

        check_restart {
          limit = 5
          grace = "20s"
        }
      }
    }

    service {
      name = "Traefik"
      port = "internal"

      tags = [
        "internal",
      ]

      check {
        type = "http"

        port     = "traefik"
        path     = "/ping"
        interval = "10s"
        timeout  = "2s"

        failures_before_critical = 0
        success_before_passing   = 1

        check_restart {
          limit = 5
          grace = "20s"
        }
      }
    }

Hi @fatesnz. Thanks for using Nomad!

I don’t think there is a way to share checks like that, but you mind want to double check in the Consul forum.

I do wonder though if you could make this work with one of the features of the Consul Service Discovery Chain.