Skip to content

Add --take-ownership flag for install and upgrade commands#13439

Merged
scottrigby merged 6 commits intohelm:mainfrom
mayankshah1607:cli-take-ownership
Dec 19, 2024
Merged

Add --take-ownership flag for install and upgrade commands#13439
scottrigby merged 6 commits intohelm:mainfrom
mayankshah1607:cli-take-ownership

Conversation

@mayankshah1607
Copy link
Copy Markdown
Contributor

@mayankshah1607 mayankshah1607 commented Nov 12, 2024

closes #10304, closes #2730

What this PR does / why we need it:

TakeOwnership option was added to the Install and Upgrade actions in #12876. This PR allows setting this option on the CLI commands using a new --take-ownership flag

Special notes for your reviewer:

xref: #10304 (comment)

If applicable:

  • this PR contains user facing changes (the docs needed label should be applied if so)
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

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 <mayankshah1614@gmail.com>
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 12, 2024
Copy link
Copy Markdown
Member

@gjenkins8 gjenkins8 left a comment

Choose a reason for hiding this comment

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

very minor fix up of the help text please

mayankshah1607 and others added 2 commits November 19, 2024 10:03
Co-authored-by: George Jenkins <gvjenkins@gmail.com>
Signed-off-by: Mayank Shah <mayankshah1614@gmail.com>
Co-authored-by: George Jenkins <gvjenkins@gmail.com>
Signed-off-by: Mayank Shah <mayankshah1614@gmail.com>
gjenkins8
gjenkins8 previously approved these changes Nov 19, 2024
@gjenkins8 gjenkins8 added docs needed Indicates that a PR includes changes that need to be documented. Should not block a PR being merged Has One Approval This PR has one approval. It still needs a second approval to be merged. Needs v3 backport Label PRs for v4/main, which are still applicable to v3 so need a separate backport PR labels Nov 19, 2024
@gjenkins8 gjenkins8 modified the milestones: 3.17.0, v4 Nov 19, 2024
@banjoh
Copy link
Copy Markdown
Contributor

banjoh commented Dec 9, 2024

@scottrigby / @joejulian are you able to take a look at this one?

@banjoh
Copy link
Copy Markdown
Contributor

banjoh commented Dec 10, 2024

@mayankshah1607 since this PR needs to merged into v3, can you please create a new PR to dev-v3 branch with the same changes here?

Copy link
Copy Markdown
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.

This PR looks good, however with manual testing this doesn't seem to be working for upgrade, only install. I'm not sure why this would be the case, since it should work according to #12876

Can someone else reproduce this?

# create example chart
helm create foo

# create matching plain template files
helm template foo foo --output-dir foo-template
<remove all helm labels>
<remove tests dir>

# install plan manifests without helm labels or metadata
kubectl apply -f foo-template/foo/templates/

# it makes sense that this wouldn't work
$ helm upgrade foo foo/ --take-ownership
Error: UPGRADE FAILED: "foo" has no deployed releases

# from this PR it seems this should work, but doesn't
$ helm upgrade --install foo foo/ --take-ownership
Error: Unable to continue with install: ServiceAccount "foo" in namespace "default" exists and cannot be imported into the current release: invalid ownership metadata; label validation error: missing key "app.kubernetes.io/managed-by": must be set to "Helm"; annotation validation error: missing key "meta.helm.sh/release-name": must be set to "foo"; annotation validation error: missing key "meta.helm.sh/release-namespace": must be set to "default"

# this works
$ helm install foo foo/ --take-ownership
<expected output>
$ helm ls  
NAME	NAMESPACE	REVISION	UPDATED                             	STATUS  	CHART    	APP VERSION
foo 	default  	1       	2024-12-11 00:21:59.727628 -0500 EST	deployed	foo-0.1.0	1.16.0  

PS I'm also updating the description to point to the correct PR (#12876 not #13130), and adding closing keywords to related issues (#10304 and #2730).

Copy link
Copy Markdown
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.

For upgrade --install to work, we also need to add this:

diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go
index 1fe793a92..75788459b 100644
--- a/cmd/helm/upgrade.go
+++ b/cmd/helm/upgrade.go
@@ -151,6 +151,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
                                        instClient.Labels = client.Labels
                                        instClient.EnableDNS = client.EnableDNS
                                        instClient.HideSecret = client.HideSecret
