azureblog.co.uk
← cd ~/roles
// roles/azure · containers

Azure Kubernetes Service RBAC WriterAzure built-in role

Allows read/write access to most objects in a namespace.This role does not allow viewing or modifying roles or role bindings. However, this role allows accessing Secrets and running Pods as any ServiceAccount in the namespace, so it can be used to gain the API access levels of any ServiceAccount in the namespace. Applying this role at cluster scope will give access across all namespaces.

Role IDa7ffa36f-339b-4b5c-8bdf-e2c188b2c0eb
CategoryContainers
Actions4
Data actions35

Before you assign it

  • It reaches the data, not just the resource. It has 35 data actions, such as reading blobs, secrets or messages.

What it can do

PermissionWhat it allows
Microsoft.Authorization/*/readAny read operation on anything under Microsoft.Authorization
Microsoft.Resources/subscriptions/operationresults/readGet the subscription operation results.
Microsoft.Resources/subscriptions/readGets the list of subscriptions.
Microsoft.Resources/subscriptions/resourceGroups/readGets or lists resource groups.

Data actions

PermissionWhat it allows
Microsoft.ContainerService/managedClusters/apps/controllerrevisions/readReads controllerrevisions
Microsoft.ContainerService/managedClusters/apps/daemonsets/*Every operation under Microsoft.ContainerService/managedClusters/apps/daemonsets
Microsoft.ContainerService/managedClusters/apps/deployments/*Every operation under Microsoft.ContainerService/managedClusters/apps/deployments
Microsoft.ContainerService/managedClusters/apps/replicasets/*Every operation under Microsoft.ContainerService/managedClusters/apps/replicasets
Microsoft.ContainerService/managedClusters/apps/statefulsets/*Every operation under Microsoft.ContainerService/managedClusters/apps/statefulsets
Microsoft.ContainerService/managedClusters/autoscaling/horizontalpodautoscalers/*Every operation under Microsoft.ContainerService/managedClusters/autoscaling/horizontalpodautoscalers
Microsoft.ContainerService/managedClusters/batch/cronjobs/*Every operation under Microsoft.ContainerService/managedClusters/batch/cronjobs
Microsoft.ContainerService/managedClusters/coordination.k8s.io/leases/readReads leases
Microsoft.ContainerService/managedClusters/coordination.k8s.io/leases/writeWrites leases
Microsoft.ContainerService/managedClusters/coordination.k8s.io/leases/deleteDeletes leases
Microsoft.ContainerService/managedClusters/discovery.k8s.io/endpointslices/readReads endpointslices
Microsoft.ContainerService/managedClusters/batch/jobs/*Every operation under Microsoft.ContainerService/managedClusters/batch/jobs
Microsoft.ContainerService/managedClusters/configmaps/*Every operation under Microsoft.ContainerService/managedClusters/configmaps
Microsoft.ContainerService/managedClusters/endpoints/*Every operation under Microsoft.ContainerService/managedClusters/endpoints
Microsoft.ContainerService/managedClusters/events.k8s.io/events/readReads events
Microsoft.ContainerService/managedClusters/events/*Every operation under Microsoft.ContainerService/managedClusters/events
Microsoft.ContainerService/managedClusters/extensions/daemonsets/*Every operation under Microsoft.ContainerService/managedClusters/extensions/daemonsets
Microsoft.ContainerService/managedClusters/extensions/deployments/*Every operation under Microsoft.ContainerService/managedClusters/extensions/deployments
Microsoft.ContainerService/managedClusters/extensions/ingresses/*Every operation under Microsoft.ContainerService/managedClusters/extensions/ingresses
Microsoft.ContainerService/managedClusters/extensions/networkpolicies/*Every operation under Microsoft.ContainerService/managedClusters/extensions/networkpolicies
Microsoft.ContainerService/managedClusters/extensions/replicasets/*Every operation under Microsoft.ContainerService/managedClusters/extensions/replicasets
Microsoft.ContainerService/managedClusters/limitranges/readReads limitranges
Microsoft.ContainerService/managedClusters/metrics.k8s.io/pods/readReads pods
Microsoft.ContainerService/managedClusters/metrics.k8s.io/nodes/readReads nodes
Microsoft.ContainerService/managedClusters/namespaces/readReads namespaces
Microsoft.ContainerService/managedClusters/networking.k8s.io/ingresses/*Every operation under Microsoft.ContainerService/managedClusters/networking.k8s.io/ingresses
Microsoft.ContainerService/managedClusters/networking.k8s.io/networkpolicies/*Every operation under Microsoft.ContainerService/managedClusters/networking.k8s.io/networkpolicies
Microsoft.ContainerService/managedClusters/persistentvolumeclaims/*Every operation under Microsoft.ContainerService/managedClusters/persistentvolumeclaims
Microsoft.ContainerService/managedClusters/pods/*Every operation under Microsoft.ContainerService/managedClusters/pods
Microsoft.ContainerService/managedClusters/policy/poddisruptionbudgets/*Every operation under Microsoft.ContainerService/managedClusters/policy/poddisruptionbudgets
Microsoft.ContainerService/managedClusters/replicationcontrollers/*Every operation under Microsoft.ContainerService/managedClusters/replicationcontrollers
Microsoft.ContainerService/managedClusters/resourcequotas/readReads resourcequotas
Microsoft.ContainerService/managedClusters/secrets/*Every operation under Microsoft.ContainerService/managedClusters/secrets
Microsoft.ContainerService/managedClusters/serviceaccounts/*Every operation under Microsoft.ContainerService/managedClusters/serviceaccounts
Microsoft.ContainerService/managedClusters/services/*Every operation under Microsoft.ContainerService/managedClusters/services

Assign it

Scope it as tightly as you can: a resource or resource group rather than the whole subscription.

azure cli
az role assignment create \
  --assignee "jane.doe@contoso.com" \
  --role "Azure Kubernetes Service RBAC Writer" \
  --scope "/subscriptions/<subscription id>/resourceGroups/<resource group>"
powershell3 lines
New-AzRoleAssignment -SignInName "jane.doe@contoso.com" `
  -RoleDefinitionName "Azure Kubernetes Service RBAC Writer" `
  -Scope "/subscriptions/<subscription id>/resourceGroups/<resource group>"
bicep7 lines
resource assignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
  name: guid(resourceGroup().id, principalId, 'a7ffa36f-339b-4b5c-8bdf-e2c188b2c0eb')
  properties: {
    roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'a7ffa36f-339b-4b5c-8bdf-e2c188b2c0eb')
    principalId: principalId
  }
}

Who already has it?

kql · azure resource graph
authorizationresources
| where type == "microsoft.authorization/roleassignments"
| where tostring(properties.roleDefinitionId) endswith "a7ffa36f-339b-4b5c-8bdf-e2c188b2c0eb"
| project principalId = tostring(properties.principalId), principalType = tostring(properties.principalType), scope = tostring(properties.scope)

Other containers roles

Find the smallest role for a task →