Kubernetes 在helm模板中传递多个变量

Kubernetes 在helm模板中传递多个变量,kubernetes,devops,kubernetes-helm,Kubernetes,Devops,Kubernetes Helm,是否有方法在模板中传递多个变量或使用包含的函数?在我的例子中,我迭代了一个项目列表,但在模板中,我还需要.Release.Name变量 是否有方法向$client添加.Release.Name?我尝试了类似于{$client.Name:=.Release.Name}}的方法,但它抛出了一个错误 我有以下模板: {{- range $client := .Values.global.clients }} {{- with $ }} search.service-{{ $client.clientI

是否有方法在
模板中传递多个变量
或使用
包含
的函数?在我的例子中,我迭代了一个项目列表,但在模板中,我还需要
.Release.Name
变量

是否有方法向
$client
添加
.Release.Name
?我尝试了类似于
{$client.Name:=.Release.Name}}
的方法,但它抛出了一个错误

我有以下模板:

{{- range $client := .Values.global.clients }}
{{- with $ }}
search.service-{{ $client.clientId }}.cfg: |
{{ include "rest-api.search" $client | indent 4}}
{{- end}}
{{- end}}
rest-api.search函数:

{{- define "rest-api.search" -}}
client.id={{ .clientId }}
id={{ .clientId }}
uri=http://{{ .Release.Name }}:11666/{index}/ws/{configuration}
default.index=quicksearch
default.configuration=form
query.sort=
query.filter=
query.dsf=word
query.lower=0
query.max=10
query.locale=de
query.query=*
# Index mapping
index.COMMON=quicksearch
index.REF=quicksearch
supportObjectGroup=true
# authorization scheme
authScheme=NONE

{{- end -}}

我感谢你的帮助。谢谢

您可以在dict中将客户机对象与发布对象一起传递

值。yaml

global:
  clients:
    - name: test
      clientId: test-123
{{- range $client := .Values.global.clients }}
{{$data := dict "client" $client "release" $.Release }}
search.service-{{ .clientId }}.cfg: |
{{ include "mychart.search" $data | indent 4}}
{{- end}}
{{- define "mychart.search" -}}
client.id={{ .client.clientId }}
id={{ .client.clientId }}
uri=http://{{ .release.Name }}:11666/{index}/ws/{configuration}
default.index=quicksearch
{{- end -}}
configmap.yaml

global:
  clients:
    - name: test
      clientId: test-123
{{- range $client := .Values.global.clients }}
{{$data := dict "client" $client "release" $.Release }}
search.service-{{ .clientId }}.cfg: |
{{ include "mychart.search" $data | indent 4}}
{{- end}}
{{- define "mychart.search" -}}
client.id={{ .client.clientId }}
id={{ .client.clientId }}
uri=http://{{ .release.Name }}:11666/{index}/ws/{configuration}
default.index=quicksearch
{{- end -}}
\u helpers.tpl

global:
  clients:
    - name: test
      clientId: test-123
{{- range $client := .Values.global.clients }}
{{$data := dict "client" $client "release" $.Release }}
search.service-{{ .clientId }}.cfg: |
{{ include "mychart.search" $data | indent 4}}
{{- end}}
{{- define "mychart.search" -}}
client.id={{ .client.clientId }}
id={{ .client.clientId }}
uri=http://{{ .release.Name }}:11666/{index}/ws/{configuration}
default.index=quicksearch
{{- end -}}

我将文件内容移动到第一个模板中。。在尝试了不同的方法后,我放弃了。。如果能有一个解决方案那就太好了..我查看了如何使用dict来实现这一点,但找不到任何示例。谢谢