I have a k3s cluster with a Prometheus and Alertmanager deployment inside, and set up an Ingress resource for each of them. My initial setup was prometheus.domain.com and alermanager.domain.com respectively, and these worked as expected.
However, I would like to switch it to domain.com/prometheus and domain.com/alertmanager respectively, and the options I have researched aren't working.
GOAL
Have my Prometheus service work having domain.com/prometheus being the 'root' of my Prometheus pathing, hence redirecting automatically to domain.com/prometheus/graph, as per its default behavior, and all subpaths under Prometheus (alerts, config, admin API) follow the same behavior.
Attempt #1
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
app: Prometheus
annotations:
traefik.ingress.kubernetes.io/rewrite-target: /$2
spec:
rules:
- http:
paths:
- path: /prometheus($|/)(.*)
backend:
serviceName: prometheus
servicePort: 9090
SSH into the Vagrant box hosting my k3s cluster:
$ kubectl get ingress
NAME CLASS HOSTS ADDRESS PORTS
prometheus <none> * 192.168.0.200 80
$ curl 192.168.0.200/prometheus
404 page not found
$ curl 192.168.0.200/prometheus/graph
404 page not found
Attempt #2
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
app: Prometheus
annotations:
traefik.ingress.kubernetes.io/rule-type: PathPrefixStrip
spec:
rules:
- http:
paths:
- path: /prometheus
backend:
serviceName: prometheus
servicePort: 9090
Same result as above.