Skip to content

Resource ownership between charts #2388

Closed

Description

@helgi

I have a scenario where 2 charts installed via helm both think they own identically named resource (f.ex. secret), which generally isn't a problem until you want to helm delete one of them.

Lets take a simple example: Chart dingo has a Secret named db-access and then later a new cool chart named baby is created, which also happens to have a Secret named db-access. Both are in the same namespace.

helm status on both of the releases tells me they have db-access however when I run helm delete --purge dingo I do not see the db-access after running helm status baby, it is as if the dingo ate the baby resource... so to speak.

What is the expected behaviour and potential fixes?

Few things come to mind:

  • Only remove resources that are not in other releases
  • Installation fails if there are identically named resources (of the same resource type) in a different release
  • A flag (or flags) to support either or both of the above scenarios, or the inverse

Activity

  1. helgi commented on May 4, 2017

    @helgi
    ContributorAuthor
    helm version
    Client: &version.Version{SemVer:"v2.4.1", GitCommit:"46d9ea82e2c925186e1fc620a8320ce1314cbb02", GitTreeState:"clean"}
    Server: &version.Version{SemVer:"v2.4.1", GitCommit:"46d9ea82e2c925186e1fc620a8320ce1314cbb02", GitTreeState:"clean"}
    
  2. krancour commented on May 5, 2017

    @krancour
    Contributor

    This seems to me like a glaring deficiency in the charts themselves-- both of them. Ideally, all resources in a chart are prefixed with the chart name and release name specifically to avoid these sort of naming conflicts in the event that two releases share a namespace.

  3. krancour commented on May 5, 2017

    @krancour
    Contributor

    In fact, when you helm new <name>, the scaffolding for your new chart even includes a template partial that's intended to be used... and re-used... and re-used ad-nauseum throughout the chart to make prefixing resource names with chart name and release name quasi-easy.

  4. jchauncey commented on May 5, 2017

    @jchauncey

    The problem with that thought though is that there is no real way to enforce that model against the chart. So if we allow developers to create charts that are used to deploy their applications there are bound to be naming collisions at some point. I think having a better linting system to enforce rules would be a good first step.

    see #1495

  5. helgi commented on May 5, 2017

    @helgi
    ContributorAuthor

    @krancour when you use words like ideally and intended and that using chart name and release is a recommendation at the best of times, not a requirement or enforced, then this is not a deficiency in the chart :)

    Now, my question was around expected behaviour - Is the answer here that unless I use the recommended partials and naming conventions then Helm will not able to understand it has more than 1 package that owns the same resource within the same namespace?

    I do think my proposal(s) above are pretty "okay" for a solution, even if they are hidden behind flags. A package manager that can help resolve issues via a) not messing with files defined by 2 or more packages b) prevents installation of identically named resources c) a combo there off, leaving it up to the end user which to support/use.

    At the end of the day, yes, I can fix the charts to not have identically named resources and make sure all charts are rolled out at the same time, etc etc but that was not my point here - I was attempting to bring up a problem which will no doubt surprise others in the future, if the naming conventions are not enforced going forward.

    @krancour what else can I do to convince you this is a tooling issue and not a chart deficiency, per se.

  6. krancour commented on May 5, 2017

    @krancour
    Contributor

    @helgi no need to convince me. I wasn't trying to convince you, per se, that the tooling couldn't / shouldn't be better in this regard, but only that there are some established best practices that perhaps were not observed here. The Go programming language isn't at fault for nil pointer dereferences. Your code is. Likewise, Helm charts can be poorly written in a way that will expose undesired behavior.

    I agree with what @jchauncey said about improved chart linting possibly being one solution.

  7. thomastaylor312 commented on May 6, 2017

    @thomastaylor312
    Contributor

    @jchauncey and @helgi, do you both think that an implementation of #1495 would cover this? If it is covered, we can probably close this. If not, we can probably create another issue with a specific feature request.

  8. atombender commented on May 7, 2017

    @atombender

    I think this is major deficiency in Helm, because it means there's no way to ensure that charts are fully encapsulated. Helm aims to be a high-level tool (treat charts as atomic units), but approaches the problem with a fairly low-level mechanism (Kubernetes resources).

    We ended up with two tactics to enforce uniqueness. First, we require that all of ours apps accept a name template variable and that the app uses this as the name or prefix for all its resources. So, for example, if an app has a deployment.

    kind: Deployment
    metadata:
      name: {{ name }}

    and if you have several services, you have to rely on the name to prefix:

    kind: Service
    metadata:
      name: {{ name }}-web
    

    The second part is to use annotations. We require that all apps take two template variables labels and annotations that must be injected into metadata.labels and metadata.annotations respectively. The labels are important for resource targeting (e.g. services), obviously. Annotations let us track what resources belong to an app, as well as things like git versions and who deployed things.

    Of course, manually specifying all of this stuff would be a nightmare, so we wrap Helm using a small deployment tool specific to our company. One benefit is that we can deploy multiple concurrent versions (e.g. for A/B testing, blue/green deployment or release canaries) of an app and know that releases don't tread on each others' toes.

  9. fejta-bot commented on Dec 24, 2017

    @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.

    Prevent issues from auto-closing with an /lifecycle frozen comment.

    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

  10. fejta-bot commented on Jan 23, 2018

    @fejta-bot

    Stale issues rot after 30d of inactivity.
    Mark the issue as fresh with /remove-lifecycle rotten.
    Rotten issues close after an additional 30d of inactivity.

    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 rotten
    /remove-lifecycle stale

  11. fejta-bot commented on Feb 22, 2018

    @fejta-bot

    Rotten issues close after 30d of inactivity.
    Reopen the issue with /reopen.
    Mark the issue as fresh with /remove-lifecycle rotten.

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

  12. helgi commented on Mar 22, 2018

    @helgi
    ContributorAuthor

    /reopen

  13. thomastaylor312 commented on Mar 23, 2018

    @thomastaylor312
    Contributor

    @helgi This is labeled as a question and should probably be closed. Should this be relabeled and kept open?

  14. helgi commented on Mar 23, 2018

    @helgi
    ContributorAuthor

    @thomastaylor312 I do not consider this a question but rather a problem/bug with how Helm lets multiple charts claim ownership over the same resource.

  15. thomastaylor312 commented on Apr 2, 2018

    @thomastaylor312
    Contributor

    Ok, I will relabel this.

  16. added
    bug
    and removed on Jun 5, 2018
  17. Jamstah commented on Nov 26, 2019

    @Jamstah

    What I would really like to see here is a model for shared ownership. Sometimes there really is a need for a helm chart to install a cluster-level resource of a given name, one and only one. In those cases, the chart cannot then also be installed twice.

    If this resource could somehow be tagged as "shared" between two releases, and to fail the second install if it tries to modify the resource, and to only actually delete it when there are no shared owners left, that would be awesome.

    I get that this doesn't fit the helm model. How should this problem be addressed in a helm world?

  18. ysaakpr commented on Feb 13, 2020

    @ysaakpr

    In my case, we use the service name without any release name in the helm. When we created another installation using a new deployment process, the service got shared between two helm deployments, and now I can't delete the other one deployment safely.

    What would be the suggested way in this case, to safely delete the old helm release.

  19. bacongobbler commented on May 14, 2020

    @bacongobbler
    Member

    fixed with #7649. Two releases can no longer share ownership over the same resource.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions