Unable to get a Grafana helm-charts URL to work with subpath

5/6/2019

I am setting up a Grafana server on my local kube cluster using helm-charts. I am trying to get it to work on a subpath in order to implement it on a production env with tls later on, but I am unable to access Grafana on http://localhost:3000/grafana.

I have tried all most all the recommendations out there on the internet about adding a subpath to ingress, but nothing seems to work.

The Grafana login screen shows up on http://localhost:3000/ when I remove root_url: http://localhost:3000/grafana from Values.yaml

But when I add root_url: http://localhost:3000/grafana back into values.yaml file I see the error attached below (towards the end of this post).

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: {}

I expect the http://localhost:3000/grafana url to show me the login screen instead i see the below errors:

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

Can you please help me fix the ingress and root_url on values.yaml to get Grafana URL working at /grafana ?

-- Lokesh Sreedhar
grafana
kubernetes
kubernetes-helm
kubernetes-ingress

1 Answer

5/13/2019

As you check documentation for Configuring grafana behind Proxy, root_url should be configured in grafana.ini file under [server] section. You can modify your values.yaml to achieve this.

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

Also your ingress in values should look like this.

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

Hope it helps.

-- coolinuxoid
Source: StackOverflow