简体   繁体   English

如何使用 helm 从目录创建 ConfigMap

[英]How to create ConfigMap from directory using helm

I have a folder with 3 json files in a postman folder.我在postman文件夹中有一个包含 3 个 json 文件的文件夹。 How can I create a ConfigMap using a Helm yaml template?如何使用 Helm yaml 模板创建 ConfigMap?

kubectl create configmap test-config --from- 
file=clusterfitusecaseapihelm/data/postman/

The above solution works, but I need this as yaml file as I am using Helm.上述解决方案有效,但我需要将其作为 yaml 文件,因为我正在使用 Helm。

Inside a Helm template, you can use the Files.Glob and AsConfig helper functions to achieve this:在 Helm 模板中,您可以使用Files.GlobAsConfig辅助函数来实现这一点:

{{- (.Files.Glob "postman/**.json").AsConfig | nindent 2 }}

Or, to give a full example of a Helm template:或者,举一个 Helm 模板的完整示例:

apiVersion: v1
kind: ConfigMap
metadata:
  name: test-config
data:
  {{- (.Files.Glob "postman/**.json").AsConfig | nindent 2 }}

See the documentation (especially the section on "ConfigMap and secrets utility functions") for more information.有关更多信息,请参阅文档(尤其是“ConfigMap 和 secrets 实用程序函数”部分)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM