1
-
2
1
---
3
2
title : Container Resource based Autoscaling
4
3
authors :
@@ -27,6 +26,7 @@ status: provisional
27
26
- [ User Stories] ( #user-stories )
28
27
- [ Multiple containers with different scaling thresholds] ( #multiple-containers-with-different-scaling-thresholds )
29
28
- [ 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 )
30
30
- [ Risks and Mitigations] ( #risks-and-mitigations )
31
31
- [ Design Details] ( #design-details )
32
32
- [ Test Plan] ( #test-plan )
@@ -40,7 +40,7 @@ status: provisional
40
40
The Horizontal Pod Autoscaler supports scaling of targets based on the resource usage
41
41
of the pods in the target. The resource usage of pods is calculated as the sum
42
42
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
44
44
suggests that when scaling based on resource usage the HPA also provide an option
45
45
to consider the usages of individual containers to make scaling decisions.
46
46
@@ -94,7 +94,7 @@ type ResourceMetricSource struct {
94
94
}
95
95
```
96
96
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
98
98
for this field. The other field is used to specify the target at which the HPA should maintain
99
99
the resource usage by adding or removing pods. For instance if the target is _ 60%_ CPU utilization,
100
100
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.
131
131
132
132
2 . The ` ResourceMetricSource ` should be aliased to ` PodResourceMetricSource ` . It will work
133
133
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 `
135
135
and ` PodResource ` as values.
136
136
137
137
### User Stories
@@ -231,7 +231,53 @@ spec:
231
231
averageUtilization: 30
232
232
` ` `
233
233
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
+
235
281
236
282
# ## Risks and Mitigations
237
283
0 commit comments