Nomad Load Balancing with Traefik and Consul Connect on the same time

Hello there,

I’m quite new to the Nomad and Consul.

I’m trying to merge those both tutorials:

I have that nomad file:

job "countdash" {
    datacenters = [
        "fra1"]

    group "api" {
        network {
            mode = "bridge"
        }

        service {
            name = "count-api"
            port = "9001"

            connect {
                sidecar_service {}
            }
        }

        task "web" {
            driver = "docker"

            config {
                image = "hashicorpnomad/counter-api:v1"
            }
        }
    }

    group "dashboard" {
        network {
            mode = "bridge"

            port "http" {
                static = 9002
                to = 9002
            }
        }

        service {
            name = "count-dashboard"
            port = "9002"

            tags = [
                "traefik.enable=true",
                "traefik.http.routers.http.rule=PathPrefix(`/count`)",
            ]

            connect {
                sidecar_service {
                    proxy {
                        upstreams {
                            destination_name = "count-api"
                            local_bind_port = 8080
                        }
                    }
                }
            }
        }

        task "dashboard" {
            driver = "docker"

            env {
                COUNTING_SERVICE_URL = "http://${NOMAD_UPSTREAM_ADDR_count_api}"
            }

            config {
                image = "hashicorpnomad/counter-dashboard:v1"
            }
        }
    }
}

The job is successfully sent and handled by Nomad which is running api and dashboard.
The both count-api and count-dashboard services are connected to Consul.
The count-dashboard can access to count-api (using the private ip adress).
The count-dashboard service is registered to Treafik.

Here’re the issues:

  • I saw two HTTP Services count-dashboard@consulcatalog and count-dashboard-sidecar-proxy@consulcatalog (can the issue be caused by the sidecar-proxy ?).
  • The rule is missing in the http router.

Is anyone have an idea how to make all of this working ?

EDIT 1: If I remove the tag traefik.http.routers.http.rule=PathPrefix:/count, I saw the two services served using their name as Host rule (e.g. for count-dashboard@consulcatalog the rule is Host:count-dashboard)…

EDIT 2 : If I disable the sidecar-proxy and set the rule traefik.http.routers.http.rule=PathPrefix('/count') the reverse-proxy is correctly set but the dashboard is no longer connected to the api…

Thanks,

Seems not possible for today :