【问题标题】:Prometheus Operator Expose Ingress RoutePrometheus Operator 暴露 Ingress Route
【发布时间】:2020-01-31 19:04:49
【问题描述】:

我想通过 HTTPS 通过 Internet 访问 Prometheus Operator。

我通过 HELM 部署了 Prometheus 并提供了以下 custom-vault.yml

图表版本:

 kube-prometheus-0.0.105
 nginx-ingress-0.31.0

部署:

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

我的期望: 我想通过 URL 浏览 Prometheus https://example.com/prometheus

我的 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

会发生什么?

我可以联系到https://example.com/graph,但由于路径错误,CSS 文件无法加载。

当我尝试配置 https://example.com/prometheus/graph 时,CSS 也不起作用,当我点击前端警报时,我被重定向到 https://example.com/alerts 并出现“默认后端 404”错误。

serval 服务/Pod 的其他入口路由正在运行 Prometheus 也在工作 - 当我将端口暴露给 localhost 时,Prometheus 会正确显示。

【问题讨论】:

    标签: kubernetes prometheus kubernetes-ingress azure-aks nginx-ingress


    【解决方案1】:

    您的网址是:“https://example.com/prometheus”,您的路径是“/”

    这解释了为什么您可能有一些工作链接而不是其他链接(CSS、索引...)。

    如果我没记错的话,你应该像这样创建你的路径:

    paths:
      - /prometheus/*
    

    这就是说,结合您的重写目标使用 /prometheus 作为它的根 url 并接受所有子 url。重写将在 pod 内重定向到 /。

    【讨论】:

      【解决方案2】:

      更改部分

      paths:
        - /
      

        paths:
        - prometheus:
          path: /prometheus
      

      但您应该记住,通过 Ingress 对象公开 Prometheus Web UI 需要运行 Ingress controller

      您可以在此处找到更多信息:operator-prometheus-coreos

      【讨论】:

        【解决方案3】:

        感谢您的意见。你帮我解决了问题。不是直接的,但它给了我一个新的观点。

        我是如何解决这个问题的: 我将部署从 coreos/kube-prometheus 更改为 stable/prometheus-operator

        当前版本是 6.11 我无法直接安装 6.11 - 我需要安装 6.0.0 并升级到 6.11

        还提供了一个新的custom-value.yaml

        有了这个设置就完美了!

        自定义值.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/
        
        

        谢谢。

        BR

        【讨论】:

          猜你喜欢
          • 2018-08-11
          • 2021-07-16
          • 2020-08-04
          • 2019-02-24
          • 1970-01-01
          • 1970-01-01
          • 2019-06-20
          • 2022-01-16
          • 2021-08-13
          相关资源
          最近更新 更多