Reputation: 55
I have a use case where i want to have dynamic value for given attribute in helm values.yaml.For example I have below version file
version=123
I want to dynamically parse and consume this version into helm values.yaml version attribute.
Expected values.yaml
name: abc
version: 123
Upvotes: 3
Views: 3955
Reputation: 9915
There are many options depending on what goes best with your toolset, but what I've done/seen done in the past is to create your own template of the yaml file, values.yaml.template
, and substitute the desired values in.
So, for example your values.yaml.template, would be something like:
name: abc
version: {{version}}
And you would pass both the template filename and the version filename to a templating engine to do the substitution.
Some ways to do this:
sed
- a little hacky but already installed. Here's an example.There are obviously a large number of templating languages, so it's a matter of what is the least effort given your stack. But maybe a more difficult question is, how do you hook into the helm provisioning or startup so that you can generate the config yaml file from your template. This also depends on your stack.
[UPDATE] I'm not familiar with helm, but it may also be possible to get config values dynamically (ie, using a helm plugin that retrieves the helm config from a config server at helm startup).
Upvotes: 2