Traefik: Consul Catalog constraints does not seem to work

Created on 9 Dec 2016  路  3Comments  路  Source: traefik/traefik

Using latest traefik; and frontend Rules are working; hooked up automatically via tagging as per below via Nomad scheduler.

...
        tags = [
                "traefik.tag=blue",
                "traefik.frontend.rule=Host:www.10.0.2.5.xip.io;Path:/whoami",
                "traefik.frontend.entryPoints=http"
        ]
...

However, when running with simple constraints; it does not seem to work (everything is pruned).

sudo ./traefik  --constraints="tag==blue" --debug

Debug log:

...
DEBU[2016-12-09T13:01:31Z] Service global-whoami pruned by 'tag==blue' constraint 
DEBU[2016-12-09T13:01:31Z] Service global-whoami pruned by 'tag==blue' constraint 
DEBU[2016-12-09T13:01:31Z] Service global-whoami pruned by 'tag==blue' constraint 
DEBU[2016-12-09T13:01:31Z] Service global-whoami pruned by 'tag==blue' constraint 
DEBU[2016-12-09T13:01:31Z] Service global-whoami pruned by 'tag==blue' constraint 
...
statu5-frozen-due-to-age

Most helpful comment

@freefood89 from docs it's not very evident that traefik will only parse consul tags that start with traefik.tags=, e.g.

{
    "services": [
        {
            "name": "web-srv", 
            "port": 8080, 
            "tags": [
                "traefik.tags=trk"
            ]
        }
    ]
}

it will be more user-friendly if traefik consumes ordinary consul tags, e.g

{
    "services": [
        {
            "name": "web-srv", 
            "port": 8080, 
            "tags": [
                "trk"
            ]
        }
    ]
}

as shown in consul docs

All 3 comments

Try changing "traefik.tag=blue" to "traefik.tags=blue"

You can add more tags: "traefik.tags=blue,external,lolcats"

@freefood89 Thanks; it works! For reference, the below setup works for me:

Only route to containers tagged 'lolcats':

sudo ./traefik  --constraints="tag==lolcats"

Jobs with multiple traefik.tags (including the 'lolcats' tag):

...
        tags = [
                "traefik.tags=blue,lolcats",
                "traefik.frontend.rule=Host:www.10.0.2.5.xip.io;Path:/whoami",
                "traefik.frontend.entryPoints=http"
        ]
..

@freefood89 from docs it's not very evident that traefik will only parse consul tags that start with traefik.tags=, e.g.

{
    "services": [
        {
            "name": "web-srv", 
            "port": 8080, 
            "tags": [
                "traefik.tags=trk"
            ]
        }
    ]
}

it will be more user-friendly if traefik consumes ordinary consul tags, e.g

{
    "services": [
        {
            "name": "web-srv", 
            "port": 8080, 
            "tags": [
                "trk"
            ]
        }
    ]
}

as shown in consul docs

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arschles picture arschles  路  3Comments

rogeriollacerda picture rogeriollacerda  路  3Comments

r3pek picture r3pek  路  3Comments

JensErat picture JensErat  路  3Comments

pjebs picture pjebs  路  3Comments