Charts: [Grafana/Helm] how set path /grafana/ when use helm ?

Created on 22 Jun 2018  Â·  19Comments  Â·  Source: helm/charts

I've define a Ingress rule on path /grafana I understand that I need also to configure root_url I'm looking for the correct way to pass the root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana/ with a command line like :

helm install --namespace grafana -n grafana stable/grafana --set rbac.pspEnabled=false --set grafana.ini="{root_path = https://ingress-ops.nd-int-ops-paas.itn/grafana/ }"

I don't know what's wrong

Most helpful comment

You'll need a rewrite rule for a grafana subpath to work, I'm using the nginx ingress controller and had to do this

ingress:
  enabled: true
  annotations:
     nginx.ingress.kubernetes.io/rewrite-target: /$1
  labels:
  path: /grafana/?(.*)
  hosts:
    - foo.bar

If your version of the nginx ingress controller is < 0.22, then you do

ingress:
  enabled: true
  annotations:
     nginx.ingress.kubernetes.io/rewrite-target: /
  labels:
  path: /grafana
  hosts:
    - foo.bar

See https://kubernetes.github.io/ingress-nginx/examples/rewrite/#rewrite-target

All 19 comments

This excerpt from my values.yaml does the job for me:

grafana.ini:
  server:
    root_url: https://subdomain.example.com/grafana

Do you know how to convert it as --set option form helm ?

server.root_uri?

On Fri, 22 Jun 2018, 18:50 obeyler notifications@github.com wrote:

Do you know how to convert it as --set option form helm ?

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/kubernetes/charts/issues/6264#issuecomment-399370814,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADjWVPFwANoCywkQxEsVi9MBBj_SR2Aks5t_K_DgaJpZM4UzUeY
.

I try this without success
--set grafana.ini=server[0].root_url=https://ingress-ops.nd-int-ops-paas.itn/grafana

I try this without success
--set grafana.ini[0].server[0].root_url=https://ingress-ops.nd-int-ops-paas.itn/grafana

--set 'grafana\.ini'.server.root_url=https://ingress-ops.nd-int-ops-paas.itn/grafana

Works (Thanks to Alexandre V)

You should use this syntax:

--set 'grafana\.ini'.server.root_url=https://ingress-ops.nd-int-ops-paas.itn/grafana

Single quotes preserve literal values and the backspace avoids the dot to be treated as a separator.

@obeyler did you need to configure anything extra to make the static assets work?

Using equivalent configuration I cannot get static assets to load:

screen shot 2018-08-08 at 18 59 12

--set 'grafana.ini'.server.root_url=https://ingress-ops.nd-int-ops-paas.itn/grafana

That doesn't even make a change the yaml output. It does absolutely nothing with helm v2.10.0

@haizaar

I run helm template istio-1.0.2/install/kubernetes/helm/istio --name istio --namespace istio-system --set grafana.enabled=true --set grafana.security.enabled=true --set grafana.security.adminUser=admin --set grafana.security.adminPassword=mypass > istio.yaml

to generate my istio.yaml. None of the --set 'grafana.ini'.server.root_url= parameters actually change the yaml output. Do you know where in the istio.yaml code I can insert the grafana.ini code you listed? I tried adding it to the deployment for grafana under env: but I get:
error: error validating "istio.yaml": error validating data: ValidationError(Deployment.spec.template.spec.containers[0]): unknown field "grafana.ini" in io.k8s.api.core.v1.Container; if you choose to ignore these errors, turn validation off with --validate=false

don't forget the '\' as the . in 'grafana.ini' cause lot of trouble in parsing
--set 'grafana\.ini'.server.root_url=https://ingress-ops.nd-int-ops-paas.itn/grafana

The only thing working for me is:

--set grafana\.ini.server.root_url=https://ingress-ops.nd-int-ops-paas.itn/grafana

When I put " or ' around grafana.ini it doesn't work.
That also fits the relevant parsing code if I understand it correctly.

Helm version:

Client: &version.Version{SemVer:"v2.10.0-rc.3", GitCommit:"9ad53aac42165a5fadc6c87be0dea6b115f93090", GitTreeState:"clean"} Server: &version.Version{SemVer:"v2.10.0-rc.3", GitCommit:"9ad53aac42165a5fadc6c87be0dea6b115f93090", GitTreeState:"clean"}

