gpt4 book ai didi

templates - Helm 遍历范围

转载 作者:行者123 更新时间:2023-12-04 11:05:11 24 4
gpt4 key购买 nike

我找不到在 helm 模板中迭代某个范围的方法。
我的 values.yaml 中有下一个定义:

ingress:
app1:
port: 80
hosts:
- example.com
app2:
port: 80
hosts:
- demo.example.com
- test.example.com
- stage.example.com
app3:
port: 80
hosts:
- app3.example.com

我想为每个提到的主机生成相同的 nginx 入口规则:
spec:
rules:
{{- range $key, $value =: .Values.global.ingress }}
- host: {{ $value.hosts }}
http:
paths:
- path: /qapi
backend:
serviceName: api-server
servicePort: 80
{{- end }}

但它会生成错误的主机:
- host: [example.com]
- host: [test.example.com demo.example.com test.example.com]

谢谢您的帮助!

最佳答案

我终于让它工作了:

spec:
rules:
{{- range $key, $value := .Values.global.ingress }}
{{- range $value.hosts }}
- host: {{ . }}
http:
paths:
- path: /qapi
backend:
serviceName: api-server
servicePort: 80
{{- end }}
{{- end }}

关于templates - Helm 遍历范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56224527/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com