Review Kubernetes RBAC settings for an AKS cluster

Enable Kubernetes RBAC in AKS and grant only the required operations through roles and bindings.

Description

Set properties.enableRBAC: true when creating an AKS cluster to enable Kubernetes RBAC. The separate aadProfile.enableAzureRBAC setting authorizes Entra identities through Azure roles.

Potential impact

A broad administrator grant can still let a user or service account reach other workloads or data.

Remediation

Check the current cluster’s RBAC state and grants. Bind a Role or ClusterRole containing only the required operations, then test allowed and denied actions as a regular user and a service account. An existing non-RBAC cluster needs migration to a new cluster.

Examples

Both examples use a managed identity and the service’s default Kubernetes version. Supply the node administrator’s adminUserName and sshPublicKey, and a VM size available in the region.

Before

bicep
param adminUserName string
param sshPublicKey string
param nodeVmSize string = 'Standard_D2s_v3'

resource aksCluster1 'Microsoft.ContainerService/managedClusters@2024-10-01' = {
  name: 'aksCluster1'
  location: resourceGroup().location
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    dnsPrefix: 'dnsprefix'
    agentPoolProfiles: [
      {
        name: 'agentpool'
        count: 2
        vmSize: nodeVmSize
        osType: 'Linux'
        mode: 'System'
      }
    ]
    linuxProfile: {
      adminUsername: adminUserName
      ssh: {
        publicKeys: [
          {
            keyData: sshPublicKey
          }
        ]
      }
    }
  }
}

API version 2024-10-01 enables RBAC by default for new clusters. The first excerpt relies on that default and the second makes it explicit.

After

bicep
param adminUserName string
param sshPublicKey string
param nodeVmSize string = 'Standard_D2s_v3'

resource aksCluster1 'Microsoft.ContainerService/managedClusters@2024-10-01' = {
  name: 'aksCluster1'
  location: resourceGroup().location
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    enableRBAC: true
    dnsPrefix: 'dnsprefix'
    agentPoolProfiles: [
      {
        name: 'agentpool'
        count: 2
        vmSize: nodeVmSize
        osType: 'Linux'
        mode: 'System'
      }
    ]
    linuxProfile: {
      adminUsername: adminUserName
      ssh: {
        publicKeys: [
          {
            keyData: sshPublicKey
          }
        ]
      }
    }
  }
}

References