An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
Hello @Joel Zhu ,
Your AKS cluster’s node pools (VMSS instances) are intermittently deallocating at the Azure VM level
Step 1: Verify Azure Resource Health
Why? Azure Resource Health tracks platform-related issues (e.g., maintenance, capacity constraints) that might not appear in Activity Logs.
Actions:
Check VMSS Resource Health:
Navigate to your VMSS resource in the Azure Portal → Resource Health.
Look for:
Planned Maintenance (e.g., host upgrades).
Unplanned Maintenance (e.g., hardware failures).
Platform Issues (e.g., network/storage faults).
Check Subscription-Level Health:
Go to Subscription → Resource Health → Events.
Filter for Service Health incidents (e.g., region-wide outages).
Step 2: Dive into Azure Monitor Logs
Why? Activity Logs only show user-initiated operations. Azure Monitor Logs (Log Analytics) capture deeper platform events, including VM lifecycle changes.
2.1 Query VM Lifecycle Events
Use Log Analytics to search for VirtualMachineEvents and AzureActivity tables:
// Query 1: VM deallocation events (last 7 days)
VirtualMachineEvents
| where TimeGenerated > ago(7d)
| where VMEventCode == "instance-retirement" or VMEventCode == "deallocate"
| project Timestamp, VMName, ResourceGroup, VMEventCode, VMEventCodeDetails
| sort by Timestamp desc
// Query 2: Cross-reference with Azure Activity
AzureActivity
| where TimeGenerated > ago(7d)
| where OperationNameValue has "deallocate" or OperationNameValue has "stop"
| project Timestamp, OperationNameValue, SUBSCRIPTIONID, RESOURCEGROUP, RESOURCENAME, CALLER, CORRELATIONID
| sort by Timestamp desc
Key Fields to Investigate:
VMEventCode:
deallocate: Explicit user action (should appear in Activity Log).
instance-retirement: Azure-induced deallocation (e.g., spot VM eviction, maintenance).
CALLER: Often shows system or azure-resource-manager for platform actions.
2.2 Enable Detailed Diagnostics
If not already enabled:
VMSS Diagnostic Settings:
In your VMSS → Insights → Diagnostic Settings → Add Diagnostic Setting.
Enable VirtualMachineAgentEvents and AzureActivity streams.
Send logs to Log Analytics or Event Hub.
Scope to Specific Timestamps:
Use the exact timestamps of past incidents to filter logs and identify hidden triggers.
Step 3: Investigate Subscription Quotas & Limits
Why? Azure may silently deallocate VMs if you hit subscription quotas (e.g., vCPU limits, regional capacity).
Actions:
Check Quotas:
In Azure Portal → Subscription → Quotas → Select the affected region.
Verify limits for:
Total Core Quota
Specific VM Size Quota (e.g., Standard_DS3_v2)
Monitor Usage:
Use Azure Usage and Estimated Costs to track core usage across subscriptions/resource groups.
Contact Support if Quotas Are Hit:
Azure may deallocate VMs to enforce quotas without logging it as an explicit operation.
Step 4: Review AKS-Specific Configurations
4.1 Node OS Upgrade Channel
AKS can trigger node upgrades via Node OS Upgrade Channel (e.g., NodeImage). While you ruled out most upgrades:
Check Upgrade History:
az aks get-upgrades --name --resource-group
Look for recent Upgraded events coinciding with incidents.
Temporarily Disable Auto-Upgrades:
az aks update --name --resource-group --os-upgrade-type None
4.2 AKS Add-On Health
Some AKS add-ons (e.g., Azure Policy for AKS, Defender for Containers) can trigger VM reboots/deallocations.
Check Add-On Status:
az aks show --name --resource-group --query "addons"
Disable Suspicious Add-Ons (e.g., AzurePolicy):
az aks disable-addons --name --resource-group --add-ons AzurePolicy
Step 5: Inspect VMSS Extensions & Dependencies
Why? Malfunctioning VM extensions (e.g., Azure Monitor Agent, Network Watcher) can force deallocations.
Actions:
List VMSS Extensions:
az vmss list-extensions -g -n
Check for failed extensions (e.g., ProvisioningState: Failed).
Disable/Uninstall Problematic Extensions:
az vmss extension delete --resource-group --vmss-name --name
If this answers your query, do click Accept Answer and Up-Vote for the same. And, if you have any further query do let us know.