@@ -204,6 +204,12 @@ const (
204
204
// (for example length of queue in cloud messaging service, or
205
205
// QPS from loadbalancer running outside of cluster).
206
206
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"
207
213
)
208
214
209
215
// MetricSpec specifies how to scale based on a single metric
@@ -229,6 +235,13 @@ type MetricSpec struct {
229
235
// to normal per-pod metrics using the "pods" source.
230
236
// +optional
231
237
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
232
245
// External refers to a global metric that is not associated
233
246
// with any Kubernetes object. It allows autoscaling based on information
234
247
// coming from components running outside of cluster
@@ -271,6 +284,22 @@ type ResourceMetricSource struct {
271
284
Target MetricTarget
272
285
}
273
286
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
+
274
303
// ExternalMetricSource indicates how to scale on a metric not associated with
275
304
// any Kubernetes object (for example length of queue in cloud
276
305
// messaging service, or QPS from loadbalancer running outside of cluster).
@@ -420,6 +449,13 @@ type MetricStatus struct {
420
449
// to normal per-pod metrics using the "pods" source.
421
450
// +optional
422
451
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
423
459
// External refers to a global metric that is not associated
424
460
// with any Kubernetes object. It allows autoscaling based on information
425
461
// coming from components running outside of cluster
@@ -456,6 +492,18 @@ type ResourceMetricStatus struct {
456
492
Current MetricValueStatus
457
493
}
458
494
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
+
459
507
// ExternalMetricStatus indicates the current value of a global metric
460
508
// not associated with any Kubernetes object.
461
509
type ExternalMetricStatus struct {
0 commit comments