Blushoe logo

26.02.2025

Lower Cloud Costs without Compromising Performance

Cost Optimization of an Azure Kubernetes Cluster

Cloud resources are powerful and practical, but expensive - especially Kubernetes clusters. In this blog post, we show how we successfully implemented Azure Kubernetes Service Cost Optimization in a existing project. We present strategies, tools, and best practices that helped reduce AKS costs without compromising performance.

Cost Optimization of an Azure Kubernetes Cluster

Table of Contents

Starting Point

The project is fully operated in the Azure Cloud and uses two AKS Kubernetes clusters: a Staging and a Production system. These generate cloud resources like virtual machines, hard drives, load balancers, and IP addresses.

Additionally, various Azure services are used, including a Managed Database, Storage for Media Data, and a Redis instance. Before optimization, costs were around 100 € per day.

Before

Analysis with Azure Cost Management

The first step towards Kubernetes cluster cost management was an analysis using Azure Cost Management for Kubernetes. The tool provides detailed insights into which services cost how much - a good starting point to look more closely at which services might be worthwhile.

We directly noticed a deactivated, but still existing VM. This caused few costs, but was unnecessary and could be removed.

The biggest cost drivers were the virtual machines - especially the Node Pools of both AKS clusters. A detailed look at Kubernetes resource optimization showed that the number of nodes was not optimally matched to actual needs. Azure also supported this - namely with monitoring of CPU and memory utilization.

Azure Log Analytics also proved to be an unexpectedly high cost point. This was configured for the Production cluster. All logs of Kubernetes resources were stored long-term without being actively used.

Implemented Measures

Optimize Node Pools

Based on these insights, we implemented a series of targeted optimization measures.

  • The Staging Cluster was reduced from 3 to 1-3 Nodes - with Auto-Scaling. Typically, only 2 Nodes are now running.
  • The Production Cluster now uses two Node Pools: System Mode and User Mode.

Adjust Virtual Machines

A VM that was too large for the Managed Database was downsized. Thanks to Azure Cost Management for Kubernetes, it was clear that the existing computing power was overdimensioned. The conversion was seamless and can be reverted at any time if demand increases.

Deactivate Log Analytics

The high costs of Azure Log Analytics were disproportionate to the actual usage. Deactivation led to significant savings that only became fully noticeable after a few weeks, as logs were stored for up to 90 days.

Deactivate Log Analytics

Remove Unnecessary Resources

An unused VM of an old GitLab Runner was deleted. Although it only caused about 10€ per month, such "forgotten" resources accumulate over time.

Optimize Operating Times with KEDA

Both AKS clusters are only used during working hours. Using KEDA Auto-Scaling, operating times are defined so that applications outside these times are automatically scaled down. This additionally reduces AKS costs, as fewer nodes are active.

Result: Over 50% Cost Reduction

It took some time until the full extent of the cost savings became visible. But the optimization measures paid off. Operating costs dropped from around 100€ to 45€ per day - a saving of more than 50%!

Some measures could have been implemented earlier. Others, like the Kubernetes Cluster Cost Management through Operating Time Optimization, required more planning but will pay off long-term.

Lessons Learned

✔ Regular cost analysis is worthwhile - without it, we would not have discovered unnecessary resources.
✔ Consistently use Auto-Scaling - fixed node sizes are often inefficient.
✔ Question logging - not every log service is necessary or economical.

Want to learn more about Kubernetes & Cost Optimization?

Learn more about our Kubernetes Development Services

Frequently Asked Questions

1. How can I reduce the costs of my Azure Kubernetes Cluster?

You can reduce AKS costs by activating Auto-Scaling, removing unused resources, optimizing log services, and adjusting operating times with KEDA.

2. Which tools help with Azure Kubernetes Cost Optimization?

Azure Cost Management for Kubernetes offers detailed analyses. Additionally, the Kubernetes Autoscaler and KEDA help with dynamically scaling nodes.

3. Why is Auto-Scaling important for cost optimization in AKS?

Auto-Scaling adjusts the number of nodes to actual needs and prevents over-provisioning - an effective measure for Kubernetes resource optimization.

4. How does deactivating Azure Log Analytics affect costs?

Log Analytics can cause high running costs. If you do not actively use the logs, deactivation can lead to significant savings.

5. Is there a way to reduce Kubernetes Clusters outside working hours?

Yes! With KEDA Auto-Scaling you can automatically scale down your clusters outside business hours and save costs.

6. How often should I review my Azure Kubernetes Cost Management?

A monthly analysis with Azure Cost Management helps identify inefficient resources early.

7. Which Node-Pool strategy is the most cost-efficient for AKS?

A combination of System-Mode and User-Mode pools with Auto-Scaling is ideal. System-Mode should remain stable, while User-Mode dynamically scales.

8. When does it make sense to use Spot Instances in AKS?

Spot Instances are cost-effective, but not always available. They are suitable for non-critical workloads with flexible execution times.

9. Can I save costs by switching to another cloud provider?

Yes, Azure is not always the most cost-effective option. It's worth checking alternatives like Linode or Hetzner if your requirements allow.


Do you have questions or an opinion? With your GitHub account you can let us know...