Skip to content

Commit ec453ff

Browse files
authored
Merge pull request kubernetes#90691 from arjunrn/container-resource-hpa
Add container based scaling to HPA
2 parents 106ee38 + 0fec7b0 commit ec453ff

File tree

54 files changed

+5591
-871
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+5591
-871
lines changed

api/openapi-spec/swagger.json

Lines changed: 121 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/autoscaling/types.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,12 @@ const (
204204
// (for example length of queue in cloud messaging service, or
205205
// QPS from loadbalancer running outside of cluster).
206206
ExternalMetricSourceType MetricSourceType = "External"
207+
// ContainerResourceMetricSourceType is a resource metric known to Kubernetes, as
208+
// specified in requests and limits, describing a single container in each pod in the current
209+
// scale target (e.g. CPU or memory). Such metrics are built in to
210+
// Kubernetes, and have special scaling options on top of those available
211+
// to normal per-pod metrics (the "pods" source).
212+
ContainerResourceMetricSourceType MetricSourceType = "ContainerResource"
207213
)
208214

209215
// MetricSpec specifies how to scale based on a single metric
@@ -229,6 +235,13 @@ type MetricSpec struct {
229235
// to normal per-pod metrics using the "pods" source.
230236
// +optional
231237
Resource *ResourceMetricSource
238+
// ContainerResource refers to a resource metric (such as those specified in
239+
// requests and limits) known to Kubernetes describing a single container in each pod of the
240+
// current scale target (e.g. CPU or memory). Such metrics are built in to
241+
// Kubernetes, and have special scaling options on top of those available
242+
// to normal per-pod metrics using the "pods" source.
243+
// +optional
244+
ContainerResource *ContainerResourceMetricSource
232245
// External refers to a global metric that is not associated
233246
// with any Kubernetes object. It allows autoscaling based on information
234247
// coming from components running outside of cluster
@@ -271,6 +284,22 @@ type ResourceMetricSource struct {
271284
Target MetricTarget
272285
}
273286

287+
// ContainerResourceMetricSource indicates how to scale on a resource metric known to
288+
// Kubernetes, as specified in the requests and limits, describing a single container in
289+
// each of the pods of the current scale target(e.g. CPU or memory). The values will be
290+
// averaged together before being compared to the target. Such metrics are built into
291+
// Kubernetes, and have special scaling options on top of those available to
292+
// normal per-pod metrics using the "pods" source. Only one "target" type
293+
// should be set.
294+
type ContainerResourceMetricSource struct {
295+
// name is the name of the of the resource
296+
Name api.ResourceName
297+
// container is the name of the container in the pods of the scaling target.
298+
Container string
299+
// target specifies the target value for the given metric
300+
Target MetricTarget
301+
}
302+
274303
// ExternalMetricSource indicates how to scale on a metric not associated with
275304
// any Kubernetes object (for example length of queue in cloud
276305
// messaging service, or QPS from loadbalancer running outside of cluster).
@@ -420,6 +449,13 @@ type MetricStatus struct {
420449
// to normal per-pod metrics using the "pods" source.
421450
// +optional
422451
Resource *ResourceMetricStatus
452+
// ContainerResource refers to a resource metric (such as those specified in
453+
// requests and limits) known to Kubernetes describing a single container in each pod in the
454+
// current scale target (e.g. CPU or memory). Such metrics are built in to
455+
// Kubernetes, and have special scaling options on top of those available
456+
// to normal per-pod metrics using the "pods" source.
457+
// +optional
458+
ContainerResource *ContainerResourceMetricStatus
423459
// External refers to a global metric that is not associated
424460
// with any Kubernetes object. It allows autoscaling based on information
425461
// coming from components running outside of cluster
@@ -456,6 +492,18 @@ type ResourceMetricStatus struct {
456492
Current MetricValueStatus
457493
}
458494

495+
// ContainerResourceMetricStatus indicates the current value of a resource metric known to
496+
// Kubernetes, as specified in requests and limits, describing each pod in the
497+
// current scale target (e.g. CPU or memory). Such metrics are built in to
498+
// Kubernetes, and have special scaling options on top of those available to
499+
// normal per-pod metrics using the "pods" source.
500+
type ContainerResourceMetricStatus struct {
501+
// Name is the name of the resource in question.
502+
Name api.ResourceName
503+
Container string
504+
Current MetricValueStatus
505+
}
506+
459507
// ExternalMetricStatus indicates the current value of a global metric
460508
// not associated with any Kubernetes object.
461509
type ExternalMetricStatus struct {

0 commit comments

Comments
 (0)