As described here and here the annotation
***.ingress.kubernetes.io/rewrite-target in Kubernetes Ingress seems to work fine with NGINX but not with traefik.
Not sure if this is a Traefik or Kubernetes Issue but Traefik Ingress Controller is just ignoring
- host: myhost.com
- path: /overview
path: /foo(.*) and
traefik.ingress.kubernetes.io/rewrite-target: /$1 no path rewriting is taking place and a 404 is returned.
Traefik does not support the
traefik.ingress.kubernetes.io/rewrite-target annotation. See the list of available annotations here: Kubernetes Ingress - Traefik
But your goal can be achieved using the StipPrefix middleware.
Thanks Tom, I looked into that and it seems I have to employ Middleware and Ingress Routers.
Is there no way to configure or "talk to" traefik from an Ingress Resource?
I guess I could create a Middleware but I don't see how to link it to my routing rules which are in an Ingress Resource
You have access to this annotation on Ingress:
Hope it helps
Unfortunately, as soon as I apply the annotation everything stops working and I just get 404s.
│ 10.42.0.1 - - [21/Jan/2022:13:40:39 +0000] "GET /overview/ HTTP/2.0" 404 19 "-" "-" 23891 "-" "-" 0ms
Also I had to remove the
@kubernetescrd part as traefik did not like it:
time="2022-01-21T13:40:00Z" level=error msg="middleware \"mw-admin@kubernetescrd\" does not exist" entryPointName=web routerName=
# Strip prefix /overview
- host: admin.mydomain.com
- path: /overview
I tried with
forceSlash: true and without this line.
OK, thanks to this post I was able to solve it.
The namespace must pre prefixed to the annotation and the @ suffix appended!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.