Share:
Twitter
LinkedIn
Facebook
Reddit
Whatsapp
Follow by Email
Reading Time: 4 minutes

Update: This has now gone to GA and you do not need to register the preview features.

I am sure like me, you have at least one Azure Kubernetes Service (AKS) Cluster that does not need to be on all the time, probably a development cluster. Before now, you have been able to scale you User Node Pools down to 0, but the system node pool was still required to run the system components. You can read more about System and User node pools at https://pixelrobots.co.uk/2020/06/azure-kubernetes-service-aks-system-and-user-node-pools/. With this new feature the control plane and agent nodes are stopped, meaning that your cluster is “turned off”. This means you will save money on the compute costs. All objects and your cluster sate will be maintained ready for you when you start your cluster. As of writing this article the feature is currently in preview, so please do not try this on a cluster your business needs.

Before you can begin

You will need to install/update register the aks-preview extension. To do this you can use the following commands.

Next you will need to register the extension. To do that you can use the following command.

After a few minutes you will need to check to see if the status of this feature is registered. To do that run the following. If it still shows Registering just wait a few minutes longer.

Once it shows registered you can use the following command to refresh the Microsoft.ContainerService resource provider to pick up the updates.

Stopping the cluster

Below I will show you the command to Stop your AKS cluster. Don’t worry, it is really easy, and I am sure you can easily guess the command. Before you stop the cluster there is one thing to note. The cluster state is only preserved for 12 months. If you try to start it after 12 months you will not be able to. Another thing is you can only start or delete a stopped cluster. To do operations such as scale or upgrades you will need to start the cluster.

Also, if you are using Pod Disruption Budgets stopping the cluster can take longer as the drain process will take longer to complete. This is the same when you upgrade node pools.

Enough warnings, here is the command to stop the cluster.

That’s your AKS cluster all stopped. You can use the command az aks show to check the power state of your cluster. If it says stopped then the command completed successfully. When using Windows node pools, you will see that it takes a short while to stop that node pool. You can also check in the Azure portal. Go to the node pool blade to check the state.

As you will see it shows 0 nodes. This means the cluster has been successfully stopped.

Starting the cluster

Again, this is really easy to do. I am sure you have even guessed the command already.

Your cluster will now be started. You can check the portal again or just use kubectl to query a resource in your cluster like nodes.

How cool is that? You can now start and stop your AKS cluster to save money and it’s super easy. Once out of preview, I would like to see it as an automation task so you can schedule the stop and start of the cluster. Hopefully, that will come but failing that you could easily create your own logic app to do this. I think this feature is a must for clusters that you do not need on all the time and where you don’t want to go through the full DevOps cycle of creating the cluster each morning.

Thank you for reading and I hope you found this article helpful, if you have any questions please reach out.

Share:
Twitter
LinkedIn
Facebook
Reddit
Whatsapp
Follow by Email
Categories: AKSAzure

Pixel Robots.

I’m Richard Hooper aka Pixel Robots. I started this blog in 2016 for a couple reasons. The first reason was basically just a place for me to store my step by step guides, troubleshooting guides and just plain ideas about being a sysadmin. The second reason was to share what I have learned and found out with other people like me. Hopefully, you can find something useful on the site.

0 Comments

Leave a Reply

Avatar placeholder

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