Kubernetes RBAC Explainer

Paste Role and binding YAML and read who can do what, with risky permissions flagged.

  • Free
  • No sign-up
  • Your input stays in your browser
Read in your browser, never sent
Try an example

To check a whole cluster, run this with read access and paste what it prints:

kubectl get roles,rolebindings,clusterroles,clusterrolebindings -A -o yaml

What you paste is saved in this browser so it’s here when you come back. Clear removes it.

Paste your manifests or try an example. Each subject’s access appears below in plain English, with risky grants flagged first.

Audit · Paid

Want the whole setup checked?

A review of your code, auth or AI setup, with clear findings on what to fix first.

Starts with a free 30-minute intro call, or email hello@nestedbit.com.

How Kubernetes RBAC works

Kubernetes role-based access control (RBAC) decides what each request to the API server may do. It uses four kinds of object. A Role or ClusterRole lists rules: which verbs are allowed on which resources in which API groups. A RoleBinding or ClusterRoleBinding gives a role to subjects: users, groups or ServiceAccounts.

Rules only ever add access. There’s no deny rule, so a subject can do anything that any of its bindings allows, and the only way to take access away is to remove a binding or narrow a role.

RoleBinding vs ClusterRoleBinding

  • Role with a RoleBinding: access inside one namespace.
  • ClusterRole with a RoleBinding: the same, but the role is defined once and reused in many namespaces. The binding’s namespace limits it, and cluster-scoped resources such as nodes or PersistentVolumes in the role don’t apply.
  • ClusterRole with a ClusterRoleBinding: access in every namespace, today’s and future ones, plus cluster-scoped resources and URLs such as /metrics.

Most mistakes come from reaching for a ClusterRoleBinding when the job only needs a few namespaces. A binding’s roleRef can’t be changed after it’s created: to point it at another role, delete it and create it again.

Kubernetes RBAC verbs list

Each verb matches an HTTP method on the API:

  • get: read one object (GET).
  • list: read a collection (GET). It returns every object in full, so list on Secrets reveals them all.
  • watch: stream changes to objects (GET with ?watch), also in full.
  • create: add an object (POST).
  • update: replace an object (PUT).
  • patch: change part of an object (PATCH).
  • delete: remove one object (DELETE).
  • deletecollection: remove many objects at once (DELETE on a collection).

Some verbs aren’t HTTP methods. bind and escalate on roles get around Kubernetes’ own guard against handing out more access than you hold. impersonate acts as another user, group or ServiceAccount. approve and sign work on certificate signing requests. * means every verb, including any added later.

Subresources are written resource/subresource, such as pods/log or pods/exec. resources: ["*"] covers every resource and subresource in the listed groups, and "*/scale" covers one subresource of everything. The core API group, where Pods, Secrets and Services live, is written as an empty string: apiGroups: [""].

Users, groups and ServiceAccounts

Kubernetes has no user objects. Users and groups are names your authentication sends, from client certificates or an identity provider, so who is in a group is decided outside the cluster. ServiceAccounts are the exception: each one signs in as system:serviceaccount:<namespace>:<name> and is put in the groups system:serviceaccounts and system:serviceaccounts:<namespace>.

Every signed-in identity is in system:authenticated, and requests with no credentials are in system:unauthenticated. Binding a role to either of those gives it to far more than people expect. Members of system:masters skip RBAC altogether, so no binding can limit them.

The built-in roles: view, edit, admin and cluster-admin

  • view: read most objects in a namespace, but not Secrets, Roles or RoleBindings.
  • edit: change most objects in a namespace. It can read Secrets, run pods as any ServiceAccount there, exec into pods and create ServiceAccount tokens, so it reaches the access of every account in the namespace.
  • admin: edit, plus managing Roles and RoleBindings in the namespace.
  • cluster-admin: every verb on every resource. Through a RoleBinding it’s limited to one namespace.

view, edit and admin are aggregated ClusterRoles: their rules are collected from every ClusterRole labelled rbac.authorization.k8s.io/aggregate-to-view (or -edit, -admin). Installing an operator can quietly add its custom resources to them. The explainer resolves aggregation from what you paste, and uses Kubernetes’ own definitions for built-in roles that aren’t in the paste.

Permissions that are riskier than they look

  • Reading Secrets. list and watch return their contents, not just their names.
  • Creating pods or workloads. A pod can run as any ServiceAccount in its namespace and mount any Secret there. Without Pod Security, it can reach the node.
  • pods/exec and pods/attach. A shell runs with the pod’s identity and files. get is enough over a websocket on older clusters.
  • nodes/proxy. It reaches the kubelet, which can run commands in any pod on the node, outside audit logging.
  • bind, escalate and impersonate. Each is a direct route to more access.
  • serviceaccounts/token. It mints a working token for an account.
  • Webhooks and admission policies. Changing them can see or change every object, or turn guardrails off.
  • Wildcards. * grows on its own as the cluster gains resources and verbs.

