traefik v2.0 labels with rancher 2.2.8 not allowed

9/19/2019

I'm running the latest version of traefik (v2.0) managed via rancher v2.2.8.

Traefik is running fine. It is accepting connections and I can reach the dashboard via port 8080.

So I created a new workload with the containous/whoami image to expose via traefik.

However, if I try to set the label key traefik.http.routers.whoami.rule with the value Host(`whoami.example.com`) via rancher, rancher declines the value because of the following reason:

Validation failed in API: Deployment.apps "whoami" is invalid: spec.template.labels: Invalid value: "Host(`whoami.example.com`)": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue', or 'my_value', or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')

I do understand the error message, but how do I get the routing to work without using characters like ( and `?

traefik requires the label to be set with characters like ( and `, but rancher does not allow such characters.

I used https://docs.traefik.io/v2.0/getting-started/quick-start/#traefik-detects-new-services-and-creates-the-route-for-you as a guideline to set the label.

Edit: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set also states, that those characters are not permitted for label key and value.

Not as important a question, but how does traefik v2.0 even work with kubernetes then? Does it not use labels?

-- André Mohrmann
kubernetes
rancher
traefik
traefik-ingress

1 Answer

5/4/2020

Turns out I looked at the wrong documentation. traefik v2.x with kubernetes does not use labels to assign traffic to a specific workload. Your keyword here would be "IngressRoute" to control traffic. This should help get things started: docs.traefik.io/v2.2/providers/kubernetes-crd

-- André Mohrmann
Source: StackOverflow