I am trying to put the content of a configuration file inside values.yaml
and get it.
For example:
This is the values.yaml:
configuration: |
[core]
# Some comments
my_folder = /usr/local/my_folder
# The folder where my app should store its log files
# This path must be absolute
base_log_folder = /usr/local/app/logs
# Logging options
remote_logging = False
remote_log_conn_id =
remote_base_log_folder =
encrypt_logs = False
and this is a configMap where I should put the content in:
apiVersion: v1
kind: ConfigMap
metadata:
name: "{{ template "app.fullname" . }}-config"
data:
my.cfg: |
{{ HELM }}
In "HELM" tag, I tried several options of tpl
and include
, all without reaching my goal.
As non-optimal solution I put the content of my configuration
in a file and grab it with
{{ .Files.Get "files/my.configuration" | indent 4 }}
I am asking for some suggestions about the possibility to have all in values.yaml
, please. Thank you in advance.
As you are using |
on your YAML, you are defining a Multiline YAML String, which means that your configuration
key has a single string value with line breaks on it (\n
).
You can simply define your ConfigMap template like this:
apiVersion: v1
kind: ConfigMap
metadata:
name: "{{ template "app.fullname" . }}-config"
data:
my.cfg:
{{- toYaml $.Values.configuration | nindent 4 }}
After rendering, the resulting ConfigMap will be deployed as:
apiVersion: v1
data:
my.cfg: |
[core]
# Some comments
my_folder = /usr/local/my_folder
# The folder where my app should store its log files
# This path must be absolute
base_log_folder = /usr/local/app/logs
# Logging options
remote_logging = False
remote_log_conn_id =
remote_base_log_folder =
encrypt_logs = False
kind: ConfigMap
metadata:
name: test-config