Setup for AKS (Required for AKS_MODE)¶
For AKS clusters, you need a Service Principal (SPN) with permissions to read cluster metadata and all Kubernetes resources, including secrets. Follow these steps to create the SPN and assign the custom KubeBuddy Reader role.
1. Create the SPN¶
Run the following command to create an SPN named kubebuddy-spn:
az ad sp create-for-rbac --name kubebuddy-spn --output json
Example Output:
{
"appId": "87654321-4321-4321-4321-0987654321ba",
"displayName": "kubebuddy-spn",
"password": "<your-client-secret>",
"tenant": "abcdef12-3456-7890-abcd-ef1234567890"
}
Save these values:
appId→AZURE_CLIENT_IDpassword→AZURE_CLIENT_SECRETtenant→AZURE_TENANT_ID
Security Note: Store
AZURE_CLIENT_SECRETsecurely (e.g., in Azure Key Vault).
2. Create the KubeBuddy Reader Role¶
Create a custom Azure role to grant read-only access to all Kubernetes resources, including secrets.
KubeBuddyReader.json:
{
"Name": "KubeBuddy Reader",
"Description": "Grants read-only access to all Kubernetes resources in an AKS cluster, including secrets, for KubeBuddy reporting.",
"Actions": [
"Microsoft.Authorization/*/read",
"Microsoft.Resources/subscriptions/operationresults/read",
"Microsoft.Resources/subscriptions/read",
"Microsoft.Resources/subscriptions/resourceGroups/read"
],
"NotActions": [],
"DataActions": [
"Microsoft.ContainerService/managedClusters/apps/*/read",
"Microsoft.ContainerService/managedClusters/autoscaling/*/read",
"Microsoft.ContainerService/managedClusters/batch/*/read",
"Microsoft.ContainerService/managedClusters/configmaps/read",
"Microsoft.ContainerService/managedClusters/endpoints/read",
"Microsoft.ContainerService/managedClusters/events/*/read",
"Microsoft.ContainerService/managedClusters/extensions/*/read",
"Microsoft.ContainerService/managedClusters/limitranges/read",
"Microsoft.ContainerService/managedClusters/namespaces/read",
"Microsoft.ContainerService/managedClusters/networking.k8s.io/*/read",
"Microsoft.ContainerService/managedClusters/pods/*/read",
"Microsoft.ContainerService/managedClusters/policy/*/read",
"Microsoft.ContainerService/managedClusters/secrets/read",
"Microsoft.ContainerService/managedClusters/services/read",
"Microsoft.ContainerService/managedClusters/storage.k8s.io/*/read"
],
"NotDataActions": [],
"AssignableScopes": [
"/subscriptions/<your-subscription-id>"
]
}
Replace <your-subscription-id> with your actual subscription ID.
az role definition create --role-definition KubeBuddyReader.json
Note: If you do not want to create a custom role, your SPN must have Cluster Admin access for full Kubernetes resource visibility.
3. Assign Permissions¶
Assign both the KubeBuddy Reader and Azure Kubernetes Service Cluster User roles to the SPN.
RESOURCE_GROUP="<group>"
CLUSTER_NAME="<cluster>"
SUBSCRIPTION_ID="<sub-id>"
SPN_CLIENT_ID="<your-client-id>"
AKS_ID=$(az aks show \
--resource-group $RESOURCE_GROUP \
--name $CLUSTER_NAME \
--subscription $SUBSCRIPTION_ID \
--query id --output tsv)
az role assignment create --role "KubeBuddy Reader" --assignee $SPN_CLIENT_ID --scope $AKS_ID
az role assignment create --role "Azure Kubernetes Service Cluster User Role" --assignee $SPN_CLIENT_ID --scope $AKS_ID
$ResourceGroup = "<group>"
$ClusterName = "<cluster>"
$SubscriptionId = "<sub-id>"
$SpnClientId = "<your-client-id>"
$AksId = az aks show `
--resource-group $ResourceGroup `
--name $ClusterName `
--subscription $SubscriptionId `
--query id --output tsv
az role assignment create --role "KubeBuddy Reader" --assignee $SpnClientId --scope $AksId
az role assignment create --role "Azure Kubernetes Service Cluster User Role" --assignee $SpnClientId --scope $AksId
4. Get Kubeconfig¶
Ensure your kubeconfig has access to the AKS cluster:
az aks get-credentials --resource-group <group> --name <cluster> --subscription <sub-id>
Example:
az aks get-credentials \
--resource-group rg-aks-0402-dev-uks \
--name aks-0402-dev-uks \
--subscription ee360ac1-ac8d-45c9-9bcf-76d19ae08a33
AKS Best Practice Checks¶
KubeBuddy evaluates various aspects of your Azure Kubernetes Service (AKS) setup, highlighting potential issues and confirming best practices.
AKS Automatic Migration Readiness¶
KubeBuddy also derives an AKS Automatic Migration Readiness view from the shared Kubernetes and AKS checks when you run with -Aks.
This is documented in its own page:
Use that page for:
- blocker vs warning behavior
- action-plan output
- JSON and HTML report sections
- affected-resource mapping
- ingress and Gateway API migration guidance
Checks Overview¶
Below is a categorized list of key AKS checks, ordered by ID and Category.
Best Practices¶
AKS runs also include one AKS-specific compatibility check from the shared Kubernetes catalog:
| ID | Check | Severity |
|---|---|---|
| SC002 | AKS Azure In-Tree Storage Provisioners | High |
| ID | Check | Severity |
|---|---|---|
| AKSBP001 | Allowed Container Images Policy | High |
| AKSBP002 | No Privileged Containers Policy | High |
| AKSBP003 | Multiple Node Pools | Medium |
| AKSBP004 | Azure Linux as Host OS | High |
| AKSBP005 | Ephemeral OS Disks Enabled | Medium |
| AKSBP006 | Non-Ephemeral Disks with Adequate Size | Medium |
| AKSBP007 | System Node Pool Taint | High |
| AKSBP008 | Auto Upgrade Channel Configured | Medium |
| AKSBP009 | Node OS Upgrade Channel Configured | Medium |
| AKSBP010 | Customized MC_ Resource Group Name | Medium |
| AKSBP011 | System Node Pool Minimum Size | High |
| AKSBP012 | Node Pool Version Matches Control Plane | Medium |
| AKSBP013 | No B-Series VMs in Node Pools | High |
| AKSBP014 | Use v5 or Newer SKU VMs for Node Pools | Medium |
Disaster Recovery¶
| ID | Check | Severity |
|---|---|---|
| AKSDR001 | Agent Pools with AZs | High |
| AKSDR002 | Control Plane SLA | Medium |
Identity & Access¶
| ID | Check | Severity |
|---|---|---|
| AKSIAM001 | RBAC Enabled | High |
| AKSIAM002 | Managed Identity | High |
| AKSIAM003 | Workload Identity Enabled | Medium |
| AKSIAM004 | Managed Identity Used | High |
| AKSIAM005 | AAD RBAC Authorization Integrated | High |
| AKSIAM006 | AAD Managed Authentication Enabled | High |
| AKSIAM007 | Local Accounts Disabled | High |
Monitoring & Logging¶
| ID | Check | Severity |
|---|---|---|
| AKSMON001 | Azure Monitor | High |
| AKSMON002 | Managed Prometheus Enabled | High |
Networking¶
| ID | Check | Severity |
|---|---|---|
| AKSNET001 | Authorized IP Ranges | High |
| AKSNET002 | Network Policy Check | Medium |
| AKSNET003 | Web App Routing Enabled | Low |
| AKSNET004 | Azure CNI Networking Recommended | Medium |
Resource Management¶
| ID | Check | Severity |
|---|---|---|
| AKSRES001 | Cluster Autoscaler | Medium |
| AKSRES002 | AKS Built-in Cost Tooling Enabled | Medium |
| AKSRES003 | Vertical Pod Autoscaler Enabled | Medium |
Security¶
| ID | Check | Severity |
|---|---|---|
| AKSSEC001 | Private Cluster | High |
| AKSSEC002 | Azure Policy Add-on | Medium |
| AKSSEC003 | Defender for Containers | High |
| AKSSEC004 | OIDC Issuer Enabled | Medium |
| AKSSEC005 | Azure Key Vault Integration | High |
| AKSSEC006 | Image Cleaner Enabled | Medium |
| AKSSEC007 | Kubernetes Dashboard Disabled | High |
| AKSSEC008 | Pod Security Admission Available | High |
Interpreting AKS evidence¶
AKSBP007requires the standardCriticalAddonsOnly=true:NoScheduleisolation taint on each system pool; a taint on a user pool does not satisfy it. The in-clusterNODE004check recognises this taint as intentional only on nodes labelledkubernetes.azure.com/mode=system.AKSBP011requires at least two current nodes in each system pool. It does not require two system pools, combine undersized pools, or substitute the autoscaler minimum for the current node count.AKSBP012prefers running control-plane and pool versions, falling back to requested versions when necessary. Requested minor-only versions are compared at the precision supplied.AKSBP014accepts VM generations v5 and newer, including v10 and later.AKSRES001checks node-poolenableAutoScalingflags. An autoscaler settings object alone does not enable scaling.AKSRES005accepts either enabled pool autoscaling or Node Auto-provisioning inAutomode.AKSDR002accepts Standard and Premium tiers for the control-plane SLA.AKSIAM004accepts both system-assigned and user-assigned managed identity;AKSIAM002separately expresses a preference for user-assigned identity.AKSSEC007fails only when the legacy dashboard addon is enabled. Enablement alone does not establish public accessibility; verify authentication and network access separately.AKSSEC008checks PSA availability using the Kubernetes version. AKS enables PSA by default from Kubernetes 1.23, but availability does not prove namespace enforcement. Use the in-clusterSEC007check and namespacepod-security.kubernetes.io/enforcelabels to review enforcement. An absent ARM PSA property is not evidence that PSA is disabled.
Each check provides insights into security, performance, and cost optimization.