Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template expression in "ingress.hosts" value isn't rendered when included in "grafana.ini" #2343

Open
MaximPopov opened this issue Apr 14, 2023 · 1 comment

Comments

@MaximPopov
Copy link

Grafana chart: 6.52.9

If I specify a template expression in ingress.hosts value like this:

ingress:
    enabled: true
    hosts:
      - monitoring-{{ .Values.global.environment }}.my-hostname.com

it gets copied verbatim to "grafana.ini" section of the ConfigMap:

  grafana.ini: |
    ...
    [server]
    domain = monitoring-{{ .Values.global.environment }}.my-hostname.com

"grafana.ini" section definition in configmap.yaml specifies that string values must be processed with tpl function:

  grafana.ini: |
  {{- range $elem, $elemVal := index .Values "grafana.ini" }}
    {{- if not (kindIs "map" $elemVal) }}
    {{- if kindIs "invalid" $elemVal }}
    {{ $elem }} =
    {{- else if kindIs "string" $elemVal }}
    {{ $elem }} = {{ tpl $elemVal $ }}
    {{- else }}
    {{ $elem }} = {{ $elemVal }}
    {{- end }}
    {{- end }}
  {{- end }}
  {{- range $key, $value := index .Values "grafana.ini" }}
    {{- if kindIs "map" $value }}
    [{{ $key }}]
    {{- range $elem, $elemVal := $value }}
    {{- if kindIs "invalid" $elemVal }}
    {{ $elem }} =
    {{- else if kindIs "string" $elemVal }}
    {{ $elem }} = {{ tpl $elemVal $ }}
    {{- else }}
    {{ $elem }} = {{ $elemVal }}
    {{- end }}
    {{- end }}
    {{- end }}
  {{- end }}

and double quotes around grafana.ini.server.domain value in values.yaml lead me to believe this value should be considered as a string kind:

grafana.ini:
  server:
    domain: "{{ if (and .Values.ingress.enabled .Values.ingress.hosts) }}{{ .Values.ingress.hosts | first }}{{ else }}''{{ end }}"

What could be the reason for tpl function not being applied to this value?

@lindeskar
Copy link

I just had the same issue.

My workaround for now is to redefine grafana.ini.server.domain:

ingress:
  enabled: true
  hosts:
    - "grafana.{{ .Values.global.publicDomain }}"

grafana.ini:
  server:
    domain: "grafana.{{ .Values.global.publicDomain }}"

nanori added a commit to nanori/grafana-helm-charts that referenced this issue May 11, 2024
Add tpl for host in grafana.ini
nanori added a commit to nanori/grafana-helm-charts that referenced this issue May 11, 2024
Add tpl for host in grafana.ini

Signed-off-by: Nanori <yannick.lucet@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants