Skip to content

Apply helm hook and release labels to hook resources #6365

Closed

Description

@jlegrone

Applying a standard set of labels to all resources managed by helm hooks will make it easier to implement log trailing and cleanup functionality.

Any resource created by a hook should have its labels patched to include the hook and release name:

hooks.helm.sh/[HOOK NAME]: "true"
app.kubernetes.io/instance: "[RELEASE NAME]"

For example, a Job with the pre-install and pre-upgrade hook would include the following labels for a release named foo:

hooks.helm.sh/pre-install: "true"
hooks.helm.sh/pre-upgrade: "true"
app.kubernetes.io/instance: "foo"

A solution for imperatively deleting hook resources is needed that does not involve re-executing the hook (a la the Helm 2test --cleanup flag). This will allow us to implement a generic cleanup subcommand that simply selects resources to delete by hook and release label, and works across resources created by multiple revisions of a chart.

Activity

  1. added
    v3.x
    on Sep 6, 2019
  2. added this to the 3.0.0 milestone on Oct 24, 2019
  3. bacongobbler commented on Oct 28, 2019

    @bacongobbler
    Member

    After further review of this proposal, it looks like it won't break backwards compatibility if we implemented this in a future Helm 3 release. Certain hooks just won't have the required annotations out of the gate, which can be worked around.

    Is there a particular reason this has to get in before 3.0 is released, or can we remove the milestone and it can be implemented when the need arises? Basically I'm trying to determine if we need to hold off on releasing 3.0 until someone gets to this or not. Thanks!

  4. jlegrone commented on Oct 28, 2019

    @jlegrone
    MemberAuthor

    If we want to use app.kubernetes.io/instance: "[RELEASE NAME]" then this would be a breaking change for any charts that currently set app.kubernetes.io/instance to something other than the recommended value. If we're okay making that change after 3.0, or would prefer to use a different (helm.sh scoped) label, then we can wait.

    It's probably safe to add hooks.helm.sh/pre-install any time since these are helm.sh scoped, though this is also technically a breaking change.

  5. thomastaylor312 commented on Oct 28, 2019

    @thomastaylor312
    Contributor

    I am more in favor of helm.sh scoped labels, but I don't see how that would be breaking since it would just be a behavior add. Am I missing something @jlegrone?

  6. jlegrone commented on Oct 28, 2019

    @jlegrone
    MemberAuthor

    I am more in favor of helm.sh scoped labels, but I don't see how that would be breaking since it would just be a behavior add.

    We would need to error out if the chart itself adds these labels with a different value, which IMO is a breaking change. It's unlikely to happen when using helm.sh scoped labels, but app.kubernetes.io/instance may be more widely used by existing charts.

  7. thomastaylor312 commented on Oct 28, 2019

    @thomastaylor312
    Contributor

    I would consider that very unlikely if we are using helm.sh scoped labels because scoped labels are supposed to be used by specific applications, so if you are using them for some reason, that is the chart author's responsibility, so I honestly think it would be a safe add afterwards. @bacongobbler any thoughts?

  8. jlegrone commented on Oct 28, 2019

    @jlegrone
    MemberAuthor

    Right, I think the main question is whether we feel comfortable requiring app.kubernetes.io/instance to be set to a specific value in v3.1+.

  9. mattfarina commented on Oct 28, 2019

    @mattfarina
    Collaborator

    app.kubernetes.io/instance is a kind of common interface for passing around this information. Other tools can use it.

    app.kubernetes.io/instance is something that "can be" changed in the chart. It is not something we enforce being the release name nor do we have linting for that. This makes me not want to start enforcing it right before an RC. We don't know what a breaking change like this might do. People use helm in production which makes me conservative about changes like this.

    If we are using this for internal automation I would be much more in favor or a new helm.sh namespaced label. It seems to be the safer route at this point.

    Note, I'm not suggesting this is the "best" approach. Rather, I would like to be conservative and safe this late in the development cycle.

  10. modified the milestones: 3.0.0, 3.1.0 on Oct 29, 2019
  11. mattfarina commented on Oct 29, 2019

    @mattfarina
    Collaborator

    I moved this to the 3.1.0 milestone. We can implement this in a backwards compatible manner.

    We are about ready to cut the first 3.0.0 RC and have a timetable for the final release.

  12. bacongobbler commented on Jan 27, 2020

    @bacongobbler
    Member

    Hey @jlegrone and @mattfarina. Is there any update on this ticket? If so, is it okay if we remove this from the 3.1 milestone? I haven't heard any movement on this ticket since late October.

  13. bacongobbler commented on Jan 30, 2020

    @bacongobbler
    Member

    punting to 3.2.

  14. modified the milestones: 3.1.0, 3.2.0 on Jan 30, 2020
  15. modified the milestones: 3.2.0, 3.3.0 on Apr 14, 2020
  16. removed this from the 3.3.0 milestone on Jun 24, 2020
  17. bacongobbler commented on Jun 24, 2020

    @bacongobbler
    Member

    Haven't seen any movement since this was first brought up in September. Removing from the milestone. Let us know when you're ready to implement this and we can re-target the next milestone

  18. bacongobbler commented on Jun 24, 2020

    @bacongobbler
    Member
    ><> helm install prestashop stable/prestashop
    ><> echo $(k get secret prestashop -o jsonpath='{.metadata.annotations}')
    map[helm.sh/hook:pre-install]
    
  19. github-actions commented on Nov 20, 2020

    @github-actions

    This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.

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

    Staleproposalv3.x

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions