简体   繁体   English

helm install 上 Configmap 中的数据节点为空

[英]data node empty in Configmap on helm install

These are my helm charts:这些是我的掌舵图:

# helm/templates/configmap.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-configmap
data:
  mycfgmap: |-
{{ .Files.Get (printf "environments/configmap.%s\n.yaml" .Values.namespace) | indent 4 }}

# helm/environments/values.dev.yaml

namespace: dev
# helm/environments/configmap.dev.yaml

MY_ENV_VARIABLE_1: "true"

This is how I am installing my helm charts:这就是我安装 helm 图表的方式:

helm install --dry-run --debug --create-namespace -n dev -f helm/environments/values.dev.yaml my-test-release helm

This is the output I am getting:这是我得到的输出:

# Source: helm/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: my-configmap
data:
  mycfgmap: |-
---

I am expecting this to be in the data node (as defined in my configmap.dev.yaml ):我希望这在数据节点中(如我的configmap.dev.yaml中所定义):

MY_ENV_VARIABLE_1: "true"

Please note that I have alredy tried these for helm/templates/config.yaml :请注意,我已经为helm/templates/config.yaml尝试过这些:

{{ .Files.Get (printf "../environments/configmap.%s\n.yaml" .Values.namespace) | indent 4 }}

# and

{{ .Files.Get (printf "environments/configmap.%s.yaml" .Values.namespace) | indent 4 }}

and it doesn't work.它不起作用。 I have also looked at similar questions answered on SO, but my problem seem to be something else.我还查看了关于 SO 回答的类似问题,但我的问题似乎是其他问题。

I can see from your message that the file you have used for configmap yaml is # helm/environments/config.dev.yaml .我可以从您的消息中看到您用于 configmap yaml 的文件是# helm/environments/config.dev.yaml Please rename it to configmap.dev.yml .请将其重命名为configmap.dev.yml And change your printf statement like below.并更改您的printf语句,如下所示。 Once you make these changes, things should work fine.进行这些更改后,一切都应该正常。

{{ .Files.Get (printf "environments/configmap.%s.yaml" .Values.namespace) | indent 4 }}

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

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