-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
POL-1405 Replace deprecated Kubecost endpoints for Kubecost Cluster Policy #2833
base: master
Are you sure you want to change the base?
Conversation
Generated by 🚫 Danger |
cost/kubecost/cluster/kubecost_cluster_rightsizing_recommendations.pt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I requested some specific changes, but more broadly, there appear to be a lot more changes here than just updating deprecated API endpoints.
Please fully document all changes in the changelog.
cost/kubecost/cluster/CHANGELOG.md
Outdated
@@ -1,5 +1,9 @@ | |||
# Changelog | |||
|
|||
## v0.3.2 | |||
|
|||
- Replace usage of Kubecost deprecated endpoints for newest versions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awkwardly worded. Recommended change:
- Updated API endpoints for Kubecost. Functionality unchanged.
cost/kubecost/cluster/kubecost_cluster_rightsizing_recommendations.pt
Outdated
Show resolved
Hide resolved
cost/kubecost/cluster/kubecost_cluster_rightsizing_recommendations.pt
Outdated
Show resolved
Hide resolved
cost/kubecost/cluster/kubecost_cluster_rightsizing_recommendations.pt
Outdated
Show resolved
Hide resolved
cost/kubecost/cluster/kubecost_cluster_rightsizing_recommendations.pt
Outdated
Show resolved
Hide resolved
added new params for use of the new endpoint
…red_core and changelog
cost/kubecost/cluster/CHANGELOG.md
Outdated
## v0.3.3 | ||
|
||
- Updated API endpoints for Kubecost. | ||
- Added two new params param_allow_shared_core,param_include_overhead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can use backticks or quotes here around the parameter names to indicate they are code or field names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joseluiszuflores, I've added few comments with questions for clarification.
category "Include overhead" | ||
label "Include overhead" | ||
allowed_values "true", "false" | ||
description " By enabling this option, Kubecost takes into account not only the resources used by applications and containers, but also those needed to operate and maintain the Kubernetes environment" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional leading space at the beginning can be removed.
result "result" | ||
code <<-'EOS' | ||
result = [] | ||
// Loop over each accountKey in data.accountID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment can be removed, as the code already shows that data.accountID is being iterated.
// Loop over each accountKey in data.accountID | ||
for (var accountKey in data.accountID) { | ||
var accountData = data.accountID[accountKey]; | ||
// Extract required fields and push them as a flat object to extractedData |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may be, the comment can be removed here as well as the code clearly indicates what it is doing.
@@ -141,10 +158,10 @@ script "js_currency", type:"javascript" do | |||
result "result" | |||
code <<-EOS | |||
code = ds_kubecost_currency_code['code'].toUpperCase().trim() | |||
// using default code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment can be removed.
totalNodeCount: crs['totalNodeCount'], | ||
totalRAMGB: crs['totalRAMGB'], | ||
totalVCPUs: crs['totalVCPUs'], | ||
monthlyRate: (Math.round(crs['monthlyRate'] * 100) / 100 ).toFixed(2), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the precision and return type varies here. Is this intended?
Initial code will return 3 decimals (number) and the new code will return 2 decimals (string).
totalRAMGB: crs['totalRAMGB'], | ||
totalVCPUs: crs['totalVCPUs'], | ||
monthlyRate: (Math.round(crs['monthlyRate'] * 100) / 100 ).toFixed(2), | ||
totalMonthlyCost: (Math.round(recommendation['totalMonthlyCost'] * 100) / 100 ).toFixed(2), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loooks like the precision and return type varies here. Is this intended?
Initial code will return 3 decimals (number) and the new code will return 2 decimals (string).
monthlyRate: (Math.round(crs['monthlyRate'] * 100) / 100 ).toFixed(2), | ||
totalMonthlyCost: (Math.round(recommendation['totalMonthlyCost'] * 100) / 100 ).toFixed(2), | ||
// Note: Savings is presented as a negative value. Hence why we multiply by a negative number to invert it | ||
savings: (Math.round(recommendation['monthlySavings'] * 100) / 100 ).toFixed(2), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loooks like the precision and return type varies here. Is this intended and not inline with the comment in line no. 324
Initial code will return 3 decimals (number) and the new code will return 2 decimals (string).
end | ||
|
||
script "js_recommendations", type: "javascript" do | ||
parameters "ds_cluster_sizing", "ds_currency", "ds_applied_policy", "param_strategy", "param_min_nodes", "param_lookback", "param_target_util" | ||
parameters "ds_cluster_sizing", "ds_currency","ds_applied_policy", "param_strategy", "param_min_nodes", "param_lookback", "param_target_util" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistency in spacing.
parameters "ds_cluster_sizing", "ds_currency","ds_applied_policy", "param_strategy", "param_min_nodes", "param_lookback", "param_target_util" | |
parameters "ds_cluster_sizing", "ds_currency", "ds_applied_policy", "param_strategy", "param_min_nodes", "param_lookback", "param_target_util" |
datasource "ds_recommendations" do | ||
run_script $js_recommendations, $ds_cluster_sizing, $ds_currency, $ds_applied_policy, $param_strategy, $param_min_nodes, $param_lookback, $param_target_util | ||
run_script $js_recommendations, $ds_cluster_sizing, $ds_currency, $ds_applied_policy,$param_strategy, $param_min_nodes, $param_lookback, $param_target_util |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistency in spacing.
run_script $js_recommendations, $ds_cluster_sizing, $ds_currency, $ds_applied_policy,$param_strategy, $param_min_nodes, $param_lookback, $param_target_util | |
run_script $js_recommendations, $ds_cluster_sizing, $ds_currency, $ds_applied_policy, $param_strategy, $param_min_nodes, $param_lookback, $param_target_util |
description "By enabling this option, Kubecost takes into account not only the resources used by applications and containers, but also those needed to operate and maintain the Kubernetes environment" | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
The endpoint we are currently using has been deprecated “/model/savings/clusterSizing"
It still works but only returns one cluster rather than all clusters.
The new endpoint is returns a different response “/model/savings/clusterSizingETL" and simply adding ETL onto the end of our current end point in the policy returns null values in ds_cluster_sizing
This endpoint returns all cluster recommendations in one response.
The
ds_clusters
function has been created to include two new parameters in the Kubecost API call:param_allow_shared_core: This boolean parameter indicates whether shared cores should be allowed in the cluster sizing calculation. By default, Kubecost may not consider the shared cores between pods as part of the cost savings calculations. With this new parameter, the explicit inclusion of shared cores in the calculations can be enabled. This is useful for environments where resources are shared between multiple pods, and a more accurate estimate of potential savings is desired.
param_include_overhead: This boolean parameter specifies whether overhead should be included in the calculation. In many cases, it is necessary to consider additional costs, such as overhead costs associated with resource management, when calculating savings. With this parameter, the option to include these additional costs is provided, allowing for a more accurate representation of the total savings.
Changes Made:
ds_clusters
function.Issues Resolved
Link to Example Applied Policy
https://app.flexeratest.com/orgs/1105/automation/applied-policies/projects/60073?policyId=673520d66168ce351f89f548
Contribution Check List