无法获取Grafana掌舵图URL来使用子路径

时间:2019-05-06 18:46:38

标签: kubernetes grafana kubernetes-helm kubernetes-ingress

我正在使用舵图在本地kube集群上设置Grafana服务器。我试图使其在子路径上工作,以便稍后在带有tls的生产环境中实现它,但是我无法在http://localhost:3000/grafana上访问Grafana。

我已经尝试了Internet上所有关于向入口添加子路径的所有建议,但似乎没有任何效果。

当我从Values.yaml中删除root_url:http://localhost:3000/时,http://localhost:3000/grafana上会显示Grafana登录屏幕

但是当我将root_url:http://localhost:3000/grafana重新添加到values.yaml文件中时,我看到下面的错误(在本文结尾处)。

root_url: http://localhost:3000/grafana and ingress as:
ingress:
  enabled: true
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /

  labels: {}
  path: /grafana
  hosts:
    - localhost
  tls: []
  #  - secretName: chart-example-tls
  #    hosts:
  #      - chart-example.local

resources: {}

我希望http://localhost:3000/grafana网址向我显示登录屏幕,而不是出现以下错误:

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

1. This could be caused by your reverse proxy settings.

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

3. If you have a local dev build make sure you build frontend using: yarn start, yarn start:hot, or yarn build

4. Sometimes restarting grafana-server can help

您能帮我修复values.yaml上的入口和root_url,以使Grafana URL在/ grafana上工作吗?

2 个答案:

答案 0 :(得分:0)

在检查Configuring grafana behind Proxy的文档时,应在root_url部分下的grafana.ini文件中配置[server]。您可以修改values.yaml来实现此目的。

grafana.ini:
  ...
  server:
    root_url: http://localhost:3000/grafana/

另外,您对值的输入应如下所示。

ingress:
  enabled: true
  annotations: 
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
  labels: {}
  path: /grafana/
  hosts:
    - ""

希望有帮助。

答案 1 :(得分:0)

您需要告诉 grafana 应用程序,它不是在根 url /(默认)下运行,而是在某个子路径下运行。最简单的方法是通过 GF_ 前缀的环境变量:

grafana:
  env:
    GF_SERVER_ROOT_URL: https://myhostname.example.com/grafana
    GF_SERVER_SERVE_FROM_SUB_PATH: 'true'
  ingress:
    enabled: true
    hosts:
    - myhostname.example.com
    path: /grafana($|(/.*))
    pathType: ImplementationSpecific

以上示例适用于 kubernetes 的 nginx-ingress-controller。根据您使用的入口控制器,您可能需要

    path: /grafana
    pathType: Prefix

相反。

相关问题