You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
proposal: handle immutable resources on update #7082
Error: UPGRADE FAILED: failed to replace object: RoleBinding.rbac.authorization.k8s.io "tmp" is invalid: roleRef: Invalid value: rbac.RoleRef{APIGroup:"rbac.authorization.k8s.io", Kind:"ClusterRole", Name:"edit"}: cannot change roleRef
The expected result would be that helm replaces the role binding due to the --force flag.
The problem was already discussed in #6468 but it was mentioned that --force should work, so I am reporting this as new issue.
Reacted by Dmytro Kabachenko, Adam Noll, Austin Orth, Eric Welch, Anton, Bruno Galindro da Costa, Elliott Richerson, Nicholas Steicke, Chris Duong, rimusz and 42 more
Helm 2 used to delete and re-install the resource on a PATCH failure, which led to a lot of cases where things like spurious client timeouts causing the patch to fail would delete the resource... Not exactly what you'd call a great experience.
In Helm 3, the behaviour of --force was refactored to better align with its intent: to force a PUT operation (an overwrite) when the user requests. This allows the user to bypass the three-way merge patch strategy, forcing idempotency and overwriting the object currently maintained by Helm in the cluster.
If there are certain objects that cannot be replaced, we can look up the expected behaviour from Kubernetes' side of things. In this particular case, certain fields present in a role binding cannot be changed/replaced once they've been created as @zwwhdls rightly pointed out. So this seems intentional from Kubernetes' point of view. If you want to modify the role binding, my suggestion would be to delete it from the cluster first before upgrading.
@bacongobbler thanks for explaining this difference between Helm 2 and Helm 3. I agree that the way Helm 3 works with --force updates is very good for most use cases, since no unnecessary recreation of resources happens, which could cause trouble.
However, I assume that it will be problematic for some resources, that no --force update is possible anymore without manual intervention. So I would suggests to extend helms behavior on --force updates with a fallback to delete and create, when it receives a 422 response on the PUT request. This would then still not cause any unnecessary re-creations but would still make sure all resources can be update via Helm --force.
To illustrate, why I think this would be important, I would like to explain a little more detail why updating a roleRef is a standard use case.
When developing a chart with a deployment that requires a service account with certain permissions, I usually create three objects in the template (ServiceAccount, Role, RoleBinding):
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "my-chart.fullname" . }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "my-chart.fullname" . }}
rules:
- verbs
- get
# ...
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "my-chart.fullname" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ include "my-chart.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ include "my-chart.fullname" . }}
namespace: {{ .Release.Namespace }}
So if someone likes to change the "my-chart.fullname" on update providing e.g. a fullnameOverride this will cause changing the roleRef.
I would assume that there are more Kubernetes objects, where the change from delete/create to update (PUT) will cause some surprises, so I would be interested what you @zwwhdls and @bacongobbler think about a fallback to delete/create on update failure (422)?
Certainly one could keep the "recreate" strategy separated from the force flag and let the user decide.
I could think of adding a recreate flag in the flowing alternative ways:
--recreate always does a delete and create and thus is an alternative to the standard upgrade (PATCH) and the --force upgrade (PUT).
--recreate implies --force and tries PUT first and does a recreate on failure.
--recreate tries PATCH or PUT (if --force was specified as well) and does a recreate on failure.
I would propose option 3, since it is the most flexible one and gives the user most control. Option 1. does not seem to make sense, since I cannot imagine a case where deletion of non conflicting resources would pre preferable (in this case one could just delete the entire release and re-install it).
For option 2 and 3 it needs to be decided, if recreation should be attempted only on status 422 or if there are other status codes, where the recreate attempt makes sense.
I would like to hear your thoughts and if the maintainers like the idea of adding a recreate fallback strategy I can try to find time for proposing a PR.
Reacted by Tat Chiu Leung, Kellin, Oleksandr Vorona, Lucas Schill, nlgntr, Ryan Peck, Andreas Brehmer, yelhouti, André Bauer, Alexander Sauerbier and 7 more
Option 3 gives us greatest flexibility but I think user already understands why --recreate is needed in the first place, thus I believe option 2 covers most scenarios.
I think option 1 should be implemented. There may be cases where someone wants to recreate every object similar to how --recreate-pods worked in Helm 2. Less ambiguity between feature flags is always better for the end user, anyways.
@bacongobbler least ambiguity of flags is certainly preferable. But option 1 would resemble the behaviour of helm delete followed by helm install. So option 1 would not add a real new feature. To me option 3 would be least unambiguous. However, one might chose a different name than --recreate, maybe something like helm upgrade --immutable.
I'm concerned about the approach of "if A fails, then B". This was the trap we fell into with Helm 2's old --force behaviour: it deleted the resource and re-created it only if the patch failed. Many users were confused about the ambiguity of the flag's implementation. On their end, sometimes the behaviour was triggered, and sometimes it didn't. This caused the deletion and recreation behaviour to be inconsistent, and in many cases disrupting application traffic. Many users became wary of the flag because of its reliance on a PATCH operation's failure. While you and I may understand the behaviour, it's difficult to convey to others how the internals of Helm works at a broad level.
This is why I believe making the behaviour more explicit is desired: it's a destructive action, and there's no ambiguity.
But option 1 would resemble the behaviour of helm delete followed by helm install. So option 1 would not add a real new feature.
I'd argue the opposite here: users have been asking for a feature flag that performs the same behaviour as helm delete --keep-history && helm install --replace. A "one-stop shop" for CI/CD workflows. That's why flags like helm upgrade --install --dependency-update exist today. :)
Explicit resource planning is better than standard immutable k8s approach. Plan - destroy - create - apply. K8S architects way of doing this is raising eybrows.
Could the community owner pay special attention to this issue? Unresolvable conflicts are inevitable for projects that have been running for a long time.
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.
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.
Helm 4 design is finally correct. Focused on modernizing the underlying architecture, it added WebAssembly (Wasm) support for plugins, native Kubernetes Server-Side Apply, and content-based caching while maintaining backward compatibility for existing charts.
Although instead of doing good software a lot of engineers are conducting resarch/investigations using code repositories in a quite weird way. It's all not necessary at all with correct planning and prediction of what will be going on.
Activity
zwwhdls commentedon Nov 27, 2019
Hi,
I have tried for this. And I found in code here: https://github.com/helm/helm/blob/master/pkg/kube/client.go#L393. It means that when "--force" exits, attempt to call apiserver for PUT resource api. Besides, when "--force" doesn't exits, attempt to call apiserver for PATCH resource api.
When I tried the PUT api to change role to "edit" in your yaml, I got the same error:

