Skip to content

Commit 40b1605

Browse files
committed
Move more recommender flags into config
I had missed these on previous commits since they aren't in main.go
1 parent 9c39396 commit 40b1605

File tree

10 files changed

+247
-122
lines changed

10 files changed

+247
-122
lines changed

vertical-pod-autoscaler/pkg/recommender/config/config.go

Lines changed: 70 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"k8s.io/autoscaler/vertical-pod-autoscaler/common"
2929
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/input"
3030
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/model"
31-
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/routines"
3231
)
3332

3433
// RecommenderConfig holds all configuration for the recommender component
@@ -37,13 +36,31 @@ type RecommenderConfig struct {
3736
CommonFlags *common.CommonFlags
3837

3938
// Recommender-specific flags
40-
RecommenderName string
41-
MetricsFetcherInterval time.Duration
42-
CheckpointsGCInterval time.Duration
43-
Address string
44-
Storage string
45-
MemorySaver bool
46-
UpdateWorkerCount int
39+
RecommenderName string
40+
MetricsFetcherInterval time.Duration
41+
CheckpointsGCInterval time.Duration
42+
CheckpointsWriteTimeout time.Duration
43+
Address string
44+
Storage string
45+
MemorySaver bool
46+
UpdateWorkerCount int
47+
MinCheckpointsPerRun int
48+
49+
// Recommendation configuration
50+
SafetyMarginFraction float64
51+
PodMinCPUMillicores float64
52+
PodMinMemoryMb float64
53+
TargetCPUPercentile float64
54+
LowerBoundCPUPercentile float64
55+
UpperBoundCPUPercentile float64
56+
ConfidenceIntervalCPU time.Duration
57+
TargetMemoryPercentile float64
58+
LowerBoundMemoryPercentile float64
59+
UpperBoundMemoryPercentile float64
60+
ConfidenceIntervalMemory time.Duration
61+
HumanizeMemory bool
62+
RoundCPUMillicores int
63+
RoundMemoryBytes int
4764

4865
// Prometheus history provider configuration
4966
PrometheusAddress string
@@ -89,13 +106,31 @@ func DefaultRecommenderConfig() *RecommenderConfig {
89106
CommonFlags: common.DefaultCommonConfig(),
90107

91108
// Recommender-specific flags
92-
RecommenderName: input.DefaultRecommenderName,
93-
MetricsFetcherInterval: 1 * time.Minute,
94-
CheckpointsGCInterval: 10 * time.Minute,
95-
Address: ":8942",
96-
Storage: "",
97-
MemorySaver: false,
98-
UpdateWorkerCount: 10,
109+
RecommenderName: input.DefaultRecommenderName,
110+
MetricsFetcherInterval: 1 * time.Minute,
111+
CheckpointsGCInterval: 10 * time.Minute,
112+
CheckpointsWriteTimeout: time.Minute,
113+
Address: ":8942",
114+
Storage: "",
115+
MemorySaver: false,
116+
UpdateWorkerCount: 10,
117+
MinCheckpointsPerRun: 10,
118+
119+
// Recommendation configuration
120+
SafetyMarginFraction: 0.15,
121+
PodMinCPUMillicores: 25,
122+
PodMinMemoryMb: 250,
123+
TargetCPUPercentile: 0.9,
124+
LowerBoundCPUPercentile: 0.5,
125+
UpperBoundCPUPercentile: 0.95,
126+
ConfidenceIntervalCPU: 24 * time.Hour,
127+
TargetMemoryPercentile: 0.9,
128+
LowerBoundMemoryPercentile: 0.5,
129+
UpperBoundMemoryPercentile: 0.95,
130+
ConfidenceIntervalMemory: 24 * time.Hour,
131+
HumanizeMemory: false,
132+
RoundCPUMillicores: 1,
133+
RoundMemoryBytes: 1,
99134

100135
// Prometheus history provider flags
101136
PrometheusAddress: "http://prometheus.monitoring.svc",
@@ -144,10 +179,29 @@ func InitRecommenderFlags() *RecommenderConfig {
144179
flag.StringVar(&config.RecommenderName, "recommender-name", config.RecommenderName, "Set the recommender name. Recommender will generate recommendations for VPAs that configure the same recommender name. If the recommender name is left as default it will also generate recommendations that don't explicitly specify recommender. You shouldn't run two recommenders with the same name in a cluster.")
145180
flag.DurationVar(&config.MetricsFetcherInterval, "recommender-interval", config.MetricsFetcherInterval, `How often metrics should be fetched`)
146181
flag.DurationVar(&config.CheckpointsGCInterval, "checkpoints-gc-interval", config.CheckpointsGCInterval, `How often orphaned checkpoints should be garbage collected`)
182+
flag.DurationVar(&config.CheckpointsWriteTimeout, "checkpoints-timeout", config.CheckpointsWriteTimeout, `Timeout for writing checkpoints since the start of the recommender's main loop`)
147183
flag.StringVar(&config.Address, "address", config.Address, "The address to expose Prometheus metrics.")
148184
flag.StringVar(&config.Storage, "storage", config.Storage, `Specifies storage mode. Supported values: prometheus, checkpoint (default)`)
149185
flag.BoolVar(&config.MemorySaver, "memory-saver", config.MemorySaver, `If true, only track pods which have an associated VPA`)
150186
flag.IntVar(&config.UpdateWorkerCount, "update-worker-count", config.UpdateWorkerCount, "Number of concurrent workers to update VPA recommendations and checkpoints. When increasing this setting, make sure the client-side rate limits ('kube-api-qps' and 'kube-api-burst') are either increased or turned off as well. Determines the minimum number of VPA checkpoints written per recommender loop.")
187+
// MinCheckpointsPerRun is deprecated but kept for warning/compatibility.
188+
flag.IntVar(&config.MinCheckpointsPerRun, "min-checkpoints", config.MinCheckpointsPerRun, "Minimum number of checkpoints to write per recommender's main loop. WARNING: this flag is deprecated and doesn't have any effect. It will be removed in a future release. Refer to update-worker-count to influence the minimum number of checkpoints written per loop.")
189+
190+
// Recommendation configuration flags
191+
flag.Float64Var(&config.SafetyMarginFraction, "recommendation-margin-fraction", config.SafetyMarginFraction, `Fraction of usage added as the safety margin to the recommended request`)
192+
flag.Float64Var(&config.PodMinCPUMillicores, "pod-recommendation-min-cpu-millicores", config.PodMinCPUMillicores, `Minimum CPU recommendation for a pod`)
193+
flag.Float64Var(&config.PodMinMemoryMb, "pod-recommendation-min-memory-mb", config.PodMinMemoryMb, `Minimum memory recommendation for a pod`)
194+
flag.Float64Var(&config.TargetCPUPercentile, "target-cpu-percentile", config.TargetCPUPercentile, "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.")
195+
flag.Float64Var(&config.LowerBoundCPUPercentile, "recommendation-lower-bound-cpu-percentile", config.LowerBoundCPUPercentile, `CPU usage percentile that will be used for the lower bound on CPU recommendation.`)
196+
flag.Float64Var(&config.UpperBoundCPUPercentile, "recommendation-upper-bound-cpu-percentile", config.UpperBoundCPUPercentile, `CPU usage percentile that will be used for the upper bound on CPU recommendation.`)
197+
flag.DurationVar(&config.ConfidenceIntervalCPU, "confidence-interval-cpu", config.ConfidenceIntervalCPU, "The time interval used for computing the confidence multiplier for the CPU lower and upper bound. Default: 24h")
198+
flag.Float64Var(&config.TargetMemoryPercentile, "target-memory-percentile", config.TargetMemoryPercentile, "Memory usage percentile that will be used as a base for memory target recommendation. Doesn't affect memory lower bound nor memory upper bound.")
199+
flag.Float64Var(&config.LowerBoundMemoryPercentile, "recommendation-lower-bound-memory-percentile", config.LowerBoundMemoryPercentile, `Memory usage percentile that will be used for the lower bound on memory recommendation.`)
200+
flag.Float64Var(&config.UpperBoundMemoryPercentile, "recommendation-upper-bound-memory-percentile", config.UpperBoundMemoryPercentile, `Memory usage percentile that will be used for the upper bound on memory recommendation.`)
201+
flag.DurationVar(&config.ConfidenceIntervalMemory, "confidence-interval-memory", config.ConfidenceIntervalMemory, "The time interval used for computing the confidence multiplier for the memory lower and upper bound. Default: 24h")
202+
flag.BoolVar(&config.HumanizeMemory, "humanize-memory", config.HumanizeMemory, "DEPRECATED: Convert memory values in recommendations to the highest appropriate SI unit with up to 2 decimal places for better readability. This flag is deprecated and will be removed in a future version. Use --round-memory-bytes instead.")
203+
flag.IntVar(&config.RoundCPUMillicores, "round-cpu-millicores", config.RoundCPUMillicores, `CPU recommendation rounding factor in millicores. The CPU value will always be rounded up to the nearest multiple of this factor.`)
204+
flag.IntVar(&config.RoundMemoryBytes, "round-memory-bytes", config.RoundMemoryBytes, `Memory recommendation rounding factor in bytes. The Memory value will always be rounded up to the nearest multiple of this factor.`)
151205

152206
// Prometheus history provider flags
153207
flag.StringVar(&config.PrometheusAddress, "prometheus-address", config.PrometheusAddress, `Where to reach for Prometheus metrics`)
@@ -194,7 +248,7 @@ func InitRecommenderFlags() *RecommenderConfig {
194248
func ValidateRecommenderConfig(config *RecommenderConfig) {
195249
common.ValidateCommonConfig(config.CommonFlags)
196250

197-
if *routines.MinCheckpointsPerRun != 10 { // Default value is 10
251+
if config.MinCheckpointsPerRun != 10 { // Default value is 10
198252
klog.InfoS("DEPRECATION WARNING: The 'min-checkpoints' flag is deprecated and has no effect. It will be removed in a future release.")
199253
}
200254

0 commit comments

Comments
 (0)