Prometheus Operator Expose Ingress Route

10/2/2019

I want to reach Prometheus Operator over Internet via HTTPS.

I deployed Prometheus via HELM and provided the following custom-vault.yml

Chart Version:

 kube-prometheus-0.0.105
 nginx-ingress-0.31.0

Deployment:

helm install coreos/kube-prometheus --name kube-prometheus --set global.rbacEnable=false \
--namespace monitoring -f custom-vault.yml

What i expect: I want to browse Prometheus via URL https://example.com/prometheus

my custom-vault.yml

prometheus:
  ingress:
    enabled: true
    annotations:
      kubernetes.io/ingress.class: nginx
      nginx.ingress.kubernetes.io/rewrite-target: /
    tls: 
      - secretName: tls-secret
        hosts: 
          - example.com
    hosts:
      - example.com
    paths:
      - /
  #prometheusSpec:
    #externalUrl: https://example.com/prometheus

What happen?

I can reach https://example.com/graph but CSS Files doesn´t get loaded due to path error.

When i try to configure https://example.com/prometheus/graph also CSS doesn´t work and when i click on the Frontend on Alerts then i get redireted to https://example.com/alerts and getting and "default backend 404" error.

Other Ingress Routes for serval Services / Pods are working Prometheus is also working - when i expose the Port to localhost, Prometheus get displayed correctly.

-- Stefan Schulze
azure-aks
kubernetes
kubernetes-ingress
nginx-ingress
prometheus

3 Answers

10/3/2019

Change section

paths:
  - /

to

  paths:
  - prometheus:
    path: /prometheus

But you should remember that exposing the Prometheus web UI through an Ingress object requires a running Ingress controller.

More information you can find here: operator-prometheus-coreos.

-- MaggieO
Source: StackOverflow

10/23/2019

thanks for your Input. You helped me to solve the problem. Not on the direct way, but it gave me a new point of view.

How i solved the issue: I changed the deployment from coreos/kube-prometheus to stable/prometheus-operator

The current version is 6.11 I was not able to install directly 6.11 - i need to install 6.0.0 and upgraded to 6.11

Also provided a new custom-value.yaml

With this setting it works perfectly!

custom-value.yaml

prometheus:
  ingress:
    enabled: true
    annotations:
      kubernetes.io/ingress.class: nginx
      nginx.ingress.kubernetes.io/whitelist-source-range: "{my_whitelisted_public_ip}"
      nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
    tls: 
      - secretName: tls-secret
        hosts: 
          - example.com
    hosts:
      - example.com
    paths:
      - /
  prometheusSpec:
    externalUrl: http://example.com/prometheus
    routePrefix : prometheus/

Thank you.

BR

-- Stefan Schulze
Source: StackOverflow

10/2/2019

Your url is : "https://example.com/prometheus" and your path is "/"

This explains why you may have some working link and not other (CSS, index...).

If I'm not wrong you should create your path like this:

paths:
  - /prometheus/*

This says, combined with your rewrite target to use /prometheus as it's root url and to accept all sub-url. The rewrite will redirect, inside the pod, to /.

-- night-gold
Source: StackOverflow