RBAC (Role-Based Access Control) in AKS - Tutorial

Role-Based Access Control (RBAC) is a crucial aspect of securing your Azure Kubernetes Service (AKS) clusters. RBAC enables you to define fine-grained access policies, granting appropriate permissions to different users and groups based on their roles. With RBAC, you can ensure that only authorized individuals can perform specific actions within your AKS environment. This tutorial will guide you through the process of implementing RBAC in AKS.


Before getting started, ensure you have the following prerequisites:

  • An Azure subscription
  • An AKS cluster deployed
  • Azure CLI installed

Step 1: Create Azure AD Users or Groups

To implement RBAC in AKS, you need to create Azure Active Directory (Azure AD) users or groups. Follow these steps:

  1. Create Azure AD users or groups using the Azure portal or Azure CLI.
  2. Make note of the Object ID for each user or group, which will be used in the next steps.

Step 2: Define RBAC Roles

Next, you need to define RBAC roles to control access to AKS resources. Follow these steps:

  1. Identify the specific permissions required for each role, such as read-only access or cluster administration.
  2. Create custom RBAC roles using Azure CLI commands, or use the built-in roles provided by AKS, such as "Azure Kubernetes Service Cluster User" or "Azure Kubernetes Service Cluster Admin".
  3. Assign the appropriate roles to Azure AD users or groups using the following Azure CLI command:
az aks role assign --role --scope /subscriptions//resourcegroups//providers/Microsoft.ContainerService/managedClusters/ --assignee

Step 3: Verify RBAC Access

After defining RBAC roles and assigning them to users or groups, you can verify the access within your AKS cluster. Follow these steps:

  1. Authenticate with Azure AD and obtain the AKS credentials using the following Azure CLI command:
az aks get-credentials --name --resource-group
  1. Verify the access by running commands against the AKS cluster, such as:
kubectl get pods

Common Mistakes to Avoid

  • Not defining granular RBAC roles and relying solely on built-in roles.
  • Assigning incorrect roles to users or groups, granting excessive or insufficient permissions.
  • Forgetting to update RBAC roles when user or group access requirements change.

Frequently Asked Questions

  1. Can I create custom RBAC roles in AKS?

    Yes, you can create custom RBAC roles using Azure CLI commands or Azure portal. Custom roles allow you to define specific permissions for your AKS resources.

  2. How can I list the RBAC role assignments in AKS?

    You can list the RBAC role assignments using the following Azure CLI command:

    az aks list --resource-group --query "[].{Name:name, Role:roleName, User:principalName}" -o table
  3. Can I assign multiple RBAC roles to a user or group?

    Yes, you can assign multiple RBAC roles to a user or group, allowing them to have different levels of access to different resources within your AKS cluster.

  4. Can I assign RBAC roles to Azure AD service principals?

    Yes, you can assign RBAC roles to Azure AD service principals, which are used for authentication and authorization of applications accessing your AKS cluster.

  5. How can I remove an RBAC role assignment in AKS?

    To remove an RBAC role assignment, use the following Azure CLI command:

    az role assignment delete --assignee --scope /subscriptions//resourcegroups//providers/Microsoft.ContainerService/managedClusters/


Implementing Role-Based Access Control (RBAC) in Azure Kubernetes Service (AKS) is crucial for fine-grained access management and securing your AKS clusters. By following the steps outlined in this tutorial, you can create Azure AD users or groups, define RBAC roles, and assign them to users or groups. Avoid common mistakes like not defining granular roles or assigning incorrect permissions. With RBAC in AKS, you can ensure that the right individuals have appropriate access to your AKS resources, enhancing security and maintaining control over your cluster environment.