Skip to content

Upgrading ClusterRoleBindings #6468

Closed
Closed

Description

@ruszki

When I issue helm upgrade, and a role's reference of a ClusterRoleBinding would be changed, it fails with this error message:

UPGRADE FAILED
Error: ClusterRoleBinding.rbac.authorization.k8s.io "cluster-role-binding" is invalid: roleRef: Invalid value: rbac.RoleRef{APIGroup:"rbac.authorization.k8s.io", Kind:"ClusterRole", Name:"cluster-role"}: cannot change roleRef
Error: UPGRADE FAILED: ClusterRoleBinding.rbac.authorization.k8s.io "cluster-role-binding" is invalid: roleRef: Invalid value: rbac.RoleRef{APIGroup:"rbac.authorization.k8s.io", Kind:"ClusterRole", Name:"cluster-role"}: cannot change roleRef

I know, that roleRef in ClusterRoleBindings cannot be changed, but Helm should handle the recreation of such objects.

Output of helm version:

Client: &version.Version{SemVer:"v2.14.3", GitCommit:"0e7f3b6637f7af8fcfddb3d2941fcc7cbebb0085", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.14.3", GitCommit:"0e7f3b6637f7af8fcfddb3d2941fcc7cbebb0085", GitTreeState:"clean"}

Output of kubectl version:

Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.3", GitCommit:"2d3c76f9091b6bec110a5e63777c332469e0cba2", GitTreeState:"clean", BuildDate:"2019-08-19T11:05:50Z", GoVersion:"go1.12.9",
Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.3", GitCommit:"2d3c76f9091b6bec110a5e63777c332469e0cba2", GitTreeState:"clean", BuildDate:"2019-08-19T11:05:50Z", GoVersion:"go1.12.9",
Compiler:"gc", Platform:"linux/amd64"}

Cloud Provider/Platform (AKS, GKE, Minikube etc.):
I use a cluster installed with kubespray.

Activity

  1. bacongobbler commented on Sep 23, 2019

    @bacongobbler
    Member

    In this case, Helm is doing the right thing. The user has requested an update to a resource in which it cannot be updated.

    If you want to force an update, it is up to the user to delete the resource from the cluster before performing the update. You can also try issuing a helm upgrade --force, which in the case of an error will delete all resources and force a recreation.

    Does that help?

  2. ruszki commented on Sep 24, 2019

    @ruszki
    Author

    I disagree. Helm charts are on a higher level of abstraction than Kubernetes objects. Users of Helm charts shouldn't know what is the underlying structure, except if it's absolutely necessary, and a simple helm upgrade shouldn't be this problematic.
    On the other hand, chart writers should know this, and should prepare to make their charts upgradable. This problem can be mitigated with hooks, but, in my view, this is not a nice solution. If a chart developer wants to rename a role, then it will need a sizeable boilerplate. I understand, that it restricted because security risks in Kubernetes (or something else, I don't know the exact reasoning behind this), but helm upgrade isn't restricted in this way, it's just more difficult to achieve this. Solving this by Helm would make chart writers life easier, not the end users.

  3. squillace commented on Sep 24, 2019

    @squillace
    Contributor

    @ruszki wait... so, helm is correctly reporting that it can't delete the resource, but you think it should, correct?

  4. ruszki commented on Sep 25, 2019

    @ruszki
    Author

    @squillace Sort of. Sorry, I wasn't clear before. This meant to be a feature request.
    Kubernetes can't modify ClusterRoleBindings by changing the name of the referenced role. So, Helm can't do either. However, in my opinion, it should be possible during helm upgrade with resources already handled by Helm, and part of the same release. Kubernetes doesn't know anything about releases, and helm upgrades, so the only reasonable place to solve this is in Helm. Were there decisions which block this kind of feature?

  5. bacongobbler commented on Sep 25, 2019

    @bacongobbler
    Member

    Were there decisions which block this kind of feature?

    Yes, this was an intentional design decision in Helm. Users need to either manually intervene or use the --force flag when they want to opt into destructive actions such as re-creating the object when they want to change an immutable field.

    Consider this example: a user has deployed a chart with a Deployment. They wish to update the selector labels, which is something the Kubernetes API considers to part of the Deployment object that cannot be modified. In order to make changes, one must delete the object in order to update the selector labels. This is very similar to your ask in your first comment, only with ClusterRoleBindings instead.

    There's two approaches Helm could've taken here, one of which we decided to go with:

    1. Helm notices that the APIServer denied the PATCH request, forcing a recreation of the Deployment.

    2. Helm notices that the APIServer denied the PATCH request, erroring out with an informative message that the upgrade was denied. The user can then manually intervene with an override.

    The first option can cause unintended side-effects. Forcing the re-creation of a Deployment destroys all pods the Deployment was managing. The same thing happens with CRDs; if you remove a CRD, all CRs registered with that GVK (group/version/kind) will also be deleted.

    The second option is less disruptive. The user now understands that the upgrade cannot go through unless they manually intervene using an override such as by deleting the object before upgrading, or by using the --force flag. This gives the user the power to decide that this destructive action is OK and they wish to opt in.

    Many community members expressed that the disruption of production traffic during an upgrade as the default behaviour is a non-goal. This is why we chose to go with the second option.

    Therefore, your options in your scenario are to either delete the object before performing the upgrade, or use the --force flag.

    Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions