Kubernetes RBAC (original) (raw)

Last Updated : 30 Apr, 2026

Kubernetes RBAC (Role‑Based Access Control) is a security mechanism used to manage permissions and control access to resources within a Kubernetes cluster. It ensures that users and applications can only perform actions they are authorized for, improving security and governance. Every request made to the Kubernetes API server passes through a sequence of three stages:

1. Authentication

This stage identifies **who is making the request. Kubernetes verifies identity through external methods rather than an internal user database.

This stage determines **what the authenticated user is allowed to do by checking their specific permissions.

3. Admission Control

This is the final gatekeeper that enforces cluster-wide policies before the request is saved to **etcd.

The Core Components of RBAC

RBAC is built upon four key API objects. They can be divided into two categories: defining _what can be done (Roles) and defining _who can do it (Bindings).

Roles and ClusterRoles

These objects define a set of permissions. The rules inside them are purely additive (there are no "deny" rules).

RoleBindings and ClusterRoleBindings: Granting Permissions

These objects "bind" a Role or ClusterRole to a subject (a user, group, or ServiceAccount), thereby granting them the permissions defined in that role.

Kubernetes RABC

Subjects, Verbs, and Resources

Roles

In Kubernetes, a Role is a declaration of the operations that can be performed on a type of Kubernetes resource within a particular namespace. A simple example of a Role could be: You might need to do some pre-checks as below:

**Roles. yaml: This Role, named 'pod-reader', provides read-only access to Pods in the default namespace.

kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: default
name: pod-reader
rules:

RoleBindings

It actually grants the permissions defined in a Role to a user or set of users. It holds a list of subjects and a reference to the Role being granted. Here's an example of a RoleBinding:

**RoleBindings.yaml: In this RoleBinding, the 'pod-reader' Role is assigned to the user 'john'. This means that 'john' can now read Pods in the default namespace.

kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: read-pods
namespace: default
subjects:

ClusterRoles

ClusterRole is similar to Role. However, while a Role is namespace-specific, a ClusterRole is not. This means that you can define permissions that apply across all namespaces in your cluster. Here's an example of a ClusterRole.

**ClusterRoles.yaml: In this ClusterRole, reading Nodes across the cluster is allowed.

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: node-reader
rules:

ClusterRoleBindings

Similar to a RoleBinding, a ClusterRoleBinding grants the permissions defined in a ClusterRole to a set of users, but it applies cluster-wide.

**ClusterRoleBindings.yaml: In this ClusterRoleBinding, the 'node-reader' ClusterRole is assigned to the user 'john', allowing 'john' to read Node information across the entire cluster.

kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: read-nodes
subjects:

RBAC Usage Scenarios

RBAC can be used in various scenarios to isolate team access, limit resource access, restrict operations, control admin access, and manage service account permissions.

**Isolating Team Access

**Limiting Resource Access

**Restricting Operations

**Admin Access Control

**Service Account Permissions