Skip to content

Commit 28b274b

Browse files
arjunrngjtempleton
andcommitted
Apply suggestions from code review
Co-Authored-By: Guy Templeton <[email protected]>
1 parent 1c6f86b commit 28b274b

File tree

1 file changed

+51
-5
lines changed

1 file changed

+51
-5
lines changed

keps/sig-autoscaling/0001-container-resource-autoscaling.md

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
---
32
title: Container Resource based Autoscaling
43
authors:
@@ -27,6 +26,7 @@ status: provisional
2726
- [User Stories](#user-stories)
2827
- [Multiple containers with different scaling thresholds](#multiple-containers-with-different-scaling-thresholds)
2928
- [Multiple containers but only scaling for one.](#multiple-containers-but-only-scaling-for-one)
29+
- [Add container metrics to existing pod resource metric.](#add-container-metrics-to-existing-pod-resource-metric)
3030
- [Risks and Mitigations](#risks-and-mitigations)
3131
- [Design Details](#design-details)
3232
- [Test Plan](#test-plan)
@@ -40,7 +40,7 @@ status: provisional
4040
The Horizontal Pod Autoscaler supports scaling of targets based on the resource usage
4141
of the pods in the target. The resource usage of pods is calculated as the sum
4242
of the individual container usage values of the pod. This is unsuitable for workloads where
43-
the usage of the containers are not strongly correlated or change in lockstep. This KEP
43+
the usage of the containers are not strongly correlated or do not change in lockstep. This KEP
4444
suggests that when scaling based on resource usage the HPA also provide an option
4545
to consider the usages of individual containers to make scaling decisions.
4646

@@ -94,7 +94,7 @@ type ResourceMetricSource struct {
9494
}
9595
```
9696

97-
Here the `Name` is the name of the resource. Currently on `cpu` and `memory` are supported
97+
Here the `Name` is the name of the resource. Currently only `cpu` and `memory` are supported
9898
for this field. The other field is used to specify the target at which the HPA should maintain
9999
the resource usage by adding or removing pods. For instance if the target is _60%_ CPU utilization,
100100
and the current average of the CPU resources across all the pods of the target is _70%_ then
@@ -131,7 +131,7 @@ usage should be tracked.
131131

132132
2. The `ResourceMetricSource` should be aliased to `PodResourceMetricSource`. It will work
133133
exactly as the original. The aliasing is done for the sake of consistency. Correspondingly,
134-
the `type` field for the metric source should be extended support both `ContainerResource`
134+
the `type` field for the metric source should be extended to support both `ContainerResource`
135135
and `PodResource` as values.
136136

137137
### User Stories
@@ -231,7 +231,53 @@ spec:
231231
averageUtilization: 30
232232
```
233233

234-
The HPA controller will then completely ignores the resource usage in other containers.
234+
The HPA controller will then completely ignore the resource usage in other containers.
235+
236+
#### Add container metrics to existing pod resource metric.
237+
A user who is already using an HPA to scale their application can add the container metric source to the HPA
238+
in addition to the existing pod metric source. If there is a single container in the pod then the behavior
239+
will be exactly the same as before. If there are multiple containers in the application pods then the deployment
240+
might scale out more than before. This happens when the resource usage of the specified container is more
241+
than the blended usage as calculated by the pod metric source. If however in the unlikely case, the usage of
242+
all the containers in the pod change in tandem by the same amount then the behavior will remain as before.
243+
244+
For example consider the HPA object which targets a _Deployement_ with pods that have two containers `application`
245+
and `log-shipper`:
246+
247+
```yaml
248+
249+
apiVersion: autoscaling/v2beta2
250+
kind: HorizontalPodAutoscaler
251+
metadata:
252+
name: mission-critical
253+
spec:
254+
scaleTargetRef:
255+
apiVersion: apps/v1
256+
kind: Deployment
257+
name: mission-critical
258+
minReplicas: 1
259+
maxReplicas: 10
260+
metrics:
261+
- type: ContainerResource
262+
resource:
263+
name: cpu
264+
container: application
265+
target:
266+
type: Utilization
267+
averageUtilization: 50
268+
- type: PodResource
269+
resource:
270+
name: cpu
271+
target:
272+
type: Utilization
273+
averageUtilization: 50
274+
```
275+
276+
If the resource usage of the `application` container increases then the target would be scaled out even if
277+
the usage of the `log-shipper` container does not increase much. If the resource usage of `log-shipper` container
278+
increases then the deployment would only be scaled out if the combined resource usage of both containers increases
279+
above the target.
280+
235281

236282
### Risks and Mitigations
237283

0 commit comments

Comments
 (0)