Kubernetes RBAC best practices

  1. Bind in namespaces. Prefer RoleBindings, and keep ClusterRoleBindings for the few things that need the whole cluster.
  2. Name verbs and resources. Avoid * in roles you write.
  3. Give each workload its own ServiceAccount, and leave the default account with no roles.
  4. Don’t mount tokens that aren’t used: set automountServiceAccountToken: false on pods that never call the API.
  5. Keep cluster-admin for break-glass accounts, and never issue everyday credentials in system:masters.
  6. Enforce Pod Security where people can create pods, so create pods doesn’t mean node access.
  7. Review bindings regularly, and remove ones left behind by people who left or tools you uninstalled.

How to build a least-privilege Role

  1. Start from what the workload does, not from a built-in role. A deploy job that rolls out a Deployment needs get, create and patch on deployments, not edit on the whole namespace.
  2. Pick the narrowest scope. One namespace is a Role and a RoleBinding. The same permissions in a few namespaces is one ClusterRole bound with a RoleBinding in each. Only nodes, namespaces, other cluster-scoped resources and URLs such as /metrics need a ClusterRoleBinding.
  3. List subresources on their own. Logs are pods/log, a shell is create on pods/exec, and scaling is deployments/scale. Granting pods doesn’t grant them, and granting them doesn’t grant pods.
  4. Use resourceNames where they work. They limit get, update, patch and delete to named objects. They can’t limit create or deletecollection, and list and watch only match when the client asks for one object by name.
  5. Check before and after you apply. Run the role through the explainer’s checks, then confirm with kubectl auth can-i that the allowed actions say yes and the rest say no. To create a role, you need every permission it grants yourself, or the escalate verb.

The explainer’s Build a Role mode does this on a grid of resources and verbs. It writes compact YAML, flags risky permissions as you tick them, and lists the can-i checks to run. From the Subjects or Roles view, “Rebuild as least privilege” starts it from what an account or role can do today, so you can untick what isn’t needed.

Checking access in a live cluster

kubectl auth can-i answers one question for one identity: for example kubectl auth can-i list secrets -n payments --as=system:serviceaccount:payments:api, or --list to see everything that identity may do in a namespace. Using --as needs permission to impersonate.

The explainer works the other way round. It reads the RBAC objects themselves, so it covers every subject at once, says which binding grants what, and works on manifests before they’re applied, in a pull request or a Helm chart’s output. To design roles for your own application rather than the cluster, use the RBAC Matrix Builder.

Questions

Is it safe to paste my RBAC YAML here?

The YAML is read in your browser and never sent to NestedBit or anyone else. It’s kept in this browser’s storage so it’s there when you come back, and Clear removes it. Roles and bindings hold no Secrets, but they do name your namespaces, accounts and groups.

How do I export all the RBAC objects in my cluster?

Run kubectl get roles,rolebindings,clusterroles,clusterrolebindings -A -o yaml and paste the output. It needs permission to list those four kinds across the cluster, and it prints no Secrets. JSON output from -o json works too.

What’s the difference between a RoleBinding and a ClusterRoleBinding?

A RoleBinding grants a Role or ClusterRole inside one namespace. A ClusterRoleBinding grants a ClusterRole in every namespace, plus cluster-scoped resources such as nodes and non-resource URLs. If a job needs a few namespaces, use a RoleBinding in each.

What are the Kubernetes RBAC verbs?

get, list, watch, create, update, patch, delete and deletecollection, which map to HTTP methods on the API. There are also special verbs: bind and escalate on roles, impersonate on users, groups and ServiceAccounts, and approve and sign for certificates. * means all of them.

Why does it flag the built-in edit role?

edit can read every Secret in its namespace, run pods as any ServiceAccount there, exec into pods and create ServiceAccount tokens. That reaches the access of every account in the namespace. It’s often the right role for a team’s own namespace, but it’s more than read-and-deploy.

Can it tell me who is in a group?

No. Kubernetes has no group objects: group membership comes from client certificates or your identity provider, so check members there. The explainer does know the groups Kubernetes adds by itself, such as system:authenticated and the ServiceAccount groups, and counts what they’re given.

How is this different from kubectl auth can-i?

kubectl auth can-i answers one question for one identity on a live cluster. The explainer reads the RBAC objects, so it covers every subject at once, shows which binding grants what, flags risky grants, and works on manifests before they’re applied.

Can it write a least-privilege Role for me?

Yes. Build a Role puts common resources and verbs on a grid, with starting points such as a read-only viewer, a CI deployer and a log reader. It writes the Role or ClusterRole and its bindings as compact YAML, runs the same risk checks as you tick, and lists the kubectl auth can-i checks to run after applying. “Rebuild as least privilege” in the Subjects and Roles views starts it from what an account or role can do today. What you build is kept in this browser only.