+                                       instClient.TakeOwnership = client.TakeOwnership
 
                                        if isReleaseUninstalled(versions) {
                                                instClient.Replace = true

Signed-off-by: Mayank Shah <mayankshah1614@gmail.com>
@mayankshah1607
Copy link
Copy Markdown
Contributor Author

Thanks @scottrigby , I've updated the PR

@mayankshah1607
Copy link
Copy Markdown
Contributor Author

@mayankshah1607 since this PR needs to merged into v3, can you please create a new PR to dev-v3 branch with the same changes here?

@banjoh can I just change the base of this PR? Or does it need to be created against both main and dev-v3?

@banjoh
Copy link
Copy Markdown
Contributor

banjoh commented Dec 11, 2024

@mayankshah1607 since this PR needs to merged into v3, can you please create a new PR to dev-v3 branch with the same changes here?

@banjoh can I just change the base of this PR? Or does it need to be created against both main and dev-v3?

You'll need 2 separate PRs. Changing the PR base will mean your changes go to one branch and not the other.

@mayankshah1607
Copy link
Copy Markdown
Contributor Author

Running the tests locally, everything seems to pass. I'm not sure what the issue is, but I pushed a fix anyway.. not sure if that'll do.

Signed-off-by: Mayank Shah <mayankshah1614@gmail.com>
@pull-request-size pull-request-size bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 13, 2024
@mayankshah1607
Copy link
Copy Markdown
Contributor Author

Ok, tests are fixed. PR against dev-v3 branch is ready: #13531

Copy link
Copy Markdown
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.

@mayankshah1607 test fix looks good. Nice work 👏

@scottrigby scottrigby removed the Has One Approval This PR has one approval. It still needs a second approval to be merged. label Dec 19, 2024
@scottrigby scottrigby merged commit 9c0d3c4 into helm:main Dec 19, 2024
@gjenkins8 gjenkins8 removed the Needs v3 backport Label PRs for v4/main, which are still applicable to v3 so need a separate backport PR label Dec 19, 2024
@lucasfcnunes
Copy link
Copy Markdown

@yxxhero take a look at this. Helmfile would greatly benefit from it.

@yxxhero
Copy link
Copy Markdown
Member

yxxhero commented Dec 20, 2024

@yxxhero take a look at this. Helmfile would greatly benefit from it.

ok got it

@atsu85
Copy link
Copy Markdown

atsu85 commented Jan 24, 2025

if i understand correctly, then official documentation isn't currently updated with this new flag?

Seems just the feature i was looking for - very good timing regarding the release of this feature :)

@karthikmanam karthikmanam mentioned this pull request Mar 12, 2025
3 tasks
nacx pushed a commit to envoyproxy/ai-gateway that referenced this pull request Oct 24, 2025
**Description**

As discussed in this slack thread:
https://envoyproxy.slack.com/archives/C07Q4N24VAA/p1761235915409479, we
want to separate the crd chart and the resources chart. (option 1 of the
proposed approaches in
#1186)

**Related Issues/PRs (if applicable)**

#1186

**Special notes for reviewers (if applicable)**

Added an extra note on upgrade when done from a previous install of
ai-gateway-helm helm chart alone. it uses the `--take-ownership` flag
while upgrading: helm/helm#13439,
https://helm.sh/docs/helm/helm_upgrade/#options

Open Question:
- Should we rename `ai-gateway-helm` to `ai-gateway-resources-helm`? It
would be more consistent but upgrade is slightly trickier

cc: @mathetake @johnugeorge @nagar-ajay

Signed-off-by: sailesh duddupudi <saileshradar@gmail.com>
missBerg pushed a commit to missBerg/ai-gateway that referenced this pull request Dec 20, 2025
…1431)

**Description**

As discussed in this slack thread:
https://envoyproxy.slack.com/archives/C07Q4N24VAA/p1761235915409479, we
want to separate the crd chart and the resources chart. (option 1 of the
proposed approaches in
envoyproxy#1186)

**Related Issues/PRs (if applicable)**

envoyproxy#1186

**Special notes for reviewers (if applicable)**

Added an extra note on upgrade when done from a previous install of
ai-gateway-helm helm chart alone. it uses the `--take-ownership` flag
while upgrading: helm/helm#13439,
https://helm.sh/docs/helm/helm_upgrade/#options

Open Question:
- Should we rename `ai-gateway-helm` to `ai-gateway-resources-helm`? It
would be more consistent but upgrade is slightly trickier

cc: @mathetake @johnugeorge @nagar-ajay

Signed-off-by: sailesh duddupudi <saileshradar@gmail.com>
Signed-off-by: Erica Hughberg <erica.sundberg.90@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs needed Indicates that a PR includes changes that need to be documented. Should not block a PR being merged size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

helm overwrite existing resources deployed by non-helm Proposal: helm commandeer

8 participants