Pass value from one file(encrypted) to yaml with yaml inside

5/11/2020

I've got a yaml file with config for helm charts, and there is a section that looks like this:

master:
  enabled: true
  configScripts:
    config: | 
      password: xxx

I wanted to subtitute the password with the known way {{ .Values.secrets.password }} but since it's yaml in yaml I cannot - or can I? does anyone know a way, preferably it would be kept in separate file that is encrypted on git.

-- potatopotato
kubernetes-helm
yaml

1 Answer

5/11/2020

Actually you can. Just deal with the config (could be YAML, JSON, etc.) as a string.

master:
  enabled: true
  configScripts:
    config: {{- printf "password: %s" (printf "%s" .Values.secrets.password | b64enc) }} 
-- Kamol Hasan
Source: StackOverflow