My search foo isn't strong on this question and I couldn't find any answers that helped. I have a bit of an inception-style question in setting up a helm chart with secrets keys that are files with protected information.
Trying to put together a helm chart for an app that requires a config.yml file to be stored in a secret, which is then mounted by the app container. Here's an example of what the raw yaml would look like:
kind: Secret
apiVersion: v1
metadata:
name: myapp-config
namespace: myapp
data:
config.yml: >-
property1: value1
api_token: "somecrazyrandomlygeneratedtoken="
api_credentials: "username:supersecretpassword"
add_X_number_more_properties: "more values"
type: Opaque
Obviously I don't want the creds and token in plain text like that. I'd rather not base64 the entire file contents as that would make it difficult to manage when certain properties need to change and as the file could grow and be more complicated. Is there a way to use the Jinja syntax within the file contents? Maybe something like:
value.yml
api_token: "base64_version_of_token"
api_user: "username" (or base64 version)
api_pass: "base64_verison_of_password"
Secret Template:
data:
config.yml: >-
property1: value1
api_token: "{{ .Values.api_token | b64 -d }}"
api_credentials: "{{ .Values.api_user }}:{{ .Values.api_pass | b64 -d }}"
Another part of the chart is similar. rather than doing a standard range
to build a set of key/value pairs, I need to "build" a yml file based on files stored in a directory that users populate with files that define custom processing rules for the app to follow. That resulting yml file then gets pushed out to a secret for mounting by the app.
kind: Secret
apiVersion: v1
metadata:
name: {{ .Values.instance_name }}-customProcs
namespace: {{ .Values.namespace }}
data:
pipelines.yml: >-
{{ foreach files in source Directory }}
- process.id: {{ filename minus extension }}
path.config: "{{ file.name }}"
{{ end loop }}
type: Opaque
If this was a simple key-pair setup, it would be easy, but since its inside >- block as a text file, I'm not sure if the normal .Files loops would work