Skip to content

Add 'helm install --app-version' command/versioning a chart against an app version #3555

Closed

Description

@munnerz

As far as I'm aware, helm install currently only supports specifying the --version flag to specify a chart version to install.

I'm unsure how the 'appVersion' field in a Chart.yaml is supposed to be used, but it seems generally useful to add support for versioning your application against a specific version (or version set) of a Chart.

Am I mis-using the appVersion field here? Should I instead be constantly building my chart to be backward compatible with previous version, or otherwise how can I infer to my users which chart version to specify when running helm install if they want a particular version (this becomes even more complex when you consider a user can also change the version deployed with something like --set image.tag, which often results in a version change of an application).

Activity

  1. johngmyers commented on Feb 27, 2018

    @johngmyers

    I just ran into this as well. I normally want the image tag to be specified at time of packaging the chart, but for debugging the app wanted to do an install with a different tag.

  2. fejta-bot commented on May 29, 2018

    @fejta-bot

    Issues go stale after 90d of inactivity.
    Mark the issue as fresh with /remove-lifecycle stale.
    Stale issues rot after an additional 30d of inactivity and eventually close.

    If this issue is safe to close now please do so with /close.

    Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
    /lifecycle stale

  3. munnerz commented on Jun 6, 2018

    @munnerz
    ContributorAuthor

    Bringing this up again as it was raised in helm/charts#5919

    Copying over parts of my recent comment:


    We specifically choose to keep the minor version of our chart aligned with the minor application version (although patch version numbers can, and do drift apart).

    This is because we may add a new flag to a new release of cert-manager, and by adding support for it into the Helm chart would break compatibility with older releases of cert-manager, as they do not support the flag. This is a pretty fundamental question around Helm chart versioning in general IMO, and one we don't have a good story for.

    I know it isn't recommended to try and align appVersion with chart version, but this way, a user knows they can use Helm chart version 0.3.x with any of cert-manager 0.3.x, and chart version 0.4.x with cert-manager 0.4.x. Compatibility is defined within the minor version.

  4. munnerz commented on Jun 6, 2018

    @munnerz
    ContributorAuthor

    /remove-lifecycle stale

  5. asetty commented on Oct 24, 2018

    @asetty

    I'd like to bring this back up for discussion.

    Overall we haven't seen much compelling in favor of versioning the charts for our internal apps when all that is changing is the image tag used by some components. When upgrading a release, the appVersion field seems like the right place for this information.

    Copying over my original proposal referenced above:


    Our current workflow for deploying helm charts involves ansible tasks that call the helm upgrade CLI command and it would be nice to be able to pass a flag to set the appVersion when revising a release for the same chart version.

    It may be a little weird conceptually because an appVersion is associated with a chart rather than release, but in our case we are just updating the image tag used for some containers and our workflow hasn't come to incorporate chart version and/or chart repositories yet. This may change in the future, but for now I don't see any issue with adding a flag for --app-version on install and upgrade as the field is purely informational.

  6. TD-4242 commented on Nov 5, 2018

    @TD-4242

    when developing our own internal applications the app itself changes a lot more than the chart that deploys it. Typically our Continuous Deployment command is a helm upgrade with nothing more than --set imageTag=<new_version> (obviously, used elsewhere in the chart to set the container version) If we replace that with --app-version it would give us another visual point in helm ls to see what versions of code are deployed along with the version of the chart that is deployed.

    To make this more visible otherwise I have standardized on setting a metadata tag of imageTag that gets set to the imageTag passed on install/upgrade. This allows me to use the K8s dashboard or easily create Graphana dashboards with imageTag displayed, but requires me to leave the command line and go mousey clicky.

  7. FedeBev commented on Nov 9, 2018

    @FedeBev

    Any news about this?

    Thanks

  8. added 2 commits that reference this issue on Nov 22, 2018
    4e0ef83
    8ddaa4e
  9. omnipresent07 commented on Jan 5, 2019

    @omnipresent07

    Any update on this. It seems PR from @eraac does what is requested. As @TD-4242 mentioned, we also run helm upgrade --set imageTag=<imagetag>, however this doesn't update the APP VERSION listed in output of helm ls. Being able to --set app-version or --set version will allow us to run helm upgrade such that helm ls correctly shows the version that is deployed.

  10. thunder-spb commented on Jan 11, 2019

    @thunder-spb

    Any updates?

  11. ChrisCooney commented on Jan 15, 2019

    @ChrisCooney

    Aaaaany time soon would be lovely!

  12. 96 remaining items

  13. guice commented on May 15, 2020

    @guice

    So - what now?
    Drop all our versions' support and flow?
    Drop using Secrets?
    Any ideas?

    We build two packages: a helm package with just the charts, sans the env values and secrets file. We rename this package to chart-{app-version}.tgz since chart-version means nothing for us, nor does chart-version support our app-version syntax. Our app updates include any potential chart updates (same repo, using git tagging).

    Then we have a second tgz that's environment specific, chart-{app-version}-{env}.tgz that includes the chart tgz, values yaml, and encrypted secrets file. This file also includes a "package.yaml" that contains values such as tag, app, and environment name for our automated scripts to deploy using helm-secrets.

  14. bvis commented on May 20, 2020

    @bvis

    We are used to identify our applications versions, or most of them, with a semantic version number. Then use use this number in the APP VERSION to identify it easily in the helm history list for rollbacks or other operations.
    As the system does not allow to inject it automatically in deploy time we execute this simple command automatically on our CI/CD pipeline before the deploy command:

    sed -i -E "s/^appVersion: (.*)/appVersion: ${deploy.project.version}/" ${chartPath}/Chart.yaml
    

    It's tricky, but it works as expected.

  15. timothyclarke commented on May 20, 2020

    @timothyclarke

    @bvis
    The issue with your workaround is that you have to edit the chart in your CI/CD pipeline.
    If you use a centralized chart repo, then you're forced into helm pull repo/chart --untar

  16. jakovistuk commented on May 23, 2020

    @jakovistuk

    Any further progress with programatically injecting Chart.yaml/appVersion ? Are there workarounds? It would give a tremendous boost in CI/CD Helm .

  17. davi5e commented on May 23, 2020

    @davi5e

    @jakovistuk as far as I can tell, charts that use appVersion to show the container version do this directly via Chart.yaml, as seen in nginx-ingress/Chart.yaml for example...

    I haven't given much thought to this issue for quite some time, so this may be a really dumb question, but is there a way to use Helm CLI to override appVersion?

  18. munnerz commented on May 24, 2020

    @munnerz
    ContributorAuthor

    It seems like a lot of people here are asking for a way to override the ‘appVersion’ field. The original intent/request in this issue is to allow —app-version as a replacement for —version, so a user could run ‘helm fetch —app-version=v0.15.0’ and Helm would work out what the latest chart version last specified v0.15.0 as an appVersion and fetch that.

    In our project/chart (cert-manager) we want to make it as clear to end users as possible which version they are installing, so allowing them to install by app version instead of chart version would be a far more natural installation experience.

    That said, this issue was opened 2y ago now, and since then we have opted to just keep both of these version numbers in sync/lock-step. After a couple of years doing this, it’s been surprisingly easy and pain free, albeit users sometimes have to wait a couple of weeks for a new official release if there are changes made to our deployment manifests.

    Given the age of this issue, it’s length, the huge variety of slightly different feature gates, and the changes in the Helm project since then (Helm 3, OCI charts etc), I don’t think this issue is in a good state to be driven forward as a feature request in its current form. I’m going to close this issue, but anyone else who has a similar feature request Is best to open a new issue and link to any other relevant comments in this issue to provide evidence. Hopefully that’ll work better for the Helm team’s triage process so your requests can get the visibility they need!

    I also think this sort of functionality could be, and probably is best, implemented as an external tool or wrapper around
    Helm, especially when taking account of the OCI changes which I think would make this trickier to implement.

  19. haimari commented on Aug 10, 2020

    @haimari

    Until this is solved (or not) Here is how i solved this in my CI/CD (GitLab):

    package the chart with the app-version, then deploy it.
    I know that the Chart version is not meant to be the same as the appVersion, but in our case it is fine as a workaround.

    deploy:
      image: alpine/helm:3.2.4
      stage: deploy
      environment:
        name: ${ENV}
      script:
        - helm package --app-version=${CI_COMMIT_TAG} --version=${CI_COMMIT_TAG} ${NAMESPACE}
        -  | 
           helm upgrade -i --wait ${CI_PROJECT_NAME} ./${NAMESPACE}-${CI_COMMIT_TAG}.tgz \
           --set image.repository="${CI_REGISTRY_IMAGE}" \
           --set image.tag="${CI_COMMIT_TAG}" \
           --set-string ingress.enabled="${INGRESS}" \
           --set service.port="${CONTAINER_PORT}" \
           --set service.targetPort="${CONTAINER_PORT}" \
           --set dc="${CI_ENVIRONMENT_NAME}" \
           --set project="${CI_PROJECT_NAME}" \
           --namespace ${NAMESPACE}
        - helm history ${CI_PROJECT_NAME} -n ${NAMESPACE}
      tags:
        - kubernetes
      only:
        - tags
  20. TBBle commented on Aug 10, 2020

    @TBBle
    Contributor

    If you default your image.tag to {{ .Chart.AppVersion }} then you won't need to --set it during the install, it'll already be correct. This works nicely for auto-builds as well, when your Docker images are tagged with SHA1 so the AppVersion matches the Docker image tag, and the Version is an auto-build SemVer.

    There's no problem with Version being the same as AppVersion if your AppVersion happens to be SemVer.

    For packages produced by my team, we're moving towards things that look for AppVersion, e.g. image.tag, defaulting to Version if AppVersion is unset. It's not a huge difference, just one less argument to helm package for tagged releases, but only makes sense if your chart is built from the same SCM as the thing you're packaging.

  21. woodcockjosh commented on Aug 10, 2020

    @woodcockjosh

    @TBBle that won't work if you are using a sub-chart to set your image tag

  22. TBBle commented on Aug 10, 2020

    @TBBle
    Contributor

    Do you mean the image.tag is in a subchart, but you're trying to use the version of a parent chart? If so, yes, that's very awkward, and won't be easy to manage. I just bounced off exactly this layout in https://github.com/googleforgames/open-match/'s Helm charts. I suggest rolling the sub-charts in question back up into the main chart in this case.

    Charts should be independently isolated/usable units, not relying on parent-chart behaviours to function. The subchart has its own version, that's the one that its images should be using, otherwise, why is it a subchart?

    In Open Match's case, the subcharts appear to be used so that XXX.enable can be used as a shortcut in the values.yaml to disable a bunch of stuff at once, but then it introduces a bunch of structural issues like this. Open Match's subcharts all make heavy use of the parent chart named templates, and also have a local version of 0.0.0-dev, so there's already two code-smells that something is not structured well.

    Or perhaps I've misunderstood the observation you're making.

  23. a0s commented on Dec 6, 2020

    @a0s

    @haimari Unfortunately, its not working (relate to #6921 ?):

    > helm package $DIR/deployment/chart --app-version="1111e8" --version="3454e5" --namespace stage
    Error: Invalid Semantic Version

    But, this works:

    > helm package $DIR/deployment/chart --app-version="0.0.0-1111e8" --version="0.0.0-3454e5" --namespace stage
    Successfully packaged chart and saved it to: /Users/aws/service-0.0.0-3454e5.tgz

    and even this (but seems dirty):

    > helm package $DIR/deployment/chart --app-version="0-1111e8" --version="0-3454e5" --namespace stage
    Successfully packaged chart and saved it to: /Users/aws/service-0-3454e5.tgz

    helm version version.BuildInfo{Version:"v3.4.0", GitCommit:"7090a89efc8a18f3d8178bf47d2462450349a004", GitTreeState:"dirty", GoVersion:"go1.15.3"}

  24. TBBle commented on Dec 6, 2020

    @TBBle
    Contributor

    I think @haimari 's solution as-is only works because they use semver-compatible tags in their CI pipeline (i.e. this will be an example for a job run for tagged releases, not run on every-commit)

    @a0s: I generally suggest:

    helm package $DIR/deployment/chart --app-version="<container image tag>" --version="<semver version>"
    

    And then have your container image tag value be something like {{ Values.image.tag | default .Chart.AppVersion | default .Chart.Version, so that you don't need to change it on-the-fly, as @haimari does.

    In your examples you have what appear to be two different git versions, is that right? Is one for the container image, and one for the chart?

    With SemVer, you can't really put a git commit SHA into the meaningful part of the semver, because semver implies ordering, and git commit SHAs are not sortable.

    So you'll want to use a version something like 0.0.1-alpha.<build-id>+g<gitcommitsha> where <build-id> is somelike like the pipeline or job ID from your CI system, so it's always going up you commit to your project. That way you always get the latest build when you ask for it.

    In SemVer, using a - means it's a pre-release for that version, so 0.0.1-<anything> falls between the 0.0.0 and 0.0.1 releases. The part after + is the build-info, and it's ignored for sorting, hence a good place to put git SHAs or branch names or other non-sortable tracking information.

    So with what you have used here, 0-3454e5 will appear to be newer than the next commit, if its SHA happens to start with a 2, e.g., 0-2764e1.

  25. a0s commented on Dec 6, 2020

    @a0s

    In your examples you have what appear to be two different git versions, is that right? Is one for the container image, and one for the chart?

    Yes, the app and the chart - there are two independent pieces of software.

    That way you always get the latest build when you ask for it.

    What if i don't want (and even can't imagine) ask for the latest.

    0.0.1-alpha.<build-id>+g<gitcommitsha>

    This string (after interpolation) seems too long to fit into one column of standard helm list output :)

    I always know what version (sha hash) of the app i want to install (pass it with --set args). And i always know what version of the chart i use (as @haimari described, i will always use git checkout chart && helm pack && helm upgrade .tar.gz locally in my ci/cd)

    What could go wrong?

    1. An error during regular helm upgrade. Ok, i will fix the error and try again (with another sha commit of the app - 99%) (or using --atomic instead)
    2. Manual rolling back: helm rollback <RELEASE_NAME> or deployment previous sha commit through CI/CD.

    What am i missed?

    PS To be honestly, i want to use short sha part in version and app-version for information purpose only (during helm list)

  26. TBBle commented on Dec 7, 2020

    @TBBle
    Contributor

    If it's just for information purposes, then it goes after the + in a SemVer, not -. If you never care about ordering of releases, or distributing Helm charts to anyone, and your chart or app aren't already SemVer'd, then 0+g<commitsha> is a valid SemVer (equivalent to 0.0.0).

    This is what Open Match's Helm auto-built charts do, for example; they are all currently 0.0.0-dev, and we've started looking at making that 0.0.0-dev+g<commitsha> so that if you're looking at what you have installed, you can at least tell which master build you have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions