Istio - 带有子路径的 Grafana "if you're seeing this grafana has failed to load its application files"

Istio - Grafana with SubPath "if you're seeing this grafana has failed to load its application files"

我在 AKS 中使用启用了 Grafana 的 Istio,并希望使用像 example.com/metrics/grafana 这样的子路径。提供的 istio documentation 仅说明如何在没有子路径但有子域的情况下使用它。但这不是这里的选项。

根据这个grafana tutorial我得设置

domain = example.com
root_url = %(protocol)s://%(domain)s:%(http_port)s/metrics/grafana/
serve_from_sub_path = true

所以我把它们设置在 IstioOperator:

apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
spec:
  profile: default
  values:
    [...]
    grafana:
      # Enable Grafana deployment for analytics and monitoring dashboards
      enabled: true
      env:
        GF_SERVER_ROOT_URL: "%(protocol)s://%(domain)s/metrics/grafana/"
        GF_SERVER_DOMAIN: "example.com"
        GF_SERVER_SERVE_FROM_SUB_PATH: "true"

另外我设置了一个VirtualService

    - name: grafana-route
      match:
        - uri:
            prefix: /metrics/grafana/
      route:
        - destination:
            host: grafana.istio-system.svc.cluster.local
            port:
              number: 3000

但是当我访问示例时。com/metrics/grafana 我不断收到消息:

If you’re seeing this Grafana has failed to load its application files

This could be caused by your reverse proxy settings.

If you host grafana under subpath make sure your grafana.ini root_path setting includes subpath

If you have a local dev build make sure you build frontend using: npm run dev, npm run watch, or npm > > run build

Sometimes restarting grafana-server can help

有人知道问题出在哪里吗?

serve_from_sub_path 必须设置为 false.

    grafana:
      # Enable Grafana deployment for analytics and monitoring dashboards
      enabled: true
      env:
        GF_SERVER_ROOT_URL: "%(protocol)s://%(domain)s/metrics/grafana/"
        GF_SERVER_DOMAIN: "example.com"
        GF_SERVER_SERVE_FROM_SUB_PATH: "false"

此外必须重写 uri:

    - name: grafana-route
      match:
        - uri:
            exact: /management/grafana
        - uri:
            prefix: /management/grafana/
      rewrite:
        uri: /
      route:
        - destination:
            host: grafana.istio-system.svc.cluster.local
            port:
              number: 3000