Reputation: 11
I have an helm chart used to deploy a spring service that have configuration file in YAML file. Currently, my helm chart use the following code:
templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: account-service-config
data:
variable.yml:
{{ range $key, $value := .Values.spring.config.content | indent 4 }}
{{ $key | indent 2}}={{ $value }}
{{printf "\n" }}
{{- end -}}
I have a values.yaml as below
spring:
config:
content: |-
spring:
application:
name: hello
security:
abc:
abc-def: ${url}
The problem is that if I want to change the value of anything for e.g application name, I have to rewrite the entire configuration like that:
spring:
config:
content: |-
spring:
application:
name: valuechange
security:
abc:
abc-def: ${url}
So my question is, is there a way to convert the string to Yaml in a Helm template. I wanted it to be converted into helm yaml and inject it through configmaps in deployment file.
The helm templates are common for many services so I cannot explicitly define the values as they are different for each service and I am overriding the values.yaml by another file called values.yaml in respective spring service repository.
Upvotes: 0
Views: 10792
Reputation: 5521
You can use the function called toYaml
like this:
variable.yml: |-
{{ toYaml .Values.spring.config.content | indent 4 }}
We use something similar in our Hazelcast Helm Chart. Please check the details here.
Upvotes: 2