Hello community.
Looking for some help to use Traefik Kubernetes Gateway API to serve Grafana in a subpath.
I have a working Gateway config which is able to route request correctly to, for example, subdomains. However, I want to use subpaths instead. This presents a challenge, namely that the path forwarding doesn't work as expected.
Using the PathPrefix matcher and URLRewrite filter, I'm able to access Grafana at random.url/grafana/login
, but accessing Grafana at random.url/grafana
redirects to random.url/login
.
rules:
- matches:
- path:
type: PathPrefix
value: /grafana
filters:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: /
I believe that a RequestRedirect filter (see here) instead might fix the problem, but doesn't work, and produces an httproute is invalid error.
rules:
- backendRefs:
- group: ""
kind: Service
name: kube-prometheus-stack-grafana
namespace: kube-prometheus-stack
port: 80
weight: 1
matches:
- path:
type: PathPrefix
value: /grafana
filters:
- type: RequestRedirect
requestRedirect:
path:
type: ReplacePrefixMatch
replacePrefixMatch: /
statusCode: 302
Any idea on how to achieve this without editing configs on Grafana itself? Based on this tutorial from Grafana, it should be possible.