简体   繁体   中英

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 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 ):

MY_ENV_VARIABLE_1: "true"

Please note that I have alredy tried these for 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.

I can see from your message that the file you have used for configmap yaml is # helm/environments/config.dev.yaml . Please rename it to configmap.dev.yml . And change your printf statement like below. Once you make these changes, things should work fine.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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