Using Traefik as a reverse proxy for prometheus

896 views
Skip to first unread message

thibaut....@gmail.com

unread,
May 17, 2018, 4:26:48 AM5/17/18
to Prometheus Users
Hi guys,

With my own kubernetes cluster 1.8.8 working on an openstack cloud, I am trying to use traefik (1.6.1) as a reverse proxy (ingress controller) for my applications. It works just fine for an app I call helloworld but not for prometheus (in last version).
Is there something I miss for making prometheus work with traefik ?

The result with prometheus UI is a 404 error page and /prometheus is automatically redirected to /graph. I must add that, of course, prometheus is working ok from my internal cluster and I can access home page when created a NodePort (but my goal is to use a reverse proxy for accessing it).

Configuration of prometheus ingress:
apiVersion: v1
kind: Service
metadata:
  name: prometheus-svc
  labels:
    app: prometheus
  annotations:
    prometheus.io/scrape: 'true'
spec:
  ports:
  - name: prom
    port: 9090
    targetPort: 9090
  externalIPs:
    - <mypublicip>
  selector:
    app: prometheus
    env: dev
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: prometheus-ingress
  annotations:
    kubernetes.io/ingress.class: traefik
    traefik.frontend.rule.type: PathPrefixStrip
    traefik.frontend.passHostHeader: "true"
    traefik.backend.loadbalancer.sticky: "true"
spec:
  rules:
  - http:
      paths:
      - path: /prometheus
        backend:
          serviceName: prometheus-svc
          servicePort: prom


Configuration of helloworld ingress:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  namespace: helloworld
  name: helloworld
  annotations:
    kubernetes.io/ingress.class: "traefik"
    traefik.frontend.rule.type: PathPrefixStrip
    traefik.frontend.passHostHeader: "true"
    traefik.backend.loadbalancer.sticky: "true"
spec:
  rules:
  - http:
      paths:
      - path: /hello
        backend:
          serviceName: helloworld
          servicePort: 80

Julius Volz

unread,
May 17, 2018, 5:24:59 PM5/17/18
to thibaut....@gmail.com, Prometheus Users
Have you tried playing with different values for the Prometheus flags --web.external-url and --web.route-prefix? And with activating/deactivating the Traefik ingress rule "PathPrefixStrip" that you have in your YAML. It's always a bit fiddly, but hopefully some combination of those would work :)

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/7ab2735f-1ff5-459e-bdb1-479bd958a222%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages