样例一、
values.yaml:
image:
repository: nginx
tag: 1.7.9
pullPolicy: IfNotPresent
envs:
- NET_NAME : "SZ_328"
- NET_PORT : "5678"
templates/deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
...
env:
{<!-- -->{- range .Values.envs }}
{<!-- -->{- range $key,$val := . }}
- name : {<!-- -->{ $key }}
value : {<!-- -->{ $val }}
{<!-- -->{- end}}
{<!-- -->{- end}}
结果:
$ helm install --dry-run --debug . --tiller-namespace=default
...
# Source: test2/templates/deployment.yaml
apiVersion: extensions/v1beta1
...
imagePullPolicy: IfNotPresent
env:
- name : NET_NAME
value : SZ_328
- name : NET_PORT
value : 5678
样例二、
values.yaml:
image:
repository: nginx
tag: 1.7.9
pullPolicy: IfNotPresent
envs:
- name : NET_NAME
value : SZ_328
- name : NET_PORT
value : 5678
templates/deployment.yaml:
apiVersion: extensions/v1beta1
kind: Deployment
...
env:
{<!-- -->{- range .Values.envs }}
{<!-- -->{- with . }}
- name : {<!-- -->{ .name }}
value : {<!-- -->{ .value }}
{<!-- -->{- end}}
{<!-- -->{- end}}
结果:
$ helm install --dry-run --debug . --tiller-namespace=default
...
# Source: test2/templates/deployment.yaml
apiVersion: extensions/v1beta1
...
imagePullPolicy: IfNotPresent
env:
- name : NET_NAME
value : SZ_328
- name : NET_PORT
value : 5678
样例二、
a:、map写法:
server:
##extraArgs: {}
extraArgs:
storage.local.checkpoint-dirty-series-limit: 5000
query.max-concurrency: 20
- name: test
image: busybox:latest
args:
- --web.console.templates=/etc/prometheus/consoles
{<!-- -->{- range $key, $value := .Values.server.extraArgs }}
- --{<!-- -->{ $key }}={<!-- -->{ $value }}
{<!-- -->{- end }}
b: 数组写法:
server:
#extraHostPathMounts: []
extraHostPathMounts:
- name: certs-dir-1
mountPath: /etc/kubernetes/certs
hostPath: /etc/kubernetes/certs
readOnly: true
- name: certs-dir-2
mountPath: /etc-2/kubernetes/certs
hostPath: /etc-2/kubernetes/certs
readOnly: true
volumeMounts:
{{- range .Values.server.extraHostPathMounts }}
- name: {{ .name }}
mountPath: {{ .mountPath }}
readOnly: {{ .readOnly }}
{{- end }}
volumes:
{{- range .Values.server.extraHostPathMounts }}
- name: {{ .name }}
hostPath:
path: {{ .hostPath }}
{{- end }}