一般Tiller 会渲染templates/ 目录下的所有模板。
因此,如果我正确理解您的问题 - 您可以从以下简单示例开始:
1)创建测试图表并删除所有预定义模板
helm create testchart
rm -rf testchart/templates/*
2) 在templates/中创建2个Configmaps yaml文件
configmap1.yaml:
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-configmap-1
data:
myvalue: "My Drinks:"
drink1: {{ .Values.config1test.drink1 }}
drink2: {{ .Values.config1test.drink2 }}
drink3: {{ .Values.config1test.drink3 }}
configmap2.yaml:
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-configmap-2
data:
myvalue: "My food:"
food1: {{ .Values.config2test.food1 }}
food2: {{ .Values.config2test.food2 }}
food3: {{ .Values.config2test.food3 }}
3) 创建值文件(1 个或更多,具体取决于您的实现。我创建了 2 个)
myvals1.yaml:
config1test:
drink1: coffee
drink2: tea
drink3: juice
myvals2.yaml:
config2test:
food1: meat
food2: fish
food3: salad
4) 应用前测试模板渲染:
helm install --dry-run --debug -f ./testchart/myvals1.yaml -f ./testchart/myvals2.yaml ./testchart
[debug] Created tunnel using local port: '37605'
[debug] SERVER: "127.0.0.1:37605"
[debug] Original chart version: ""
[debug] CHART PATH: /home/vkryvoruchko/testchart
NAME: tan-frog
REVISION: 1
RELEASED: Fri Feb 1 13:10:46 2019
CHART: testchart-0.1.0
USER-SUPPLIED VALUES:
config1test:
drink1: coffee
drink2: tea
drink3: juice
config2test:
food1: meat
food2: fish
food3: salad
COMPUTED VALUES:
affinity: {}
config1test:
drink1: coffee
drink2: tea
drink3: juice
config2test:
food1: meat
food2: fish
food3: salad
fullnameOverride: ""
image:
pullPolicy: IfNotPresent
repository: nginx
tag: stable
ingress:
annotations: {}
enabled: false
hosts:
- chart-example.local
paths: []
tls: []
nameOverride: ""
nodeSelector: {}
replicaCount: 1
resources: {}
service:
port: 80
type: ClusterIP
tolerations: []
HOOKS:
MANIFEST:
---
# Source: testchart/templates/configmap1.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: tan-frog-configmap-1
data:
myvalue: "My Drinks:"
drink1: coffee
drink2: tea
drink3: juice
---
# Source: testchart/templates/configmap2.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: tan-frog-configmap-2
data:
myvalue: "My food:"
food1: meat
food2: fish
food3: salad
5) 安装图表
helm install -f ./testchart/myvals1.yaml -f ./testchart/myvals2.yaml ./testchart
NAME: unsung-grizzly
LAST DEPLOYED: Fri Feb 1 13:13:15 2019
NAMESPACE: default
STATUS: DEPLOYED
RESOURCES:
==> v1/ConfigMap
NAME DATA AGE
unsung-grizzly-configmap-1 4 0s
unsung-grizzly-configmap-2 4 0s
6) 验证 ConfigMap:
kubectl get configmaps -o wide
NAME DATA AGE
unsung-grizzly-configmap-1 4 61s
unsung-grizzly-configmap-2 4 61s