@@ -6,75 +6,72 @@ slug: hpa-configurable-tolerance
6
6
# the release comms team can confirm which date has been assigned
7
7
#
8
8
# PRs to remove the draft marker should be opened BEFORE release day
9
- draft : true
9
+ draft : true
10
10
math : true # for formulae
11
11
date : XXXX-XX-XX
12
- author : " Jean-Marc François"
12
+ author : " Jean-Marc François (Google) "
13
13
---
14
14
15
15
This post describes _ configurable tolerance for horizontal Pod autoscaling_ ,
16
16
a new alpha feature first available in Kubernetes 1.33.
17
17
18
18
## What is it?
19
19
20
- [ Horizontal Pod autoscaling] ( /docs/tasks/run-application/horizontal-pod-autoscale/ ) (HPA) is a
21
- well-known Kubernetes feature that
22
- allows your workload to automatically resize by adding or removing replicas
23
- based on resource utilization.
20
+ [ Horizontal Pod autoscaling] ( /docs/tasks/run-application/horizontal-pod-autoscale/ )
21
+ (HPA) is a well-known Kubernetes feature that allows your workload to
22
+ automatically resize by adding or removing replicas based on resource
23
+ utilization.
24
24
25
25
To decide how many replicas a workload requires, users configure their HPA
26
26
with a metric (e.g. CPU utilization) and an expected value for this metric (e.g.
27
27
80%). The HPA updates the number of replica based on the ratio between the
28
28
current and desired metric value. (For example, if there are currently 100
29
29
replicas, the CPU utilization is 88%, and the desired utilization is 80%, the
30
- HPA will ask for ` 100 * (88/80) ` replicas).
30
+ HPA will ask for \\ ( 100 \times (88/80)\) ) replicas).
31
31
32
32
In order to avoid replicas being created or deleted whenever a small metric
33
- fluctuation occurs, Kubernetes applies a form of hysteresis: it only changes the number of replicas
34
- when the the current and desired metric values
35
- differ by more than 10%.
33
+ fluctuation occurs, Kubernetes applies a form of hysteresis: it only changes the
34
+ number of replicas when the the current and desired metric values differ by more
35
+ than 10%.
36
36
37
- This default tolerance of 10% is cluster-wide; in older Kubernetes releases, it could not be fine-tuned. It's
38
- a suitable value for most usage, but too coarse for large deployments, where a
39
- 10% tolerance represents tens of pods. As a result,
40
- users have long [ asked] ( https://github.com/kubernetes/kubernetes/issues/116984 )
41
- to be able to tune this value.
37
+ This default tolerance of 10% is cluster-wide; in older Kubernetes releases, it
38
+ could not be fine-tuned. It's a suitable value for most usage, but too coarse
39
+ for large deployments, where a 10% tolerance represents tens of pods. As a
40
+ result, users have long
41
+ [ asked] ( https://github.com/kubernetes/kubernetes/issues/116984 ) to be able to
42
+ tune this value.
42
43
43
- In Kubernetes v1.33,
44
- ``
45
- this is now possible.
44
+ In Kubernetes v1.33, this is now possible.
46
45
47
46
## How do I use it?
48
47
49
- Just add the tolerance you want an HPA to use to your ` HorizontalPodAutoscaler `
50
- resource.
48
+ Enable the ` HPAConfigurableTolerance ` feature flag in your Kubernetes 1.33
49
+ cluster, then add the tolerance you want an HPA to use to your
50
+ HorizontalPodAutoscaler object.
51
51
52
52
Tolerances appear under the ` spec.behavior.scaleDown ` and
53
53
` spec.behavior.scaleUp ` fields and can thus be different for scale up and scale
54
54
down. A typical usage would be to specify a small tolerance on scale up (to
55
55
react quickly to spikes), but lower on scale down (to avoid adding and removing
56
56
replicas too quickly in response to small metric fluctuations).
57
57
58
- For example, an HPA with a tolerance of 5% on scale-down, and no
59
- tolerance on scale-up, would look like the following:
58
+ For example, an HPA with a tolerance of 5% on scale-down, and no tolerance on
59
+ scale-up, would look like the following:
60
60
61
61
``` yaml
62
62
apiVersion : autoscaling/v2
63
63
kind : HorizontalPodAutoscaler
64
64
metadata :
65
65
name : my-app
66
66
spec :
67
- …
67
+ ...
68
68
behavior :
69
69
scaleDown :
70
70
tolerance : 0.05
71
71
scaleUp :
72
72
tolerance : 0
73
73
` ` `
74
74
75
- Note: This feature is in alpha in Kubernetes 1.33, gated by the
76
- ` HPAConfigurableTolerance` flag.
77
-
78
75
## I want all the details!
79
76
80
77
Get all the technical details by reading
0 commit comments