Search
Close this search box.

Schedule AKS clusters to run during Business Hours

Share This Post

In the dynamic landscape of cloud computing, optimizing costs is a crucial aspect of managing resources efficiently.
Microsoft Azure Kubernetes Services (AKS) is a powerful platform for deploying, managing, and scaling containerized applications.
While AKS provides flexibility and scalability, it’s equally important for organizations to adopt cost-saving measures.
One effective strategy is shutting down and starting AKS clusters during business hours.

In this blog post, I will explore the benefits of shutting down AKS clusters in Azure to save costs on an authomatic approach.
I will use a low code Logic App approach to shutdown and startup the AKS clusters flagged by a specific tag.

  1. Creating a Logic App like I did in my Azure environment (comsumption based)


  2. Adding the tag to the AKS cluster(s)


  3. Starting with the creation of the flow in the logic App

Adding some recured action to the logic app to make sure it will start before business hours.

  1. Start with a schedule action and list all the resources from a subscription


  2. Extract the correct tags from the payload

 {
 "items": {
     "properties": {
         "id": {
             "type": "string"
         },
         "identity": {
             "properties": {
                 "principalId": {
                     "type": "string"
                 },
                 "tenantId": {
                     "type": "string"
                 },
                 "type": {
                     "type": "string"
                 }
             },
             "type": "object"
         },
         "location": {
             "type": "string"
         },
         "name": {
             "type": "string"
         },
         "tags": {
             "properties": {
                 "Hours": {
                     "type": "string"
                 }
             },
             "type": "object"
         },
         "type": {
             "type": "string"
         }
     },
     "required": [
         "id",
         "name",
         "type",
         "location",
         "identity",
         "tags"
     ],
     "type": "object"
 },
 "type": "array"
}
  1. Now, we got all the resources that are tagged with Business, so they need to run only during business hours.
    Let’s start these AKS clusters with a Foreach.



    Here you can find the code for the split function!
    split(outputs('Get_resource_Id'),'/')[4]

For the shutdown it’s the same flow only the last part is different.

In the shift to the cloud cost optimization remains a top priority for organizations leveraging services like Azure Kubernetes Service.
Shutting down AKS clusters during idle periods is a practical and effective strategy to reducing costs, aligning expenses with actual usage, and maintaining a secure and efficient cloud environment.

Happy Cloud! 🙂

P.S If you want receive the ARM template form the flows, just send me an e-mail 😉

More To Explore

Azure Kubernetes security common misconceptions

Azure Kubernetes Service (AKS) has emerged as a leading platform for container orchestration, offering scalability (with Keda), flexibility, and an easy management panel. However, like