如何将多个模板化配置文件加载到掌舵图中? [英] How do I load multiple templated config files into a helm chart?
问题描述
所以我试图建立一个舵图.
So I am trying to build a helm chart.
在我的模板文件中,我有一个类似的文件:
in my templates file I've got a file like:
apiVersion: v1
kind: ConfigMap
metadata:
name: config-map
data:
{{ Do something here to load up a set of files | indent 2 }}
我的图表中还有一个目录:configmaps
一组json文件,它们本身将具有模板化变量:
I have another directory in my chart: configmaps
where a set of json files, that themselves will have templated variables in them:
a.json
b.json
c.json
最终我想确保在图表中可以参考:
Ultimately I'd like to be sure in my chart I can reference:
volumes:
- name: config-a
configMap:
name: config-map
items:
- key: a.json
path: a.json
推荐答案
几周前,我在将文件和模板直接添加到容器中时遇到了同样的问题.
I had same problem for a few weeks ago with adding files and templates directly to container.
查找示例语法:
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-configmap-{{ .Release.Name }}
namespace: {{ .Release.Namespace }}
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
nginx_conf: {{ tpl (.Files.Get "files/nginx.conf") . | quote }}
ssl_conf: {{ tpl (.Files.Get "files/ssl.conf") . | quote }}
dhparam_pem: {{ .Files.Get "files/dhparam.pem" | quote }}
fastcgi_conf: {{ .Files.Get "files/fastcgi.conf" | quote }}
mime_types: {{ .Files.Get "files/mime.types" | quote }}
proxy_params_conf: {{ .Files.Get "files/proxy_params.conf" | quote }}
第二步是从部署中引用它:
Second step is to reference it from deployment:
volumes:
- name: {{ $.Release.Name }}-configmap-volume
configMap:
name:nginx-configmap-{{ $.Release.Name }}
items:
- key: dhparam_pem
path: dhparam.pem
- key: fastcgi_conf
path: fastcgi.conf
- key: mime_types
path: mime.types
- key: nginx_conf
path: nginx.conf
- key: proxy_params_conf
path: proxy_params.conf
- key: ssl_conf
path: ssl.conf
现在是实际的.在这里,您可以找到两种导入类型:
It's actual for now. Here you can find 2 types of importing:
- 没有模板的常规文件
- 内部具有动态变量的配置文件
请不要忘记阅读官方文档: https://helm.sh/docs/chart_template_guide/accessing_files/
Please do not forget to read official docs: https://helm.sh/docs/chart_template_guide/accessing_files/
祝你好运!
这篇关于如何将多个模板化配置文件加载到掌舵图中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!