Reputation: 1503
I have a Helm chart and in the deployment, I want to provide some environment variable for my pods. During build time in my CI/CD setup, I have the values as env vars and I'm passing them now like this:
helm upgrade CHART_NAME helm --install --set-string webserver.env.DATABASE_URL=$DATABASE_URL
I have like more then 20 env vars, can I access them somehow in my values.yml?
webserver:
env:
DATABASE_URL=${DATABASE_URL}
Sadly this one doesn't work.
Upvotes: 1
Views: 1699
Reputation: 10691
Helm does not resolve placeholders (environment variables) inside values
files, but you can do it yourself in the CI/CD script, before passing the file to the helm upgrade
command:
values-env.yaml:
webserver:
env:
DATABASE_URL=${DATABASE_URL}
CI/CD script:
eval "echo \"$(cat values-env.yaml)\"" >> values-ci.yaml
helm upgrade CHART_NAME helm --install --values values-ci.yaml
Upvotes: 2
Reputation: 630
The better approach will be to create a values-override.yaml file and store all the values that needs to be set from Jenkins in the values-override file.
Use sed
command to update the value-override.yaml to the jenkins env-variable. Use the override values.yaml in the Helm upgrade command.
Upvotes: 0