How to Pause Your AKS Clusters Nightly to Save Costs
Learn how to reduce Azure costs by stopping non-production AKS clusters nightly and restarting them in the morning using the Azure CLI.
Learn how to reduce Azure costs by stopping non-production AKS clusters nightly and restarting them in the morning using the Azure CLI.
Azure Kubernetes Service (AKS) enables organizations to run and scale Kubernetes applications, either in the cloud or on-premises.
The cost of running AKS clusters varies depending on the machine type and sizes for cluster nodes. For example, running an A2 instance with only 2 cores is billed at $0.12/hr. Running that instance for a full month would cost $87.60.
If you have non-production clusters for testing or QA purposes, you might not need them to be available for 24 hours per day. If your team has somewhat predictable work hours, you can set up a process to stop these clusters on a nightly basis and start them back up in the morning to save costs.
In this guide, we’ll show you how you can reduce your cloud costs by using the Azure CLI to scale down your AKS clusters nightly.
Before you stop AKS clusters, it’s important to alert any stakeholder who may be working with that cluster so they have a chance to intervene.
If your team is working unusual hours and has important jobs running, stopping the cluster could be disruptive. If no one objects to stopping the cluster for the night, then you can move on to the next step.
To stop your AKS cluster, you can run the “az aks stop” command and specify which cluster you want to stop. This will stop running both the AKS cluster’s nodes and control plane.
To verify that the cluster has successfully stopped, you can run the following command:
In the output, it should show a “powerState” of “Stopped”:
With the cluster stopped, you’ll have lower costs since you won't be paying for computing time during your team’s off hours.
The next morning, or whenever you want to resume using the cluster, you can start it up again using this command:
Just like in the last step, you can use the “az aks show” command to validate that the “powerState” is now “Running”. That output looks like this:
Stopping and starting your AKS cluster on a nightly basis is a good way to lower your Azure Costs. To avoid errors, It is recommended that you don’t stop and start your cluster repeatedly (more than once within 30 minutes).
You can consistently lower your costs by pausing non-production clusters at night, but only if the process isn’t time-intensive.
In the method described above, you need to run these commands for each cluster. If pausing your clusters takes too much time or requires manual execution, it might not become a habit and consistently lower your costs.
With Blink, you can run this automation to kick off this scale down at a scheduled time, send notifications, and wait for approvals.
When you run this automation, it executes the following steps:
You can easily customize this automation to add other steps. For example, you could add steps to scale the cluster back up after a certain amount of time.
There are over 5K automations in the Blink library that you can use right away, or you can build new automations from scratch with drag-and-drop actions to fit your unique needs.
Get started with Blink today to see how easy automation can be.
Blink is secure, decentralized, and cloud-native. Get modern cloud and security operations today.