簡體   English   中英

如何使用 virtualservice 來暴露 grafana prometheus 和 kiali 之類的儀表板?

[英]How to use virtualservice to expose dashboards like grafana prometheus and kiali?

我的儀表板暴露在<dashboard>.foobar.com沒有問題,現在我試圖將上面提到的儀表板暴露給www.foobar.com/dashboard/<kiali>我已經用這個 VS 使用簡單的 .net 后端容器進行了測試設置:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: whatever
spec:
  hosts:
  - www.foobar.com
  gateways:
  - some-gateway
  http:
  - match:
    - uri:
        prefix: /bla
    rewrite:
      uri: " "
    route:
    - destination:
        port:
          number: 1234
        host: dummy-service

然后我有: foobar.com/bla/api/hello -> dummyservice/api/hello foobar.com/bla/api/deeper/hello -> dummyservice/api/deeper/hello這很好。 但是,如果我將相同的方法應用於這些儀表板,則沒有任何效果:這是我對儀表板的設置:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: dashboards
  namespace: istio-system
spec:
  hosts:
  - www.foobar.com
  gateways:
  - default/somegateway
  http:
  - name: grafana
    match:
    - uri:
        prefix: /dashboards/grafana
    rewrite:
      uri: /
    route:
    - destination:
        port:
          number: 80
        host: grafana.grafana.svc.cluster.local
  - name: prometheus
    match:
    - uri:
        prefix: /dashboards/prometheus
    rewrite:
      uri: "/"
    route:
    - destination:
        port:
          number: 9089
        host: prometheus-server.prometheus.svc.cluster.local
  - name: kubernetes-dashboard
    match:
    - uri:
        prefix: "/dashboards/kubernetes"
    rewrite:
      uri: " "
    route:
    - destination:
        port:
          number: 8443
        host: kubernetes-dashboard.kubernetes-dashboard.svc.cluster.local
  - name: kubernetes-dashboard
    match:
    - uri:
        prefix: "/dashboards/kiali/"
    rewrite:
      uri: /
    route:
    - destination:
        port:
          number: 20001
        host: kiali.istio-system.svc.cluster.local

正如有人提到的, / 所以你可以看到我已經rewrite了他們兩個。 但仍然沒有任何效果。 我大部分都得到了 404,grafana 將我重定向到www.foobar.com/login

以前有人做過嗎? 我在想這些儀表板可能包含在前端,所以它不像我的 .net 后端容器那么簡單?

對於任何有相同問題的人,請看這里:

我已經解決了這個問題:

所以首先,VirtualServe 是正確的,但記得在寫部分添加引號:

    rewrite:
      uri: "/"

前綴部分需要用/關閉

  - name: kubernetes-dashboard
    match:
    - uri:
        prefix: "/kubernetes/"

訣竅來了,prometheus 和 grafana 設計為在根 url 下工作。 但是,它可以在deployment.yaml中配置。yaml 例如,我希望我的 grafana 和 prometheus 分別在www.foobar.com/grafana/www.foobar.com/prometheus工作。 在 grafana deployment.yaml中,我們需要指定:

          env:
            - name: GF_SERVER_ROOT_URL
              value: 'http://localhost:3000/grafana/'
            - name: GF_SERVER_DOMAIN
              value: localhost
            - name: GF_SERVER_SERVE_FROM_SUB_PATH
              value: 'true'

在普羅米修斯中,它有類似的:

- name: prometheus-server
    image: 'quay.io/prometheus/prometheus:v2.24.0'
    args:
      - '--web.enable-lifecycle'
      - '--web.external-url=https://localhost:9090/prometheus/'
      - '--web.route-prefix=/'

對於 kiali,訣竅在於虛擬服務,您必須將其重寫為/kiali/

  - name: kiali-dashboard
    match:
    - uri:
        prefix: /kiali/
    rewrite:
      uri: "/kiali/"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM