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

Allow install, update action to adopt existing resources (sdk only) #12876

Merged
merged 1 commit into from
Aug 14, 2024

Conversation

manno
Copy link
Contributor

@manno manno commented Mar 13, 2024

We use the Helm SDK in a GitOps operator and need more control over existing resources. We considered patching them with the Helm labels and annotations, but that would mean another update request per resource. Furthermore it seems wrong to apply Helm labels to resources, before the chart has actually been applied to them.

The PR introduces a new option TakeOwnership. If TakeOwnership is set, existing resources will be adopted, overwritten, etc. when installing or updating. Helm will not check for labels.

If it is not set, Helm behaves like before: adoption is only possible if they existing resources have the right labels
(managed-by) and annotations (release-name, ...).

Allow the SDK actions to adopt existing resources. This allows install
and update to overwrite resources. If TakeOwnership is not set, adoption
is only possible if they existing resources have the right labels
(managed-by) and annotations (release-name, ...).

Signed-off-by: Mario Manno <[email protected]>
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 13, 2024
@mattfarina mattfarina added this to the 3.16.0 milestone Aug 8, 2024
@mattfarina mattfarina added the Has One Approval This PR has one approval. It still needs a second approval to be merged. label Aug 8, 2024
Copy link
Member

@scottrigby scottrigby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @manno 👍

This could be a useful feature to bring into the CLI install and upgrade CLI commands too at some point.

@mattfarina mattfarina merged commit c261d06 into helm:main Aug 14, 2024
5 checks passed
scottrigby added a commit to scottrigby/helm that referenced this pull request Aug 14, 2024
golangci-lint passed when last commit was made on helm#12876, but has since failed.
This is probably because the linter has since updated.

I ran locally with the same version of golangci-lint we run in GH Actions, and
this is the only error now (an additional linting error in
pkg/action/package.go since helm#12876 has already been fixed.

```sh
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.58.1

./bin/golangci-lint run pkg/action/...

./bin/golangci-lint run ./...
```

we should be good now.

Signed-off-by: Scott Rigby <[email protected]>
mayankshah1607 added a commit to mayankshah1607/helm that referenced this pull request Nov 12, 2024
The `TakeOwnership` setting was added to the install and upgrade actions in
helm#12876

This PR allows setting this option on install and upgrade via the CLI
using a --take-ownership flag

Signed-off-by: Mayank Shah <[email protected]>
godhanipayal pushed a commit to godhanipayal/helm that referenced this pull request Jan 8, 2025
The `TakeOwnership` setting was added to the install and upgrade actions in
helm#12876

This PR allows setting this option on install and upgrade via the CLI
using a --take-ownership flag

Signed-off-by: Mayank Shah <[email protected]>
@atsu85
Copy link

atsu85 commented Jan 28, 2025

@manno, thanks for implementing this feature!

PR description:

If TakeOwnership is set, existing resources will be adopted, overwritten, etc. when installing or updating.

Based on this i would assume that the existing resource should get overwritten/updated based on values and chart templates fused for the Helm relase, but it seems that it is not the case? As i understand with TakeOwnership helm install/upgrade won't fail if helm release name and namespace don't match what's present on existing resource annotations, but the existing resource won't get updated by helm install/upgrade? That doesn't seem to match what you wrote in the PR description!?

If i understand correctly then TakeOwnership works basically the same way as manually adding release name/namespace annotations (or changing them in case of taking ownership of k8s resources from other helm release) before running helm install/upgrade with new release name?

I'm wondering if there is a way to make helm actually update the existing resource (without removing and re-creating it) with new content instead of silently ignoring changes that should be applied based on values and chart templates?

@atsu85
Copy link

atsu85 commented Feb 20, 2025

hi @manno, could you share your ideas/thoughts/insights about my question/comment?

@manno
Copy link
Contributor Author

manno commented Feb 20, 2025

If i understand correctly then TakeOwnership works basically the same way as manually adding release name/namespace annotations (or changing them in case of taking ownership of k8s resources from other helm release) before running helm install/upgrade with new release name?

Yes, TakeOwnership only ignores the existing labels. Updating the resource is still handled by Helm as usual. This PR didn't change how Helm updates, it just allowed Helm to update existing resources.

We found out that updating (three way merge) doesn't work for custom resources, see #13439

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Has One Approval This PR has one approval. It still needs a second approval to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants