Traefik routing is not working

Hi , I am trying to setup ingress resource for our applications using traefik. We have two microservices running on our kubernetes cluster.Problem i am facing is able to hit the endpoints on service1 which is having path /v1/. But unable to hit the endpoints on servce2 which is having /v1/xyz/.
Could you please let me know what is the issue and changes required to make it work.

Can you post your configs so we can go over them?

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: traefik
    traefik.frontend.entryPoints: api
    traefik.frontend.priority: "1"
    ingress.kubernetes.io/browser-xss-filter: "true"
    ingress.kubernetes.io/content-type-nosniff: "true"
    traefik.ingress.kubernetes.io/rule-type: PathPrefix
  labels:
    k8s-app: traefik-api
  name: traefik-api
  namespace: default
spec:
  rules:
  - http:
      paths:
      - backend:
          serviceName: service1
          servicePort: 8080
        path: /v1/
      - backend:
          serviceName: service2
          servicePort: 8080
        path: /v1/xyz/
      - backend:
          serviceName: service2
          servicePort: 8080
        path: /v1/xYz/
      - backend:
          serviceName: service2
          servicePort: 8080
        path: /v1/xyz/abc
      - backend:
          serviceName: service2
          servicePort: 8080
        path: /v1/xyz/def
      - backend:
          serviceName: service2
          servicePort: 8080
        path: /v1/def

Hi @pavan.kulkarni43, can you provide more information please?

  • How is Traefik deployed? What version is it?
  • Can you provide a capture of the error with curl --verbose --location http://<host>/v1/xyz/ please?
  • What are the logs of Traefik? Can you have them in debug mode please?
  • If you kubectl exec into Traefik container, are you able to curl to the Cluster IP of service2? (apk add --no-cache curl && curl --verbose --location http://<ip of service2>:8080/v1/xyz/)

-- Traefik is deployed using helm chart and version - v1.7.9

# curl -vk http://127.0.0.1:8080/v1/xyz/
*   Trying 0.0.0.0...
* TCP_NODELAY set
> GET http://127.0.0.1:8080/v1/xyz/ HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.61.1
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 404 Not Found
< Mime-Version: 1.0
< Date: Fri, 18 Oct 2019 06:34:59 GMT
< Content-Type: text/html;charset=utf-8
< X-Error: Resource not found.
< Content-Length: 3622
< Vary: Accept-Language
< Content-Language: en

yes

Thanks @pavan.kulkarni43. This post had been moved to Traefik-v1 section as you are using Traefik v1.7.18.

I don't see anything wrong at first sight in your configuration, let's try something.
Could you try the following and let us know if it changes?

  • Edit the Ingress rule and keep only the /v1/ rule
  • Create another Ingress object, with the same content, except that it contains only the rule /v1/xyz/
    => You should have 2 ingress rules, with only 1 rule each. What is the behavior in this case? (if you have access to Traefik's dashboard, and or traefik's debug log, could you provide screenshot or log also?)
1 Like

I have create two ingress object one with /v1/ and other with /v1/xyz/ .Here is the logs follows.

[18/Oct/2019:10:42:26 +0000] "GET /v1/xyz/ HTTP/1.1" 404 128 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36" 19 "1-www.foo-bar.com/v1/" "http://127.0.0.1:8080" 105ms
[18/Oct/2019:10:43:00 +0000] "GET / HTTP/1.1" 404 19 "-" "Go-http-client/1.1" 20 "backend not found" "/" 0ms
[18/Oct/2019:10:43:02 +0000] "GET / HTTP/1.1" 404 19 "-" "Go-http-client/1.1" 21 "backend not found" "/" 0ms
[18/Oct/2019:10:44:00 +0000] "GET / HTTP/1.1" 404 19 "-" "Go-http-client/1.1" 22 "backend not found" "/" 0ms
[18/Oct/2019:10:44:01 +0000] "GET / HTTP/1.1" 404 19 "-" "Go-http-client/1.1" 23 "backend not found" "/" 0ms
1 Like

Thanks @pavan.kulkarni43. I am sorry but the informations you are providing are partial: can you manage to share a reproduction case please? We don't know how Traefik is deployed, with which options, etc. We would like to help but we cannot currently as we don't see the same behavior as yours: there is definitively something different that causes this behavior, but we all have to find it.

1 Like

Here is the traefik.toml file content

defaultEntryPoints = ["api"]
allowMinWeightZero = true
[respondingTimeouts]
idleTimeout = "5s"
[entryPoints]
  [entryPoints.traefik]
  address = ":8877"
  [entryPoints.api]
  address = ":8080"

[accessLog]
  filePath = "/var/log/access.log"
  level = "DEBUG"

[api]
  dashboard = true
  entryPoint = "traefik"

Did you find any issue in configuration.

Hi @pavan.kulkarni43 as I said on my previous comment, I cannot analyze with partial informations. I don't know which kind of Kubernetes cluster you are running, neither I know how is Traefik deployed.

Without a case I could reproduce, I'm empty handed and unable to help you.

you're hardcoding your priority:
traefik.frontend.priority: "1"

remove that from the ingress object.
source: me, for the last 8 hours. all of the paths have the same priority so you're getting race conditions and sending to backends that aren't expecting them.

you can hit your api endpoint to confirm:
https://your-traefik-url.domain/api/http/routers

1 Like