Traefik won't route to a service I have and /api/health always shows 404

I have tried with a kubernetes ingress as follows:

# ingress.yaml
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: prefect-traefik
  namespace: prefect
  annotations:
    traefik.ingress.kubernetes.io/router.entrypoints: websecure
spec:
  ingressClassName: traefik-external
  rules:
  - http:
      paths:
      - path: /api
        pathType: Prefix
        backend:
          service:
            name: prefect-server
            port:
              number: 4200

I have tried with an

ingressroute:apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: prefect-api-ingress
  namespace: prefect
  annotations:
      kubernetes.io/ingress.class: "traefik-external"
spec:
  entryPoints:
    - websecure
  routes:
    - match: Host(`traefik.*******.com`) && PathPrefix(`/api`)
      kind: Rule
      services:
        - name: prefect-server
          port: 4200
          namespace: prefect

and I keep getting 404, what is going on?!

{"ClientAddr":"HIDDEN","ClientHost":"HIDDEN","ClientPort":"21209","ClientUsername":"-","DownstreamContentSize":19,"DownstreamStatus":404,"Duration":96761,"GzipRatio":0,"OriginContentSize":0,"OriginDuration":0,"OriginStatus":0,"Overhead":96761,"RequestAddr":"HIDDEN","RequestContentSize":0,"RequestCount":7,"RequestHost":"HIDDEN","RequestMethod":"GET","RequestPath":"/","RequestPort":"-","RequestProtocol":"HTTP/1.1","RequestScheme":"http","RetryAttempts":0,"StartLocal":"2024-06-28T04:23:06.284894755Z","StartUTC":"2024-06-28T04:23:06.284894755Z","entryPointName":"web","level":"info","msg":"","time":"2024-06-28T04:23:06Z"}

1 Like

I'm right there struggling with you. In two separate k8s tests, tried both Ingress and IngressRoute. Each one gives me a 404. It's like I'm getting a response from traefik, but traefik isn't passing the request onto the service or pod it belongs to Haven't figured it out yet.

One thing I noticed in your annotations was your use of websecure entrypoint.

    traefik.ingress.kubernetes.io/router.entrypoints: websecure

That's usually for https on port 443. Have you tried using web entrypoint first and seeing if you can get through to the dashboard that way?

In other words, maybe try http before trying https?

I noticed in the json log you posted, the entrypoint is showing web, not websecure.

"entryPointName":"web"

It's like your request is not making it to the configured endpoint. Maybe that is the problem?

I eventually got it to work, but now it’s not recognizing forwardAuth middleware when I include it in the ingress annotation as -@kubernetescrd. It keeps telling me that the middleware does not exist!! Any ideas why? It will recognize like the ipWhitelist middleware however!