Helm templates: Inject working bash script into a configmap with template parameters?

5/12/2020

I have a bash script:

script.sh:

#!/bin/bash
ENV=test
echo "$ENV" 

that I manually adjust (add values parameters) and copy into my helm configmap template/yaml file:

script-configmap.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-script
  namespace: {{ .Values.namespace }}
data:
  script.sh: |
    #!/bin/bash
    ENV={{ .Values.environment }}
    echo "$ENV" 

Are there a better approach to embed a working bash script into a configmap with helm values parameters?

Seems a bit stupid to maintain two versions of the script. One is the script.sh file that I can run/test locally and the other is basically the same script but embedded into script-configmap.yaml file but with helm values parameters.

-- u123
bash
kubernetes-helm

0 Answers