Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kubernetes 阵列内部条件下的库伯内特斯掌舵图_Kubernetes_Kubernetes Helm - Fatal编程技术网

Kubernetes 阵列内部条件下的库伯内特斯掌舵图

Kubernetes 阵列内部条件下的库伯内特斯掌舵图,kubernetes,kubernetes-helm,Kubernetes,Kubernetes Helm,我正在尝试更新此图表: k8s.v1.cni.cncf.io/networks: '[ { "name" : "ext", "ips": {{ .Values.global.extoamlancas0 | quote }}, "interface": "e1"}, { "name" : "ext-app", &

我正在尝试更新此图表:

k8s.v1.cni.cncf.io/networks: '[
            { "name" : "ext", "ips": {{ .Values.global.extoamlancas0 | quote }}, "interface": "e1"},
            { "name" : "ext-app", "ips": {{ .Values.global.extapplancas0 | quote }}, "interface": "e3"},
            { "name" : "int-", "ips": {{ .Values.global.intoamlancas0 | quote }}, "interface": "e2"}
         ]'
Here
 if {{- if Values.a }} then I want "ips" to be in an array i.e 
{ "name" : "ext-", "ips": [ {{ .Values.global.extoamlancas0 | quote }} ], "interface": "e1"}

else 
{ "name" : "ext", "ips": {{ .Values.global.extoamlancas0 | quote }}, "interface": "e1"}

我希望对所有其他2个IP也执行此操作。

在values.yaml文件中,您需要指定如下数组IP:

ips:
  - address: 192.168.1.1
    name: no1

  - address: 192.168.1.2
    name: no2
{{- range .Values.ips }}
  - name: {{ .name }}
    address: {{ .address }}
{{- end }}
在模板文件中,您可以这样循环:

ips:
  - address: 192.168.1.1
    name: no1

  - address: 192.168.1.2
    name: no2
{{- range .Values.ips }}
  - name: {{ .name }}
    address: {{ .address }}
{{- end }}
以下是golang docs的片段:

{{range pipeline}}T1{{end}}管道的值必须是 阵列、切片、贴图或通道。如果管道的值为 长度为零,不输出任何内容;否则,将点设置为 执行数组、切片或映射的连续元素和T1。 如果值是一个映射,并且键是具有定义 顺序,元素将按排序键顺序访问

{{range pipeline}}T1{{else}}T0{{end}}管道的值 必须是数组、切片、贴图或通道。如果 管道长度为零,点不受影响,执行T0; 否则,将点设置为数组的连续元素slice, 或映射并执行T1


在values.yaml文件中,需要指定如下数组:

ips:
  - address: 192.168.1.1
    name: no1

  - address: 192.168.1.2
    name: no2
{{- range .Values.ips }}
  - name: {{ .name }}
    address: {{ .address }}
{{- end }}
在模板文件中,您可以这样循环:

ips:
  - address: 192.168.1.1
    name: no1

  - address: 192.168.1.2
    name: no2
{{- range .Values.ips }}
  - name: {{ .name }}
    address: {{ .address }}
{{- end }}
以下是golang docs的片段:

{{range pipeline}}T1{{end}}管道的值必须是 阵列、切片、贴图或通道。如果管道的值为 长度为零,不输出任何内容;否则,将点设置为 执行数组、切片或映射的连续元素和T1。 如果值是一个映射,并且键是具有定义 顺序,元素将按排序键顺序访问

{{range pipeline}}T1{{else}}T0{{end}}管道的值 必须是数组、切片、贴图或通道。如果 管道长度为零,点不受影响,执行T0; 否则,将点设置为数组的连续元素slice, 或映射并执行T1