From 8a705f7dc2ad7812e54741b4fbef2ebbdf1a6f89 Mon Sep 17 00:00:00 2001 From: Elizabeth Labor Date: Thu, 29 Feb 2024 20:39:12 -0500 Subject: [PATCH 1/2] Make upper and lower bounds configurable for memory and cpu --- .../pkg/recommender/logic/recommender.go | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/vertical-pod-autoscaler/pkg/recommender/logic/recommender.go b/vertical-pod-autoscaler/pkg/recommender/logic/recommender.go index 9a7ad8e51be7..77471cbc5748 100644 --- a/vertical-pod-autoscaler/pkg/recommender/logic/recommender.go +++ b/vertical-pod-autoscaler/pkg/recommender/logic/recommender.go @@ -25,10 +25,15 @@ import ( ) var ( - safetyMarginFraction = flag.Float64("recommendation-margin-fraction", 0.15, `Fraction of usage added as the safety margin to the recommended request`) - podMinCPUMillicores = flag.Float64("pod-recommendation-min-cpu-millicores", 25, `Minimum CPU recommendation for a pod`) - podMinMemoryMb = flag.Float64("pod-recommendation-min-memory-mb", 250, `Minimum memory recommendation for a pod`) - targetCPUPercentile = flag.Float64("target-cpu-percentile", 0.9, "CPU usage percentile that will be used as a base for CPU target recommendation. Doesn't affect CPU lower bound, CPU upper bound nor memory recommendations.") + safetyMarginFraction = flag.Float64("recommendation-margin-fraction", 0.15, `Fraction of usage added as the safety margin to the recommended request`) + podMinCPUMillicores = flag.Float64("pod-recommendation-min-cpu-millicores", 25, `Minimum CPU recommendation for a pod`) + podMinMemoryMb = flag.Float64("pod-recommendation-min-memory-mb", 250, `Minimum memory recommendation for a pod`) + targetCPUPercentile = flag.Float64("target-cpu-percentile", 0.9, "CPU usage percentile that will be used as a base for CPU target recommendation. Doesn't affect CPU lower bound, CPU upper bound nor memory recommendations.") + lowerBoundCPUPercentile = flag.Float64("recommendation-lower-bound-cpu-percentile", 0.5, `CPU usage percentile that will be used for the lower bound on CPU recommendation.`) + upperBoundCPUPercentile = flag.Float64("recommendation-upper-bound-cpu-percentile", 0.95, `CPU usage percentile that will be used for the upper bound on CPU recommendation.`) + targetMemoryPercentile = flag.Float64("target-memory-percentile", 0.9, "Memory usage percentile that will be used as a base for memory target recommendation. Doesn't affect memory lower bound nor memory upper bound.") + lowerBoundMemoryPercentile = flag.Float64("recommendation-lower-bound-memory-percentile", 0.5, `Memory usage percentile that will used for the lower bound on memory recommendation.`) + upperBoundMemoryPercentile = flag.Float64("recommendation-upper-bound-memory-percentile", 0.95, `Memory usage percentile that will used for the upper bound on memory recommendation.`) ) // PodResourceRecommender computes resource recommendation for a Vpa object. @@ -102,16 +107,9 @@ func FilterControlledResources(estimation model.Resources, controlledResources [ // CreatePodResourceRecommender returns the primary recommender. func CreatePodResourceRecommender() PodResourceRecommender { - lowerBoundCPUPercentile := 0.5 - upperBoundCPUPercentile := 0.95 - - targetMemoryPeaksPercentile := 0.9 - lowerBoundMemoryPeaksPercentile := 0.5 - upperBoundMemoryPeaksPercentile := 0.95 - - targetEstimator := NewPercentileEstimator(*targetCPUPercentile, targetMemoryPeaksPercentile) - lowerBoundEstimator := NewPercentileEstimator(lowerBoundCPUPercentile, lowerBoundMemoryPeaksPercentile) - upperBoundEstimator := NewPercentileEstimator(upperBoundCPUPercentile, upperBoundMemoryPeaksPercentile) + targetEstimator := NewPercentileEstimator(*targetCPUPercentile, *targetMemoryPercentile) + lowerBoundEstimator := NewPercentileEstimator(*lowerBoundCPUPercentile, *lowerBoundMemoryPercentile) + upperBoundEstimator := NewPercentileEstimator(*upperBoundCPUPercentile, *upperBoundMemoryPercentile) targetEstimator = WithMargin(*safetyMarginFraction, targetEstimator) lowerBoundEstimator = WithMargin(*safetyMarginFraction, lowerBoundEstimator) From 5aaeb83d7ece2845af5adf7bedad97e7babdcd36 Mon Sep 17 00:00:00 2001 From: Elizabeth Labor <138024120+emla9@users.noreply.github.com> Date: Tue, 26 Mar 2024 13:36:25 -0400 Subject: [PATCH 2/2] update FAQ with recommender target/upper/lower parameters --- vertical-pod-autoscaler/FAQ.md | 6 ++++++ .../pkg/recommender/logic/recommender.go | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/vertical-pod-autoscaler/FAQ.md b/vertical-pod-autoscaler/FAQ.md index 419100dd0610..42ac7067229a 100644 --- a/vertical-pod-autoscaler/FAQ.md +++ b/vertical-pod-autoscaler/FAQ.md @@ -169,6 +169,12 @@ Name | Type | Description | Default `recommendation-margin-fraction` | Float64 | Fraction of usage added as the safety margin to the recommended request | 0.15 `pod-recommendation-min-cpu-millicores` | Float64 | Minimum CPU recommendation for a pod | 25 `pod-recommendation-min-memory-mb` | Float64 | Minimum memory recommendation for a pod | 250 +`target-cpu-percentile` | Float64 | CPU usage percentile that will be used as a base for CPU target recommendation | 0.9 +`recommendation-lower-bound-cpu-percentile` | Float64 | CPU usage percentile that will be used for the lower bound on CPU recommendation | 0.5 +`recommendation-upper-bound-cpu-percentile` | Float64 | CPU usage percentile that will be used for the upper bound on CPU recommendation | 0.95 +`target-memory-percentile` | Float64 | Memory usage percentile that will be used as a base for memory target recommendation | 0.9 +`recommendation-lower-bound-memory-percentile` | Float64 | Memory usage percentile that will be used for the lower bound on memory recommendation | 0.5 +`recommendation-upper-bound-memory-percentile` | Float64 | Memory usage percentile that will be used for the upper bound on memory recommendation | 0.95 `checkpoints-timeout` | Duration | Timeout for writing checkpoints since the start of the recommender's main loop | time.Minute `min-checkpoints` | Int | Minimum number of checkpoints to write per recommender's main loop | 10 `memory-saver` | Bool | If true, only track pods which have an associated VPA | false diff --git a/vertical-pod-autoscaler/pkg/recommender/logic/recommender.go b/vertical-pod-autoscaler/pkg/recommender/logic/recommender.go index 77471cbc5748..4afa93d69e7f 100644 --- a/vertical-pod-autoscaler/pkg/recommender/logic/recommender.go +++ b/vertical-pod-autoscaler/pkg/recommender/logic/recommender.go @@ -32,8 +32,8 @@ var ( lowerBoundCPUPercentile = flag.Float64("recommendation-lower-bound-cpu-percentile", 0.5, `CPU usage percentile that will be used for the lower bound on CPU recommendation.`) upperBoundCPUPercentile = flag.Float64("recommendation-upper-bound-cpu-percentile", 0.95, `CPU usage percentile that will be used for the upper bound on CPU recommendation.`) targetMemoryPercentile = flag.Float64("target-memory-percentile", 0.9, "Memory usage percentile that will be used as a base for memory target recommendation. Doesn't affect memory lower bound nor memory upper bound.") - lowerBoundMemoryPercentile = flag.Float64("recommendation-lower-bound-memory-percentile", 0.5, `Memory usage percentile that will used for the lower bound on memory recommendation.`) - upperBoundMemoryPercentile = flag.Float64("recommendation-upper-bound-memory-percentile", 0.95, `Memory usage percentile that will used for the upper bound on memory recommendation.`) + lowerBoundMemoryPercentile = flag.Float64("recommendation-lower-bound-memory-percentile", 0.5, `Memory usage percentile that will be used for the lower bound on memory recommendation.`) + upperBoundMemoryPercentile = flag.Float64("recommendation-upper-bound-memory-percentile", 0.95, `Memory usage percentile that will be used for the upper bound on memory recommendation.`) ) // PodResourceRecommender computes resource recommendation for a Vpa object.