Understanding Kubernetes RBAC
- RNREDDY

- Nov 26, 2025
- 2 min read
Understanding Kubernetes RBAC
Some of you may already know this. Let's quickly revise how RBAC works.
Step 1: Define Roles (Role or ClusterRole): What actions are allowed within a namespace (Role) or across the entire cluster (ClusterRole).
Step 2: Creating Service Accounts or Users/Groups: Set up service accounts within Kubernetes or manage external users/groups to take on these roles.
Step 3: Bind Roles to Accounts, Users, or Groups: Use RoleBindings to connect roles to service accounts or users within a namespace, or ClusterRoleBindings for cluster-wide permissions.
Here is the simplified visualization of Kubernetes RBAC:

To further understand how RBAC operates, let’s break down the key roles in Kubernetes:
Cluster-admin: Acts as a superuser with full control over all resources across the cluster and namespaces.
Admin: Grants complete read and write access within a specific namespace, including creating roles and bindings but not modifying the namespace itself.
Edit: Allows read and write permissions within a namespace, excluding the ability to view or modify roles or bindings.
View: Provides read-only access within a namespace, without permission to view or change roles or bindings.
Creating an RBAC role is straightforward, so let’s not go there. Instead, let’s talk about more crucial elements:
How to Check Defined Permissions:
Always verify what your service accounts can do, blind spots lead to security breaches.
Use kubectl auth can-i
These commands check if the app-sa service account in the prod-app namespace can get secrets, list pods, and create deployments.

Why Default service account shouldn’t be used ?
Default service accounts often have broad permissions that can be a security risk. Create and use custom service accounts to better control and limit access.

Assign this service account to your frontend application pod:

Disabling auto mounting of service account token
Only mount tokens when absolutely necessary for the pod's operation. This way you reduce the significant risk of token exposures.

Implementing Least Privilege access
Assign only the permissions that are absolutely necessary for a role to perform its tasks. This minimizes potential damage if a service account is compromised.

Define roles for different permissions, not for different service accounts
This way, you avoid role duplication and can easily update permissions in one place without worrying about multiple service accounts having differing access levels.




Comments