I guess this field in rolebinding can't be changed in k8s side. So, I think it's the wrong way to change roleRef and Helm did the right thing.
bacongobbler commentedon Nov 28, 2019
Helm 2 used to delete and re-install the resource on a PATCH failure, which led to a lot of cases where things like spurious client timeouts causing the patch to fail would delete the resource... Not exactly what you'd call a great experience.
In Helm 3, the behaviour of
--forcewas refactored to better align with its intent: to force a PUT operation (an overwrite) when the user requests. This allows the user to bypass the three-way merge patch strategy, forcing idempotency and overwriting the object currently maintained by Helm in the cluster.If there are certain objects that cannot be replaced, we can look up the expected behaviour from Kubernetes' side of things. In this particular case, certain fields present in a role binding cannot be changed/replaced once they've been created as @zwwhdls rightly pointed out. So this seems intentional from Kubernetes' point of view. If you want to modify the role binding, my suggestion would be to delete it from the cluster first before upgrading.
Hope this helps!
dastrobu commentedon Dec 2, 2019
@bacongobbler thanks for explaining this difference between Helm 2 and Helm 3. I agree that the way Helm 3 works with --force updates is very good for most use cases, since no unnecessary recreation of resources happens, which could cause trouble.
However, I assume that it will be problematic for some resources, that no --force update is possible anymore without manual intervention. So I would suggests to extend helms behavior on --force updates with a fallback to delete and create, when it receives a 422 response on the PUT request. This would then still not cause any unnecessary re-creations but would still make sure all resources can be update via Helm --force.
To illustrate, why I think this would be important, I would like to explain a little more detail why updating a
roleRefis a standard use case.When developing a chart with a deployment that requires a service account with certain permissions, I usually create three objects in the template (ServiceAccount, Role, RoleBinding):
So if someone likes to change the
"my-chart.fullname"on update providing e.g. afullnameOverridethis will cause changing theroleRef.I would assume that there are more Kubernetes objects, where the change from delete/create to update (PUT) will cause some surprises, so I would be interested what you @zwwhdls and @bacongobbler think about a fallback to delete/create on update failure (422)?
bacongobbler commentedon Dec 2, 2019
it might be worth considering a new feature flag that forces a deletion of the object on an upgrade. Something like
--recreate, perhaps.dastrobu commentedon Dec 4, 2019
Certainly one could keep the "recreate" strategy separated from the force flag and let the user decide.
I could think of adding a recreate flag in the flowing alternative ways:
--recreatealways does a delete and create and thus is an alternative to the standard upgrade (PATCH) and the--forceupgrade (PUT).--recreateimplies--forceand tries PUT first and does a recreate on failure.--recreatetries PATCH or PUT (if--forcewas specified as well) and does a recreate on failure.I would propose option 3, since it is the most flexible one and gives the user most control. Option 1. does not seem to make sense, since I cannot imagine a case where deletion of non conflicting resources would pre preferable (in this case one could just delete the entire release and re-install it).
For option 2 and 3 it needs to be decided, if recreation should be attempted only on status 422 or if there are other status codes, where the recreate attempt makes sense.
I would like to hear your thoughts and if the maintainers like the idea of adding a recreate fallback strategy I can try to find time for proposing a PR.
tatchiuleung commentedon Dec 5, 2019
Option 3 gives us greatest flexibility but I think user already understands why
--recreateis needed in the first place, thus I believe option 2 covers most scenarios.[-]helm upgrade --force fails on changing roleRef.[/-][+]proposal: `helm install/upgrade --recreate`[/+]bacongobbler commentedon Dec 6, 2019
re-labeled and re-titled the issue to reflect the ask.
bacongobbler commentedon Dec 13, 2019
I think option 1 should be implemented. There may be cases where someone wants to recreate every object similar to how
--recreate-podsworked in Helm 2. Less ambiguity between feature flags is always better for the end user, anyways.dastrobu commentedon Dec 16, 2019
@bacongobbler least ambiguity of flags is certainly preferable. But option 1 would resemble the behaviour of
helm deletefollowed byhelm install. So option 1 would not add a real new feature. To me option 3 would be least unambiguous. However, one might chose a different name than--recreate, maybe something likehelm upgrade --immutable.bacongobbler commentedon Dec 16, 2019
I'm concerned about the approach of "if A fails, then B". This was the trap we fell into with Helm 2's old
--forcebehaviour: it deleted the resource and re-created it only if the patch failed. Many users were confused about the ambiguity of the flag's implementation. On their end, sometimes the behaviour was triggered, and sometimes it didn't. This caused the deletion and recreation behaviour to be inconsistent, and in many cases disrupting application traffic. Many users became wary of the flag because of its reliance on a PATCH operation's failure. While you and I may understand the behaviour, it's difficult to convey to others how the internals of Helm works at a broad level.This is why I believe making the behaviour more explicit is desired: it's a destructive action, and there's no ambiguity.
I'd argue the opposite here: users have been asking for a feature flag that performs the same behaviour as
helm delete --keep-history && helm install --replace. A "one-stop shop" for CI/CD workflows. That's why flags likehelm upgrade --install --dependency-updateexist today. :)[-]proposal: `helm install/upgrade --recreate`[/-][+]proposal: `helm upgrade --recreate`[/+]79 remaining items
ericblackburn commentedon Mar 4, 2026
remove stale
antonakv commentedon Mar 4, 2026
Update can be handled with recreate. It's the best.
antonakv commentedon Mar 4, 2026
Explicit resource planning is better than standard immutable k8s approach. Plan - destroy - create - apply. K8S architects way of doing this is raising eybrows.
silence-coding commentedon Mar 11, 2026
Could the community owner pay special attention to this issue? Unresolvable conflicts are inevitable for projects that have been running for a long time.
github-actions commentedon Jun 10, 2026
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.
lucasfcnunes commentedon Jun 10, 2026
Not stale.
github-actions commentedon Sep 10, 2026
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.
antonakv commentedon Sep 10, 2026
Not stale
antonakv commentedon Sep 10, 2026
Helm 4 design is finally correct. Focused on modernizing the underlying architecture, it added WebAssembly (Wasm) support for plugins, native Kubernetes Server-Side Apply, and content-based caching while maintaining backward compatibility for existing charts.
Although instead of doing good software a lot of engineers are conducting resarch/investigations using code repositories in a quite weird way. It's all not necessary at all with correct planning and prediction of what will be going on.