Açıklaması şöyle
range is as similar to for/foreach loops, like other programming languages. In Helm’s template language, the way to iterate through a collection is to use the range operator.
Örnek
values.yaml şöyle olsun
configMap:
data:
env: test
platfrom:
- java
- python
- golangŞöyle yaparız
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-configmap
data:
env: {{ .Values.configMap.data.env }}
platfrom: |
{{- range .Values.configMap.data.platfrom }}
- {{ . | title | quote }}
{{- end }}Çıktısı şöyledir
>> helm template ~/webserver --- # Source: webserver/templates/test.yaml apiVersion: v1 kind: ConfigMap metadata: name: release-name-configmap data: env: test platfrom: | - "Java" - "Python" - "Golang"
Örnek
Şöyle yaparız. {{ toYaml ($.Values.vtgate.resources) | indent 10 }} ile values.yaml dosyasındaki blok aynen kopyalanır
{{ range $cell := $.Values.availabilityZones }}
- name: {{ $cell }}
gateway:
authentication:
static:
secret:
name: {{ $.Values.keyspaceName }}
key: users.json
replicas: {{ $.Values.vtgate.replicas }}
extraFlags:
mysql_server_version: "8.0.13-Vitess"
resources:
{{ toYaml ($.Values.vtgate.resources) | indent 10 }}
{{end}}Örnek
Şöyle yaparız. Burada $. ile başlamıyor. Üzerinde yürünen blok için bilgi çekiliyor.{{- range .Values.proc.imgw }}
{{- if and (not .podSpecific) (eq .protocol "TCP") }}
- name: {{ .name }}
protocol: {{ .protocol }}
port: {{ .containerPort }}
nodePort: {{ add $root.Values.farm_offset .nodePort }}
targetPort: {{ .containerPort }}
{{- end }}values.yaml şöyledir
proc:
...
imgw:
- containerPort: 12340
name: rlwy-proc-imgw1
protocol: TCP
nodePort: 30092
- containerPort: 12341
name: rlwy-proc-imgw2
protocol: TCP
nodePort: 30093
- containerPort: 12342
name: rlwy-proc-imgw3
protocol: TCP
nodePort: 30094
- containerPort: 12343
name: rlwy-proc-imgw4
protocol: TCP
nodePort: 30095
Hiç yorum yok:
Yorum Gönder