Interpolating yaml as a template variables
Closed this issue · 1 comments
jsierles commented
I have a lot of secrets being used as environment vars. I'd like to share this config across deployments. For example:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: "database-url"
key: "database-url"
Is there a way to do this, as opposed to interpolating a single value, with kontemplate?
tazjin commented
Very long run-up time for answering this, I'm sorry!
You can probably use the toJson
filter to create JSON out of the structure you want (you can store arbitrary keys in variables). Putting the JSON into the YAML template will work fine, as JSON is a valid subset of YAML.
For example:
# assuming `secretKeyConfig` is a variable holding the structure you mentioned above
- name: DATABASE_URL
valueFrom: {{ secretKeyConfig | toJson }}