Optimize Kubernetes Costs with Workload Recommendations
One of the most impactful ways to reduce spend on Kubernetes infrastructure is to make sure your clusters are optimally sized for the workloads and node pools they run. Harness Cloud Cost Management (CCM) provides recommendations for your Kubernetes clusters. These recommendations show you resource optimization opportunities to potentially reduce your monthly spend.
The recommendations are computed by analyzing the past utilization of CPU and memory of your workload. The implementation uses a histogram method to compute the recommendations.
This topic describes how CCM computes workload recommendations and how you can use them to potentially reduce monthly costs.
Using recommendations without proper assessment could result in unexpected changes, such as issues with system performance or poor reliability.
In this topic:
- Before You Begin
- How are Workload Recommendations Computed?
- View Recommendations
- Next Steps
Before You Begin
How are Workload Recommendations Computed?
In Harness CCM, the workload recommendations are computed by analyzing the past utilization of CPU and memory of your workload. The implementation uses a histogram method to compute the recommendations. The computation also adds a 15% buffer to the recommended resources. The recommendations are categorized as the following:
- Cost Optimized
- Performance Optimized
The cost-optimized recommendations are computed as the following:
- The lower bound is based on the 50th percentiles of CPU samples and memory peaks.
- There is no upper bound for CPU samples and memory peaks are based on the 95th percentile. It is recommended not to set the upper bound for the CPU samples, because the CPU is considered a compressible resource. If your application starts hitting the CPU limits, Kubernetes starts throttling the pods.
- There is no limit set for the CPU. This is to avoid the throttling of the workloads when there is a spike in CPU usage. The usage of the CPU may go up in certain conditions, for example during the pod start. In such a scenario, the CPU can burst and get the required additional resources.
Since the recommendations are computed using the 50th percentile of the CPU samples and memory peaks, this may potentially lead to system performance issues. Before using cost-optimized recommendations, ensure that you evaluate the recommendation's impact thoroughly.
The performance-optimized recommendations are computed using the 95th percentile of CPU samples and memory peaks. Because of which the probability of having any effect on the performance is minimum. However, the cost may go high for the resources that are optimized using this method.
The custom option allows you to customize your recommendations by selecting the percentile for CPU and memory sample requests and limits. You can increase or decrease the request and limit coverage of the CPU and memory samples.
Simply drag the slider to adjust the percentile. The slider indicates the percentile of all the CPU and memory samples that are covered to compute the resource recommendations.
Based on your selection, the recommendations for your workload are made.
Let's try to understand how the recommendations are computed using the following examples:
Example A: Cost Optimized
The following example illustrates how the resources can be optimized using the cost-optimized recommendations:
Cluster Name: ce-prod-cluster-primary
The current resources are provisioned using
40Gi memory and
4 CPU, but the recommended resources require only
20.5Gi memory and
32m CPU for requests.
- In Cloud Costs, click Recommendations.
The recommendations page displays the following information:
- A breakdown of all the available recommendations.
- Potential Monthly Savings across your Kubernetes clusters if you apply the recommendations.
- Forecasted Monthly Spend across your Kubernetes clusters if you do not apply the recommendations.
- The Recommendation Breakdown displays the following information:
Potential monthly savings for your resource, if you apply the recommendations.
Name of the resource for which CCM displays the recommendation.
Type of the resource for which the CCM has provided the recommendations. For example, node pool or workload.
Potential Monthly Savings for the resource, if you apply the recommendations.
Type of the recommendation for your resource. For example, rightsizing or resizing. Based on your resource type, CCM recommends to rightsize or resize your CPU, memory, or node counts.
- Click the recommendation for which you want to view the details. You can use a filter to select the resource or recommendation for which you want to view the details.You can filter by:
- Name: Each Kubernetes namespace in the cluster.
- Resource Type: The type of resources for which the recommendation is displayed. Currently, CCM supports node pool and workload.
- Namespace: Each Kubernetes namespace in the cluster.
- Cluster Name: Each Kubernetes cluster in your infrastructure.
- Monthly savings greater than: Filter by potential monthly savings greater than the specified amount. For example, all the recommendations with potential monthly savings of more than $1000.
- Monthly cost greater than: Filter by forecasted monthly spend greater than the specified amount. For example, all the recommendations with forecasted monthly spend of more than $1000.
- The recommendation for the selected resource is displayed.
- You can use this information to optimize your resources to potentially reduce your monthly cloud costs.