how to check whether RBAC is enabled, using kubectl
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Understanding RBAC in Kubernetes
Role-Based Access Control (RBAC) is a key security feature in Kubernetes that allows administrators to manage fine-grained access controls to the Kubernetes API. By defining roles and role bindings, RBAC systemizes how permissions are granted to users or service accounts. Determining whether RBAC is enabled in your Kubernetes cluster is fundamental to ensuring that your access policies are enforced. In this guide, we will dive into how to use kubectl to verify RBAC settings.
Checking for RBAC in Your Kubernetes Cluster
To determine if RBAC is enabled on a Kubernetes cluster, one of the simplest methods is to assess the API server configuration or query the cluster directly for RBAC resources.
Step 1: Inspect the API Server
RBAC is configured through the Kube API server. Specifically, you should verify the --authorization-mode flag includes RBAC. Here's how you can examine the API server's configuration:
- If you have access to the control plane:
- Look for the
--authorization-modeflag:
If RBAC is listed among the authorization modes, then RBAC is enabled.
Step 2: Query for RBAC Resources
If you don’t have direct access to the control plane, you can infer RBAC is enabled by checking for the presence of RBAC resources such as Roles, RoleBindings, ClusterRoles, and ClusterRoleBindings. Here’s how you can perform this check:
- List Cluster Roles: Fetch the cluster roles in the cluster:
- Check Role Bindings: Fetch role bindings:
- Example output:If RBAC is enabled, you will see output similar to:
- Describe a Role or RoleBinding (Optional): You can describe any role or role binding to better understand its permissions:
Step 3: Create a Test Role and RoleBinding
If uncertain, creating a simple RBAC role and role binding is another way to validate if the feature is operational:
- Create a Test Role: Define a
RoleYAML file:
- Apply the Role:
- Validate by checking the created role:
This empirical test demonstrates RBAC functionality when you can successfully create and retrieve roles.
Key Points
| Step | Description |
| Inspect API Server | Check --authorization-mode for RBAC in Kube API server. |
| List ClusterRoles | Check for existence of ClusterRoles using kubectl get clusterroles. |
| List RoleBindings | Ensure RoleBindings are present using kubectl get rolebindings. |
| Test with Role | Validate operation by creating a test Role and RoleBinding resource. |
Conclusion
RBAC is pivotal for managing access within Kubernetes, and confirming its activation is crucial for maintaining security and operational oversight. By using kubectl and examining configuration and resource presence, you can verify that RBAC is effectively enabled in your environment. This proactive verification ensures your cluster's security policies remain robust and enforced consistently.
Related reading
- How to choose Kafka transactional.id in a Kubernetes (Producer side only transaction) set up
- How to clean-up old unused Kubernetes images/tags?
- How to cleanup failed CronJob spawned Jobs once a more recent job passes
- How to clear CrashLoopBackOff
- How to clear out session on log out
- How to config simple login/pass authentication for kubernetes desktop UI
- How to clear or clean specific pod from the local cocoapods cache
- How to clone a private git repository into a kubernetes pod using ssh keys in secrets?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.