Stopping a AKS cluster with Azure CLI

Working with an AKS cluster (meaning rather experiments than production systems) needs some preparations and time to provision if you don’t already have a cluster running, and you surely make some adjustments during the work.

So you started Friday, made good progress, work finished for the day, but now….

  • Leave the cluster running to continue Monday? Good for Microsoft, bad for your credit card
  • Deleting the entire cluster? Bad for your motivation next Monday to continue the work

To save compute costs, one first option is to scale down the user nodes to 0 manually. But then there are still costs left for some components. For example, the standard system nodepool always needs at least one node running, and maybe you already have more than one user node pool, so more configuration is left. Therefore, the best option is to stop the complete cluster if you are done for the moment and restart it again if you would like to continue.

To use this option, keep in mind some limitations:

  • Only possible with shell, not over the portal
  • Only for clusters using scale sets
  • Cluster can only be stopped for a duration of 12 months

To stop the cluster, open the cloud shell in bash mode and use the following line of code, replacing your clustername and resource groub name:

az aks stop --name k8sdemocluster --resource-group k8s

After using the show-command you can see the cluster is stopped and the portal tells you that all worker nodes are down and the scale set behind has no instances:

az aks show --name k8sdemocluster --resource-group k8s

Worker nodes after stopping the cluster:

If want to continue, just use the start command to wake up the cluster again:

az aks start --name k8sdemocluster --resource-group k8s

Worker nodes after starting again:

VM scale set instances:

Remaining Costs:

You should keep in mind that your costs are NOT down to zero. As you can see in the next picture, of course there remaining costs e.g. for the loadbalancer and public IPs (deployed because of an external k8s loadbalancer service, but much less then in comparison to keep the cluster up and running.

Displayed in the last picture, you can see the cost analysis for 3 days with a stopped cluster, the VNet costs are representend by the provisioned Public IPs:

For additional information, check https://docs.microsoft.com/en-us/azure/aks/start-stop-cluster

Enjoy your cluster (-:

Leave a comment

Your email address will not be published. Required fields are marked *