For some reason the solution proposed by @haizaar has not worked for me. The following are chunks from my values.yaml:
Ingress chunk:

ingress:
  enabled: true
  annotations:
     kubernetes.io/ingress.class: nginx
     kubernetes.io/tls-acme: "true"
     certmanager.k8s.io/cluster-issuer: letsencrypt-prod
     ingress.kubernetes.io/secure-backends: "true"
  labels:
  path: /grafana
  hosts:
    - foo.bar
  tls:
    - secretName: foo.bar
      hosts:
        - foo.bar

grafana.ini:

grafana.ini:
  server:
    root_url: https://foo.bar/grafana
  paths:
    data: /var/lib/grafana/data
    logs: /var/log/grafana
    plugins: /var/lib/grafana/plugins
    provisioning: /etc/grafana/provisioning
  analytics:
    check_for_updates: true
  log:
    mode: console
  grafana_net:
    url: https://grafana.net

I get to grafana login just fine when the ingress path is / instead of /grafana.

I have also tried the following with no luck:

grafana.ini:
  server:
    domain: foo.bar
    root_url: https://foo.bar/grafana
  paths:
    data: /var/lib/grafana/data
    logs: /var/log/grafana
    plugins: /var/lib/grafana/plugins
    provisioning: /etc/grafana/provisioning
  analytics:
    check_for_updates: true
  log:
    mode: console
  grafana_net:
    url: https://grafana.net

You'll need a rewrite rule for a grafana subpath to work, I'm using the nginx ingress controller and had to do this

ingress:
  enabled: true
  annotations:
     nginx.ingress.kubernetes.io/rewrite-target: /$1
  labels:
  path: /grafana/?(.*)
  hosts:
    - foo.bar

If your version of the nginx ingress controller is < 0.22, then you do

ingress:
  enabled: true
  annotations:
     nginx.ingress.kubernetes.io/rewrite-target: /
  labels:
  path: /grafana
  hosts:
    - foo.bar

See https://kubernetes.github.io/ingress-nginx/examples/rewrite/#rewrite-target

Future versions of Grafana will "just work" without this requirement for a rewrite rule. https://github.com/grafana/grafana/pull/17048

You'll need a rewrite rule for a grafana subpath to work, I'm using the nginx ingress controller and had to do this

ingress:
  enabled: true
  annotations:
     nginx.ingress.kubernetes.io/rewrite-target: /$1
  labels:
  path: /grafana/?(.*)
  hosts:
    - foo.bar

If your version of the nginx ingress controller is < 0.22, then you do

ingress:
  enabled: true
  annotations:
     nginx.ingress.kubernetes.io/rewrite-target: /
  labels:
  path: /grafana
  hosts:
    - foo.bar

See https://kubernetes.github.io/ingress-nginx/examples/rewrite/#rewrite-target

not work for me !

With chart grafana-3.10.1, you need to do this:

grafana.ini:
  server:
    domain: foo.bar
    root_url: https://foo.bar/grafana
    serve_from_sub_path: true
  paths:
    data: /var/lib/grafana/data
    logs: /var/log/grafana
    plugins: /var/lib/grafana/plugins
    provisioning: /etc/grafana/provisioning
  analytics:
    check_for_updates: true
  log:
    mode: console
  grafana_net:
    url: https://grafana.net

Works for me.

With chart grafana-3.10.1, you need to do this:

grafana.ini:
  server:
    domain: foo.bar
    root_url: https://foo.bar/grafana
    serve_from_sub_path: true
  paths:
    data: /var/lib/grafana/data
    logs: /var/log/grafana
    plugins: /var/lib/grafana/plugins
    provisioning: /etc/grafana/provisioning
  analytics:
    check_for_updates: true
  log:
    mode: console
  grafana_net:
    url: https://grafana.net

Works for me.

Where do I need to write grafana.ini, Is it in values.yaml ,env block.
Does changes need to made in grafana deployment too?

Make changes in the values.yaml

Was this page helpful?
0 / 5 - 0 ratings