helm-charts icon indicating copy to clipboard operation
helm-charts copied to clipboard

extraExposePorts no longer working after 6.32.10

Open pcornelissen opened this issue 2 years ago • 1 comments

We are installing grafana using the official helm release and we just tried to upgrade from 6.32.3 to 6.32.13, but we encountered a weird error message:

Error: YAML parse error on grafana/templates/service.yaml: error converting YAML to JSON: yaml: line 18: mapping values are not allowed in this context
helm.go:84: [debug] error converting YAML to JSON: yaml: line 18: mapping values are not allowed in this context

After a longer debugging session, we have managed to find the culprit:

  {{- if .Values.extraExposePorts }}
  {{- tpl (toYaml .Values.extraExposePorts) . | indent 4 }}
  {{- end }}

the extraExposedPorts part is rendered incorrectly

spec:
  type: LoadBalancer
  ports:
    - name: grafanahttps
      port: 443
      protocol: TCP
      targetPort: 3000    - name: grafanahttp
      port: 80
      targetPort: 8060
  selector:
    app.kubernetes.io/name: grafana
    app.kubernetes.io/instance: testgrafana

The corresponding values file is: (Our version is longer, but this triggers the problem)

extraExposePorts:
- name: grafanahttp
  port: 80
  targetPort: 8060
service:
  port: 443
  portName: grafanahttps
  targetPort: 3000
  type: "LoadBalancer"

We have traced the error to the release 6.32.11, as it works with 6.32.10.

To fix that you could change the service.yaml template like this:

...
      {{- end }}
      {{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort))) }}
      nodePort: {{.Values.service.nodePort}}
      {{- end }}
{{ if .Values.extraExposePorts }}
      {{- tpl (toYaml .Values.extraExposePorts) . | indent 4 }}
{{ end }}
  selector:
    {{- include "grafana.selectorLabels" . | nindent 4 }}
{{ end }}

(Remove the - before the if and end and also remove the indentation of the if and else)

pcornelissen avatar Aug 15 '22 15:08 pcornelissen

https://github.com/grafana/helm-charts/pull/1729. should fix this I hope

sharkannon avatar Aug 25 '22 18:08 sharkannon