Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error converting YAML to JSON: yaml: line 15: did not find expected alphabetic or numeric character

I want to set wildcard subdomain for my project, using k8s, nginx ingress controller, helm chart:

In ingress.yaml file:

...
rules:
  - host: {{ .Values.ingress.host }}
...

In values.yaml file, I change host example.local to *.example.local:

...
ingress:
  enabled: true
  host: "*.example.local"
...

Then, when I install chart using helm chart:

Error: YAML parse error on example/templates/ingress.yaml: error converting YAML to JSON: yaml: line 15: did not find expected alphabetic or numeric character

How can I fix it?

Thank for your support.

like image 402
Phan Ly Huynh Avatar asked Feb 03 '26 23:02

Phan Ly Huynh


2 Answers

YAML treats strings starting with asterisk in a special way - that's why the hostname with wildcards like *.example.local breaks the ingress on helm install. In order to be recognized as strings, the values in ingress.yaml file should be quoted with " " characters:

...
rules:
  - host: "{{ .Values.ingress.host }}"
...

One more option here - adding | quote :

...
rules:
  - host: {{ .Values.ingress.host | quote }}
...

I've reproduced your issue, both these options worked correctly. More information on quoting special characters for YAML is here.

like image 129
anarxz Avatar answered Feb 05 '26 13:02

anarxz


In your ingress.yaml put quotes around the host key.

host: "{{ .Values.ingress.host }}"
like image 32
Robin Webb Avatar answered Feb 05 '26 12:02

Robin Webb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!