Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support environment variable replacements during helm package #3198

Closed
ngeor opened this issue Nov 23, 2017 · 4 comments
Closed

Support environment variable replacements during helm package #3198

ngeor opened this issue Nov 23, 2017 · 4 comments
Labels

Comments

@ngeor
Copy link

ngeor commented Nov 23, 2017

It would be great if the command "helm package" is able to handle environment variables inside yaml files.

For example, consider the following Chart.yaml:

name: my-app
version: ${APP_VERSION}

When running APP_VERSION=1.0.1 helm package, this should generate a tgz file in which the Chart.yaml will have gone through environment substitution (so we'll have version: 1.0.1).

The same should be supported for all yaml files. The main use case is to dynamically specify the Docker image tag in values.yaml:

imageTag: ${IMAGE_TAG}

This gets really handy when doing continuous delivery using Helm:

  • the build process is responsible for building the Docker image. The version of the Docker image is calculated based on the app version and the git SHA ID (e.g. 1.0.1-a345f12)
  • during the build process, the Helm chart is packaged and published to a Helm repository. Having this environment variable substitution feature will allow for generating a Helm chart that references the exact correct Docker image that was produced by that particular build.
  • effectively this renders the Helm chart the single artifact of the build (as it has a 1-1 relationship with the Docker image)

While implementing this in helm package is something that I could even manage by myself, I don't know if this fits the overall architecture of helm (or if there is an alternative to this).

We currently have a workaround in-place inspired by this repo: https://github.com/samsung-cnct/chart-logging - here the pre-processing of environment variables is done with extra files. Chart.yaml has a pre-process template Chart.yaml.in. Before packaging the chart in the build server, Chart.yaml.in is used to generate the actual Chart.yaml. This works but it is an extra custom step (would be great if Helm had this out of the box) and it means you need to maintain two almost identical files.

@jascott1
Copy link
Contributor

Hi @ngeor
PR #3196 was just merged that allows you to set the package version with --app-version flag. Does specifying that with your environment variable (e.g. helm package --app-version=$APP_VERSION) fulfill your needs?

@bacongobbler
Copy link
Member

it indeed does, and the second use case of "dynamically specify the Docker image tag in values.yaml" should be solved via helm package --values/--set, which is described in #3141.

Good catch, @jascott1.

@bacongobbler
Copy link
Member

Does this sound right to you @ngeor? If so I think we can close this one out in favor of the previously opened feature request in #3141.

@ngeor
Copy link
Author

ngeor commented Nov 28, 2017

Good morning,

thanks for the suggestions! It seems that I might be able to put them into good use and get rid of the custom workaround.

For the Docker tag, the helm upgrade --install --set will probably do (not helm package).

For the Chart version, I think actually helm package --version might do what I want just fine, I don't even need the new --app-version flag.

The idea is to take the version out of package.json (it's a nodeJS app) and concatenate the git SHA id (except for the master branch). So I'll have a Docker image versioned 1.2.3-sha-id. Then, I'll package my chart with --version 1.2.3-sha-id and install it with --set image.tag=1.2.3-sha-id, which leaves me with one version to rule them all.

In theory everything should work fine, thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants