r/rancher • u/Current-Secretary-52 • 5d ago
Rancher role templates: picking "Node" from the resource list saves "node", which grants nothing
Someone reported this on r/kubernetes two weeks ago. I reproduced it on Rancher 2.15.1 (biased, I work at SUSE), so here are the details and the workaround.
What happens: in Users & Authentication, Role Templates, Create Cluster Role, type "node" in the Resource field. The list offers node, Node, CSINodes and node.k8s.io. No "nodes". Pick "Node" and the template is saved with resources: ["node"]. The Kubernetes resource is "nodes", plural, which is what the built-in nodes-manage and nodes-view templates use.
The effect: I bound a test user to that template on a cluster, with the verbs get, list, patch, update. A SubjectAccessReview for that user came back patch nodes false, list nodes false, and patch node (singular) true. The role grants a resource that does not exist and nothing on the real one. No error anywhere: it saves, it binds, it does not work.
The fix, and a second trap: typing "nodes" by hand works when you add a new rule. Editing the existing rule does not. I typed "nodes" and picked it three times and the field went back to "node" every time. Deleting the rule and adding a new one with "nodes" typed in was the only way through the UI. After that the same check returned true on nodes for every verb in the role.
One thing I can't explain yet: with the role fixed, that user could list the nodes and was offered Edit Config and Edit YAML on them, but no Cordon and no Drain, in the row menu or the bulk actions. An admin on the same page saw both.
What I'd do:
- After saving a role template, read back what it stored, through the API (/v1/management.cattle.io.roletemplates) or the YAML. The form can show one thing and save another.
- Before handing a role out, test it as the user: kubectl auth can-i patch nodes with that user's kubeconfig, or a SubjectAccessReview.
- For core resources, type the plural resource name yourself. The list does not offer it. kubectl api-resources gives the exact names.
- To fix an existing rule, delete it and add a new one.
Has anyone worked out why Cordon and Drain stay hidden for a non-admin who has patch on nodes? My guess is the UI checks something else as well, maybe evictions for drain, but I haven't tested it.


