Stop all compute in AKS (Azure Managed Kubernetes)
You could use the Azure CLI to stop the the entire cluster:
az aks stop --name myAksCluster --resource-group myResourceGroup
And start it again with
az aks start --name myAksCluster --resource-group myResourceGroup
Before this feature, it was possible to stop the virtual machines via Powershell:
az vm deallocate --ids $(az vm list -g MC_my_resourcegroup_westeurope --query "[].id" -o tsv)
Replace MC_my_resourcegroup_westeurope
with the name of your resource group that contains the VM(s).
When you want to start the VM(s) again, run:
az vm start --ids $(az vm list -g MC_my_resourcegroup_westeurope --query "[].id" -o tsv)
Only VMs cost money out of all AKS resources (well, VHDs as well, but you cannot really stop those). So you only need to take care of those. Edit: Public Ips also cost money, but you cannot stop those either.
For my AKS cluster I just use portal and issue stop\deallocate command. And start those back when I need them (everything seems to be working fine).
You can use REST API\powershell\cli\various SKDs to achieve the same result in an automated fashion.
Above method (az vm <deallocate|start> --ids $(...)
) no longer seems to work.
Solved by first listing the VM scale sets and use these to deallocate/start:
$ResourceGroup = "MyResourceGroup"$ClusterName = "MyAKSCluster"$Location = "westeurope"$vmssResourceGroup="MC_${ResourceGroup}_${ClusterName}_${Location}"# List all VM scale sets$vmssNames=(az vmss list --resource-group $vmssResourceGroup --query "[].id" -o tsv | Split-Path -Leaf)# Deallocate first instance for each VM scale set$vmssNames | ForEach-Object { az vmss deallocate --resource-group $vmssResourceGroup --name $_ --instance-ids 0}# Start first instance for each VM scale set$vmssNames | ForEach-Object { az vmss start --resource-group $vmssResourceGroup --name $_ --instance-ids 0}