Introduction
Kubernetes has become the go-to platform for managing containerized applications, offering powerful autoscaling mechanisms to handle workload demands. The Horizontal Pod Autoscaler (HPA) and Vertical Pod Autoscaler (VPA) enable dynamic scaling but don’t fully address optimal resource allocation-especially at the node level. This article explores the limitations of Kubernetes’ scaling and highlights node-level right-sizing as a complementary solution for efficient resource utilization.
Kubernetes Autoscaling: The Basics
Kubernetes offers two main autoscaling mechanisms:
- Horizontal Pod Autoscaler (HPA): HPA adjusts the number of pod replicas based on observed metrics like CPU and memory. It’s effective for stateless applications but doesn’t optimize the underlying nodes’ resource allocation. Stateful workloads can face issues as HPA doesn’t maintain state across scaling events.
- Vertical Pod Autoscaler (VPA): VPA adjusts the resource requests and limits of pods but may restart them, causing potential downtime. While it works well for vertical scaling, it’s not ideal for stateful applications needing consistent uptime.
The Limitations of Kubernetes Autoscaling
While HPA and VPA play key roles, they have limitations:
- Overprovisioning and Resource Waste: HPA may add pods to meet peak demand, but often those replicas aren’t fully utilized, resulting in overprovisioning. Similarly, VPA can lead to resource inefficiency during periods of low demand.
- Node-Level Resource Imbalance: HPA and VPA do not address node-level optimization, potentially leaving nodes underutilized, leading to unnecessary cloud costs.
- Pod Restarts and Downtime with VPA: VPA’s vertical scaling may require restarting pods, making it less suitable for stateful applications that require uninterrupted uptime.
Node-Level Right-Sizing: Complementary Optimization
Right-sizing at the node level aims to address inefficiencies within infrastructure by dynamically adjusting node resource allocation based on real-time demand. If the aggregated resource usage within a node is under a certain threshold, node level right sizing allows idle resources to be released seamlessly for cost savings. When the resource utilization goes up, we can allocate more resources for the node to accommodate the increasing need. All these can be done in a way that is completely transparent to Kubernetes and applications. This complements HPA and VPA by optimizing nodes, ensuring workloads receive the right resources without overprovisioning or underutilization.
Node-level right-sizing provides key benefits:
- Better Resource Efficiency: Nodes are dynamically adjusted based on demand, eliminating resource waste.
- Improved Reliability for Stateful Workloads: Live migration helps stateful applications access consistent resources without downtime.
- Proactive and Predictive Scaling: Real-time insights help maintain the right capacity, preventing job termination or performance degradation.
Real-Time Right-Sizing with Live Migration
Live migration is crucial for real-time right-sizing, especially for stateful applications. It allows workloads to be transferred seamlessly between nodes with different sizes without downtime, ensuring resource adjustments do not disrupt application continuity. This means stateful workloads can benefit from dynamic right-sizing without service interruption.
Karpenter and Right-Sizing: A Perfect Match
Karpenter, AWS’s open-source tool, is designed to optimize Kubernetes autoscaling by improving node provisioning and handling pod placement. It uses bin-packing to consolidate workloads efficiently on nodes, reducing the number of nodes and improving resource utilization. However, there are challenges:
- Pod Restarts and Limited Support for Stateful Workloads: Karpenter’s bin-packing often requires restarting pods to optimize placement, which can be disruptive to stateful applications that cannot tolerate interruptions. As a result, Karpenter can’t optimize these workloads.
- Focus on Fragmentation, Not Over-Provisioning: While Karpenter is effective at reducing node fragmentation, it doesn’t address vertical scaling at the pod level. If a pod is over-provisioned with excessive CPU or memory, Karpenter’s bin-packing won’t optimize it, potentially leaving resource waste.
This is where node-level right-sizing comes into play. By focusing on reducing overprovisioning within nodes, right-sizing complements Karpenter’s work on bin-packing. Here’s how they work together:
- Karpenter for Node Consolidation: Karpenter improves utilization by packing pods onto nodes efficiently, reducing fragmentation.
- Right-Sizing for Reducing Over-Provisioning: Right-sizing optimizes node resources to prevent over-allocation, ensuring that workloads use only the resources they need without impacting performance.
Together, Karpenter and node-level right-sizing provide a holistic solution to cloud optimization: Karpenter handles the consolidation of workloads, while right-sizing focuses on the efficient allocation of resources within those nodes.
Use Cases for Right-Sizing in Kubernetes
Node-level right-sizing benefits several use cases in cloud-native environments:
- AI/ML and High-Performance Computing (HPC): These workloads often have unpredictable spikes and lulls. Right-sizing nodes ensures they’re scaled optimally for these dynamic demands.
- Non-Production Environments: Right-sizing optimizes development, testing, and staging environments that don’t need consistent resource availability.
- Stateful Applications: Live migration allows stateful workloads to access resources dynamically without downtime.
A Better Way to Manage Kubernetes Resources
As the cloud-native ecosystem matures, companies are shifting towards automation and smarter resource management. The next wave of Kubernetes efficiency lies in this layered approach: let HPA and VPA handle your pods, let Karpenter manage node availability and placement, and let node-level right-sizing ensure those nodes are operating efficiently.
Together, they create a balanced Kubernetes cluster that keeps costs low and performance high. By embracing node-level right-sizing, you’re not just adding more tables for your guests-you’re ensuring each table is the perfect size, that your party flows without interruption, and that you’re getting the best bang for your buck.
Conclusion: Achieve a Balanced, Cost-Efficient Kubernetes Environment
The journey to cloud optimization doesn’t stop at the application layer. While HPA and VPA are important for scaling your workloads, focusing on node-level right-sizing is the missing piece to achieving true cloud efficiency. With live migration enabling real-time adjustments for stateful workloads, and tools like Karpenter ensuring enough capacity is available, right-sizing at the node level brings everything together for a cost-effective, high-performing Kubernetes environment.
To learn more about Kubernetes and the cloud native ecosystem, join us at KubeCon + CloudNativeCon North America, in Salt Lake City, Utah, on November 12-15, 2024.
##
ABOUT THE AUTHOR
Nayan Lad, Product Marketing Manager at Exostellar
Nayan Lad is the product marketing manager at Exostellar, where he has played a pivotal role in shaping the company’s sales, marketing, product development and operations for the past four years. Holding a Masters of Engineering in Engineering Management from Cornell University, Nayan possesses a deep interest and expertise in cloud computing, FinOps and Kubernetes. His unique blend of technical knowledge and management skills underscores his proficiency in navigating the complexities of the tech industry and driving innovative solutions.





