Pha*_*ynh 10 wildcard kubernetes nginx-ingress helm3
我想使用 k8s、nginx 入口控制器、helm 图表为我的项目设置通配符子域:
在ingress.yaml文件中:
...
rules:
- host: {{ .Values.ingress.host }}
...
Run Code Online (Sandbox Code Playgroud)
在values.yaml文件中,我将主机更改example.local为*.example.local:
...
ingress:
enabled: true
host: "*.example.local"
...
Run Code Online (Sandbox Code Playgroud)
然后,当我使用 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
Run Code Online (Sandbox Code Playgroud)
我该如何修复它?
感谢您的支持。
ana*_*rxz 21
YAML 以特殊方式处理以星号开头的字符串 - 这就是为什么带有通配符的主机名*.example.local 会破坏helm install. 为了被识别为字符串,ingress.yaml文件中的值应该用 " "字符引起来:
...
rules:
- host: "{{ .Values.ingress.host }}"
...
Run Code Online (Sandbox Code Playgroud)
这里还有一个选项 - 添加| quote:
...
rules:
- host: {{ .Values.ingress.host | quote }}
...
Run Code Online (Sandbox Code Playgroud)
我已经重现了您的问题,这两个选项都工作正常。有关为 YAML 引用特殊字符的更多信息,请参见此处。
| 归档时间: |
|
| 查看次数: |
8164 次 |
| 最近记录: |