簡體   English   中英

如何使用 helm 從目錄創建 ConfigMap

[英]How to create ConfigMap from directory using helm

我在postman文件夾中有一個包含 3 個 json 文件的文件夾。 如何使用 Helm yaml 模板創建 ConfigMap?

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

上述解決方案有效,但我需要將其作為 yaml 文件,因為我正在使用 Helm。

在 Helm 模板中,您可以使用Files.GlobAsConfig輔助函數來實現這一點:

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

或者,舉一個 Helm 模板的完整示例:

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

有關更多信息,請參閱文檔(尤其是“ConfigMap 和 secrets 實用程序函數”部分)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM