Navigating Kubernetes Cost Optimization with Karpenter at CloudNative Days Tokyo 2023

Author: Aya Ozawa

Date: Dec 14, 2023

At CloudNative Days Tokyo 2023, one of Japan's largest tech conferences dedicated to cloud-native technologies and development, I had the opportunity to give a talk on the topic at the Kubernetes cost optimization: “FinOps! The Path to Kubernetes Cost Optimization with Karpenter”.

Presentation Overview: The Cost-Optimization Challenge in Kubernetes

One of the key techniques for reducing costs with Kubernetes is cluster autoscaling. However, the question arises whether simply introducing an autoscaler can really lead to cost reduction. In my presentation, I explored this question in depth using Karpenter in an AWS environment as a case study.

Karpenter: A Tool for Kubernetes Cost Optimization

Karpenter Optimize Costs

Karpenter is a powerful Kubernetes cluster autoscaler that is open-source and flexible. It is designed to help users optimize their costs on AWS or Azure. However, the autoscaling algorithm of Karpenter does not take into account any pricing discounts coming from AWS Savings Plans or Reserved Instances, which are commonly used by AWS users to reduce costs. So why is it ineffective if the Saving Plans are not considered?

Example: cost is not optimized

Karpenter efficiently creates cheaper instances based on public rates on-demand and Spot prices (e.g., it favors Spot instances over on-demand due to lower costs), but lacks consideration for existing Savings Plans, which may inadvertently result in additional costs. In order to effectively reduce costs, autoscaling should take into account the utilization of Savings Plans.

Our Solution: Enhancing Kubernetes Cost Optimization

CloudNatix developed a feature to optimize Kubernetes costs, while considering Savings Plans. This feature enhances Karpenter so that on-demand instances and Spot instances are automatically rebalanced based on the availability of Savings Plans. It monitors the usage of Savings Plans and their hourly commitments. CloudNatix keeps the composition of clusters in such a way that Savings Plans are neither under-utilized or over-utilized.

Predicting Savings Plan Utilization

Predict plan utilization

We utilize AWS Cost Usage Report along with the data on each cluster instance to make predictions about Savings Plan utilization. Based on these predictions, a CloudNatix agent within each cluster updates the NodePool settings of Karpenter. This adaptive approach allows Karpenter to create the most cost-effective instances based on the Savings Plan utilization to optimize spending.

Conclusion

The journey to optimal Kubernetes cost management is complex, but that goal becomes more attainable with incremental functionality additions. By integrating consideration of discount plans into autoscaling decisions, we have taken yet another novel step toward creating the best Kubernetes cost management imaginable.

Previous
Previous

CloudNatix Cloud Cost Visibility Portal

Next
Next

“Right-scaling” clusters