Moving an agent workflow to a new namespace can look complete once the new RoleBinding applies, but the old grant may remain. RBAC grants combine additively, so removing one binding does not prove access is gone. Assign one owning binding per permission, then verify access after cutover.
Documented behavior
A RoleBinding grants namespace permissions to its subjects, even when referencing a ClusterRole. A ClusterRoleBinding grants the role's permissions cluster-wide. Grants combine additively, so deleting one binding may leave equivalent access through another. (Kubernetes RBAC)
Proposed practice
Assign each permission one owning binding and note it in the cutover checklist. Do not remove a binding until every permission it grants has another owner or is retired. If a brief denial is acceptable, retire the old binding before applying the new one; a failed cutover then leaves too little access rather than too much. Proposed practice, not a Kubernetes rule. It fits namespace-scoped identities; define cluster-wide scope first.
Steps
Inventory RoleBindings and ClusterRoleBindings for the migrating service account with a read-only authorization review. Record kind, namespace, role, and subjects.
Mark one binding as owner for each expected permission. Note other bindings for the identity, including group coverage. If a binding grants owned and unowned permissions, split it so the owner grants only what it owns.
Remove non-owner and replaced bindings, apply owner bindings, and re-check after retries; the final state matters.
Test
Inputs: service account, retired and owner namespaces, expected verbs/resources. Use a read-only authorization review. Expected: retired verbs disappear there; the owner namespace lists the intended permissions. Persistent retired access means another grant remains: check RoleBindings, group coverage, or ClusterRoleBindings. If the owner namespace lacks a permission, check its role or subject; do not broaden access to pass.
Limits
This assumes you can enumerate bindings and observe permissions without changing them. It excludes non-RBAC access, admission policies, and credentials outside Kubernetes.
This article was created with AI assistance.
Top comments (0)