如何将多个模板化配置文件加载到舵图中? [英] How do I load multiple templated config files into a helm chart?

查看:18
本文介绍了如何将多个模板化配置文件加载到舵图中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在尝试构建一个舵图.

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 

现在是实际的.在这里您可以找到 2 种导入类型:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