helm模版中的数组模式取值

韵味老鸟 2024-07-08 17:04:44

helm模版中的 数组模式取值

如果模版中的值是数组,则使用循环的方式获取,如 virtualservice

#istio 控制istio: enabled: true namespace: default virtualservice: - name: "go-ai-inner" hosts: - "go-ai.default.svc.cluster.local" header_key: go-ai port: 60000 destination: subsets: - name: v1 labels: version: v1

template/virtualservice.yaml

{{- if .Values.istio.enabled -}}{{- range .Values.istio.virtualservice -}}apiVersion: networking.istio.io/v1beta1kind: VirtualServicemetadata: name: {{ .name }} namespace: {{ $.Values.istio.namespace }} labels: {{- include "umi-meta.labels" $ | nindent 4 }} annotations: {{- with $.Values.istio.annotations }} {{- toYaml $ | nindent 4 }} {{ end }}spec: hosts: {{- with .hosts }} {{- toYaml . | nindent 4 }} {{- end }} http: {{- $count := int $.Values.controller.replicaCount -}} {{- $hkey := .header_key -}} {{- range $i,$e := until $count }} - match: - headers: {{ $hkey }} : exact: {{ $hkey }}-{{ $i }} route: - destination: host: {{ $hkey }}-{{ $i }}.{{ $.Values.istio.namespace }}.svc.cluster.local port: number: {{ $.port }} subset: {{ $.Values.controller.version }} {{- end }} - route: - destination: host: {{ $hkey }}-10000.{{ $.Values.istio.namespace }}.svc.cluster.local port: number: {{ $.port }} subset: {{ $.Values.controller.version }}{{ end }}{{- end }}

0 阅读:0