Access and identity options for Azure Kubernetes Service (AKS)
You can authenticate, authorize, secure, and control access to Kubernetes clusters in a variety of ways:
- Using Kubernetes role-based access control (Kubernetes RBAC), you can grant users, groups, and service accounts access to only the resources they need.
- With Azure Kubernetes Service (AKS), you can further enhance the security and permissions structure using Azure Active Directory and Azure RBAC.
Kubernetes RBAC and AKS help you secure your cluster access and provide only the minimum required permissions to developers and operators.
This article introduces the core concepts that help you authenticate and assign permissions in AKS.
Kubernetes RBAC provides granular filtering of user actions. With this control mechanism:
- You assign users or user groups permission to create and modify resources or view logs from running application workloads.
- You can scope permissions to a single namespace or across the entire AKS cluster.
- You create roles to define permissions, and then assign those roles to users with role bindings.
For more information, see Using Kubernetes RBAC authorization.
Roles and ClusterRoles
Before assigning permissions to users with Kubernetes RBAC, you'll define user permissions as a Role. Grant permissions within a namespace using roles.
Kubernetes roles grant permissions; they don't deny permissions.
To grant permissions across the entire cluster or to cluster resources outside a given namespace, you can instead use ClusterRoles.
A ClusterRole grants and applies permissions to resources across the entire cluster, not a specific namespace.
RoleBindings and ClusterRoleBindings
Once you've defined roles to grant permissions to resources, you assign those Kubernetes RBAC permissions with a RoleBinding. If your AKS cluster integrates with Azure Active Directory (Azure AD), RoleBindings grant permissions to Azure AD users to perform actions within the cluster. See how in Control access to cluster resources using Kubernetes role-based access control and Azure Active Directory identities.
Assign roles to users for a given namespace using RoleBindings. With RoleBindings, you can logically segregate a single AKS cluster, only enabling users to access the application resources in their assigned namespace.
To bind roles across the entire cluster, or to cluster resources outside a given namespace, you instead use ClusterRoleBindings.
With a ClusterRoleBinding, you bind roles to users and apply to resources across the entire cluster, not a specific namespace. This approach lets you grant administrators or support engineers access to all resources in the AKS cluster.
Microsoft/AKS performs any cluster actions with user consent under a built-in Kubernetes role
aks-service and built-in role binding
This role enables AKS to troubleshoot and diagnose cluster issues, but can't modify permissions nor create roles or role bindings, or other high privilege actions. Role access is only enabled under active support tickets with just-in-time (JIT) access. Read more about AKS support policies.
Kubernetes service accounts
Service accounts are one of the primary user types in Kubernetes. The Kubernetes API holds and manages service accounts. Service account credentials are stored as Kubernetes secrets, allowing them to be used by authorized pods to communicate with the API Server. Most API requests provide an authentication token for a service account or a normal user account.
Normal user accounts allow more traditional access for human administrators or developers, not just services and processes. While Kubernetes doesn't provide an identity management solution to store regular user accounts and passwords, you can integrate external identity solutions into Kubernetes. For AKS clusters, this integrated identity solution is Azure AD.
For more information on the identity options in Kubernetes, see Kubernetes authentication.
Azure role-based access control
Azure role-based access control (RBAC) is an authorization system built on Azure Resource Manager that provides fine-grained access management of Azure resources.
|Kubernetes RBAC||Designed to work on Kubernetes resources within your AKS cluster.|
|Azure RBAC||Designed to work on resources within your Azure subscription.|
With Azure RBAC, you create a role definition that outlines the permissions to be applied. You then assign a user or group this role definition via a role assignment for a particular scope. The scope can be an individual resource, a resource group, or across the subscription.
For more information, see What is Azure role-based access control (Azure RBAC)?
There are two levels of access needed to fully operate an AKS cluster:
- Access the AKS resource in your Azure subscription.
- Control scaling or upgrading your cluster using the AKS APIs.
- Pull your
- Access to the Kubernetes API. This access is controlled by either:
- Kubernetes RBAC (traditionally).
- Integrating Azure RBAC with AKS for Kubernetes authorization.
Azure RBAC to authorize access to the AKS resource
With Azure RBAC, you can provide your users (or identities) with granular access to AKS resources across one or more subscriptions. For example, you could use the Azure Kubernetes Service Contributor role to scale and upgrade your cluster. Meanwhile, another user with the Azure Kubernetes Service Cluster Admin role only has permission to pull the Admin
Alternatively, you could give your user the general Contributor role. With the general Contributor role, users can perform the above permissions and every action possible on the AKS resource, except managing permissions.
Azure RBAC for Kubernetes Authorization
With the Azure RBAC integration, AKS will use a Kubernetes Authorization webhook server so you can manage Azure AD-integrated Kubernetes cluster resource permissions and assignments using Azure role definition and role assignments.
As shown in the above diagram, when using the Azure RBAC integration, all requests to the Kubernetes API will follow the same authentication flow as explained on the Azure Active Directory integration section.
If the identity making the request exists in Azure AD, Azure will team with Kubernetes RBAC to authorize the request. If the identity exists outside of Azure AD (i.e., a Kubernetes service account), authorization will defer to the normal Kubernetes RBAC.
In this scenario, you use Azure RBAC mechanisms and APIs to assign users built-in roles or create custom roles, just as you would with Kubernetes roles.
With this feature, you not only give users permissions to the AKS resource across subscriptions, but you also configure the role and permissions for inside each of those clusters controlling Kubernetes API access. For example, you can grant the
Azure Kubernetes Service RBAC Reader role on the subscription scope. The role recipient will be able to list and get all Kubernetes objects from all clusters without modifying them.
You need to enable Azure RBAC for Kubernetes authorization before using this feature. For more details and step by step guidance, follow our Use Azure RBAC for Kubernetes Authorization how-to guide.
AKS provides the following four built-in roles. They are similar to the Kubernetes built-in roles with a few differences, like supporting CRDs. See the full list of actions allowed by each Azure built-in role.
|Azure Kubernetes Service RBAC Reader||Allows read-only access to see most objects in a namespace.
Doesn't allow viewing roles or role bindings.
Doesn't allow viewing
|Azure Kubernetes Service RBAC Writer||Allows read/write access to most objects in a namespace.
Doesn't allow viewing or modifying roles, or role bindings.
|Azure Kubernetes Service RBAC Admin||Allows admin access, intended to be granted within a namespace.
Allows read/write access to most resources in a namespace (or cluster scope), including the ability to create roles and role bindings within the namespace.
Doesn't allow write access to resource quota or to the namespace itself.
|Azure Kubernetes Service RBAC Cluster Admin||Allows super-user access to perform any action on any resource.
Gives full control over every resource in the cluster and in all namespaces.
Azure AD integration
Enhance your AKS cluster security with Azure AD integration. Built on decades of enterprise identity management, Azure AD is a multi-tenant, cloud-based directory and identity management service that combines core directory services, application access management, and identity protection. With Azure AD, you can integrate on-premises identities into AKS clusters to provide a single source for account management and security.
With Azure AD-integrated AKS clusters, you can grant users or groups access to Kubernetes resources within a namespace or across the cluster.
- To obtain a
kubectlconfiguration context, a user runs the az aks get-credentials command.
- When a user interacts with the AKS cluster with
kubectl, they're prompted to sign in with their Azure AD credentials.
This approach provides a single source for user account management and password credentials. The user can only access the resources as defined by the cluster administrator.
Azure AD authentication is provided to AKS clusters with OpenID Connect. OpenID Connect is an identity layer built on top of the OAuth 2.0 protocol. For more information on OpenID Connect, see the Open ID connect documentation. From inside of the Kubernetes cluster, Webhook Token Authentication is used to verify authentication tokens. Webhook token authentication is configured and managed as part of the AKS cluster.
Webhook and API server
As shown in the graphic above, the API server calls the AKS webhook server and performs the following steps:
kubectluses the Azure AD client application to sign in users with OAuth 2.0 device authorization grant flow.
- Azure AD provides an access_token, id_token, and a refresh_token.
- The user makes a request to
kubectlwith an access_token from
kubectlsends the access_token to API Server.
- The API Server is configured with the Auth WebHook Server to perform validation.
- The authentication webhook server confirms the JSON Web Token signature is valid by checking the Azure AD public signing key.
- The server application uses user-provided credentials to query group memberships of the logged-in user from the MS Graph API.
- A response is sent to the API Server with user information such as the user principal name (UPN) claim of the access token, and the group membership of the user based on the object ID.
- The API performs an authorization decision based on the Kubernetes Role/RoleBinding.
- Once authorized, the API server returns a response to
kubectlprovides feedback to the user.
Learn how to integrate AKS with Azure AD with our AKS-managed Azure AD integration how-to guide.
AKS service permissions
When creating a cluster, AKS generates or modifies resources it needs (like VMs and NICs) to create and run the cluster on behalf of the user. This identity is distinct from the cluster's identity permission, which is created during cluster creation.
Identity creating and operating the cluster permissions
The following permissions are needed by the identity creating and operating the cluster.
||Required to read disk encryption set ID.|
||Required for updating proximity placement groups.|
||Required to configure application gateways and join the subnet.|
||Required to configure the Network Security Group for the subnet when using a custom VNET.|
||Required to configure the outbound public IPs on the Standard Load Balancer.|
||Required to create and update Log Analytics workspaces and Azure monitoring for containers.|
||Required to configure the IP-based Load Balancer Backend Pools.|
AKS cluster identity permissions
The following permissions are used by the AKS cluster identity, which is created and associated with the AKS cluster. Each permission is used for the reasons below:
||Required for creating users and operating the cluster|
||Required to configure the load balancer for a LoadBalancer service.|
||Required to find and configure public IPs for a LoadBalancer service.|
||Required for configuring public IPs for a LoadBalancer service.|
||Required to create or delete security rules for a LoadBalancer service.|
||Required to configure AzureDisks.|
||Required to configure storage accounts for AzureFile or AzureDisk.|
||Required to configure route tables and routes for nodes.|
||Required to find information for virtual machines in a VMAS, such as zones, fault domain, size, and data disks.|
||Required to attach AzureDisks to a virtual machine in a VMAS.|
||Required to find information for virtual machines in a virtual machine scale set, such as zones, fault domain, size, and data disks.|
||Required to add a virtual machine in a VMAS to a load balancer backend address pool.|
||Required to add a virtual machine scale set to a load balancer backend address pools and scale out nodes in a virtual machine scale set.|
||Required to delete a virtual machine scale set to a load balancer backend address pools and scale down nodes in a virtual machine scale set.|
||Required to attach AzureDisks and add a virtual machine from a virtual machine scale set to the load balancer.|
||Required to search internal IPs and load balancer backend address pools for virtual machines in a VMAS.|
||Required to search internal IPs and load balancer backend address pools for a virtual machine in a virtual machine scale set.|
||Required to find public IPs for a virtual machine in a virtual machine scale set.|
||Required to verify if a subnet exists for the internal load balancer in another resource group.|
||Required to configure snapshots for AzureDisk.|
||Required to find virtual machine sizes for finding AzureDisk volume limits.|
Additional cluster identity permissions
When creating a cluster with specific attributes, you will need the following additional permissions for the cluster identity. Since these permissions are not automatically assigned, you must add them to the cluster identity after it's created.
||Required if using a network security group in another resource group. Required to configure security rules for a LoadBalancer service.|
||Required if using a subnet in another resource group such as a custom VNET.|
||Required if using a subnet associated with a route table in another resource group such as a custom VNET with a custom route table. Required to verify if a subnet already exists for the subnet in the other resource group.|
||Required if using an internal load balancer in another resource group. Required to verify if a subnet already exists for the internal load balancer in the resource group.|
||Required if using a private DNS zone in another resource group such as a custom privateDNSZone.|
AKS Node Access
By default Node Access is not required for AKS. The following access is needed for the node if a specific component is leveraged.
||Required to grant MSI access to ACR.|
||Required for write permission to "random name".aksapp.io.|
||Required to grant permission to the Log Analytics workspace.|
View the table for a quick summary of how users can authenticate to Kubernetes when Azure AD integration is enabled. In all cases, the user's sequence of commands is:
az loginto authenticate to Azure.
az aks get-credentialsto download credentials for the cluster into
- The first command may trigger browser-based authentication to authenticate to the cluster, as described in the following table.
In the Azure portal, you can find:
- The Role Grant (Azure RBAC role grant) referred to in the second column is shown on the Access Control tab.
- The Cluster Admin Azure AD Group is shown on the Configuration tab.
- Also found with parameter name
--aad-admin-group-object-idsin the Azure CLI.
- Also found with parameter name
|Description||Role grant required||Cluster admin Azure AD group(s)||When to use|
|Legacy admin login using client certificate||Azure Kubernetes Admin Role. This role allows
||n/a||If you're permanently blocked by not having access to a valid Azure AD group with access to your cluster.|
|Azure AD with manual (Cluster)RoleBindings||Azure Kubernetes User Role. The "User" role allows
||User is not in any of these groups. Because the user is not in any Cluster Admin groups, their rights will be controlled entirely by any RoleBindings or ClusterRoleBindings that have been set up by cluster admins. The (Cluster)RoleBindings nominate Azure AD users or Azure AD groups as their
||If you want fine-grained access control, and you're not using Azure RBAC for Kubernetes Authorization. Note that the user who sets up the bindings must log in by one of the other methods listed in this table.|
|Azure AD by member of admin group||Same as above||User is a member of one of the groups listed here. AKS automatically generates a ClusterRoleBinding that binds all of the listed groups to the
||If you want to conveniently grant users full admin rights, and are not using Azure RBAC for Kubernetes authorization.|
|Azure AD with Azure RBAC for Kubernetes Authorization||Two roles:
First, Azure Kubernetes User Role (as above).
Second, one of the "Azure Kubernetes Service RBAC..." roles listed above, or your own custom alternative.
|The admin roles field on the Configuration tab is irrelevant when Azure RBAC for Kubernetes Authorization is enabled.||You are using Azure RBAC for Kubernetes authorization. This approach gives you fine-grained control, without the need to set up RoleBindings or ClusterRoleBindings.|
- To get started with Azure AD and Kubernetes RBAC, see Integrate Azure Active Directory with AKS.
- For associated best practices, see Best practices for authentication and authorization in AKS.
- To get started with Azure RBAC for Kubernetes Authorization, see Use Azure RBAC to authorize access within the Azure Kubernetes Service (AKS) Cluster.
- To get started securing your
kubeconfigfile, see Limit access to cluster configuration file
For more information on core Kubernetes and AKS concepts, see the following articles:
Submit and view feedback for