1 /* 2 Copyright 2021 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 // +k8s:openapi-gen=true 18 19 package v2 20 21 import ( 22 v1 "k8s.io/api/core/v1" 23 "k8s.io/apimachinery/pkg/api/resource" 24 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 25 ) 26 27 // +genclient 28 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 29 30 // HorizontalPodAutoscaler is the configuration for a horizontal pod 31 // autoscaler, which automatically manages the replica count of any resource 32 // implementing the scale subresource based on the metrics specified. 33 type HorizontalPodAutoscaler struct { 34 metav1.TypeMeta `json:",inline"` 35 // metadata is the standard object metadata. 36 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 37 // +optional 38 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 39 40 // spec is the specification for the behaviour of the autoscaler. 41 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status. 42 // +optional 43 Spec HorizontalPodAutoscalerSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` 44 45 // status is the current information about the autoscaler. 46 // +optional 47 Status HorizontalPodAutoscalerStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` 48 } 49 50 // HorizontalPodAutoscalerSpec describes the desired functionality of the HorizontalPodAutoscaler. 51 type HorizontalPodAutoscalerSpec struct { 52 // scaleTargetRef points to the target resource to scale, and is used to the pods for which metrics 53 // should be collected, as well as to actually change the replica count. 54 ScaleTargetRef CrossVersionObjectReference `json:"scaleTargetRef" protobuf:"bytes,1,opt,name=scaleTargetRef"` 55 // minReplicas is the lower limit for the number of replicas to which the autoscaler 56 // can scale down. It defaults to 1 pod. minReplicas is allowed to be 0 if the 57 // alpha feature gate HPAScaleToZero is enabled and at least one Object or External 58 // metric is configured. Scaling is active as long as at least one metric value is 59 // available. 60 // +optional 61 MinReplicas *int32 `json:"minReplicas,omitempty" protobuf:"varint,2,opt,name=minReplicas"` 62 63 // maxReplicas is the upper limit for the number of replicas to which the autoscaler can scale up. 64 // It cannot be less that minReplicas. 65 MaxReplicas int32 `json:"maxReplicas" protobuf:"varint,3,opt,name=maxReplicas"` 66 67 // metrics contains the specifications for which to use to calculate the 68 // desired replica count (the maximum replica count across all metrics will 69 // be used). The desired replica count is calculated multiplying the 70 // ratio between the target value and the current value by the current 71 // number of pods. Ergo, metrics used must decrease as the pod count is 72 // increased, and vice-versa. See the individual metric source types for 73 // more information about how each type of metric must respond. 74 // If not set, the default metric will be set to 80% average CPU utilization. 75 // +listType=atomic 76 // +optional 77 Metrics []MetricSpec `json:"metrics,omitempty" protobuf:"bytes,4,rep,name=metrics"` 78 79 // behavior configures the scaling behavior of the target 80 // in both Up and Down directions (scaleUp and scaleDown fields respectively). 81 // If not set, the default HPAScalingRules for scale up and scale down are used. 82 // +optional 83 Behavior *HorizontalPodAutoscalerBehavior `json:"behavior,omitempty" protobuf:"bytes,5,opt,name=behavior"` 84 } 85 86 // CrossVersionObjectReference contains enough information to let you identify the referred resource. 87 type CrossVersionObjectReference struct { 88 // kind is the kind of the referent; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds 89 Kind string `json:"kind" protobuf:"bytes,1,opt,name=kind"` 90 91 // name is the name of the referent; More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names 92 Name string `json:"name" protobuf:"bytes,2,opt,name=name"` 93 94 // apiVersion is the API version of the referent 95 // +optional 96 APIVersion string `json:"apiVersion,omitempty" protobuf:"bytes,3,opt,name=apiVersion"` 97 } 98 99 // MetricSpec specifies how to scale based on a single metric 100 // (only `type` and one other matching field should be set at once). 101 type MetricSpec struct { 102 // type is the type of metric source. It should be one of "ContainerResource", "External", 103 // "Object", "Pods" or "Resource", each mapping to a matching field in the object. 104 // Note: "ContainerResource" type is available on when the feature-gate 105 // HPAContainerMetrics is enabled 106 Type MetricSourceType `json:"type" protobuf:"bytes,1,name=type"` 107 108 // object refers to a metric describing a single kubernetes object 109 // (for example, hits-per-second on an Ingress object). 110 // +optional 111 Object *ObjectMetricSource `json:"object,omitempty" protobuf:"bytes,2,opt,name=object"` 112 113 // pods refers to a metric describing each pod in the current scale target 114 // (for example, transactions-processed-per-second). The values will be 115 // averaged together before being compared to the target value. 116 // +optional 117 Pods *PodsMetricSource `json:"pods,omitempty" protobuf:"bytes,3,opt,name=pods"` 118 119 // resource refers to a resource metric (such as those specified in 120 // requests and limits) known to Kubernetes describing each pod in the 121 // current scale target (e.g. CPU or memory). Such metrics are built in to 122 // Kubernetes, and have special scaling options on top of those available 123 // to normal per-pod metrics using the "pods" source. 124 // +optional 125 Resource *ResourceMetricSource `json:"resource,omitempty" protobuf:"bytes,4,opt,name=resource"` 126 127 // containerResource refers to a resource metric (such as those specified in 128 // requests and limits) known to Kubernetes describing a single container in 129 // each pod of the current scale target (e.g. CPU or memory). Such metrics are 130 // built in to Kubernetes, and have special scaling options on top of those 131 // available to normal per-pod metrics using the "pods" source. 132 // This is an alpha feature and can be enabled by the HPAContainerMetrics feature flag. 133 // +optional 134 ContainerResource *ContainerResourceMetricSource `json:"containerResource,omitempty" protobuf:"bytes,7,opt,name=containerResource"` 135 136 // external refers to a global metric that is not associated 137 // with any Kubernetes object. It allows autoscaling based on information 138 // coming from components running outside of cluster 139 // (for example length of queue in cloud messaging service, or 140 // QPS from loadbalancer running outside of cluster). 141 // +optional 142 External *ExternalMetricSource `json:"external,omitempty" protobuf:"bytes,5,opt,name=external"` 143 } 144 145 // HorizontalPodAutoscalerBehavior configures the scaling behavior of the target 146 // in both Up and Down directions (scaleUp and scaleDown fields respectively). 147 type HorizontalPodAutoscalerBehavior struct { 148 // scaleUp is scaling policy for scaling Up. 149 // If not set, the default value is the higher of: 150 // * increase no more than 4 pods per 60 seconds 151 // * double the number of pods per 60 seconds 152 // No stabilization is used. 153 // +optional 154 ScaleUp *HPAScalingRules `json:"scaleUp,omitempty" protobuf:"bytes,1,opt,name=scaleUp"` 155 156 // scaleDown is scaling policy for scaling Down. 157 // If not set, the default value is to allow to scale down to minReplicas pods, with a 158 // 300 second stabilization window (i.e., the highest recommendation for 159 // the last 300sec is used). 160 // +optional 161 ScaleDown *HPAScalingRules `json:"scaleDown,omitempty" protobuf:"bytes,2,opt,name=scaleDown"` 162 } 163 164 // ScalingPolicySelect is used to specify which policy should be used while scaling in a certain direction 165 type ScalingPolicySelect string 166 167 const ( 168 // MaxChangePolicySelect selects the policy with the highest possible change. 169 MaxChangePolicySelect ScalingPolicySelect = "Max" 170 // MinChangePolicySelect selects the policy with the lowest possible change. 171 MinChangePolicySelect ScalingPolicySelect = "Min" 172 // DisabledPolicySelect disables the scaling in this direction. 173 DisabledPolicySelect ScalingPolicySelect = "Disabled" 174 ) 175 176 // HPAScalingRules configures the scaling behavior for one direction. 177 // These Rules are applied after calculating DesiredReplicas from metrics for the HPA. 178 // They can limit the scaling velocity by specifying scaling policies. 179 // They can prevent flapping by specifying the stabilization window, so that the 180 // number of replicas is not set instantly, instead, the safest value from the stabilization 181 // window is chosen. 182 type HPAScalingRules struct { 183 // stabilizationWindowSeconds is the number of seconds for which past recommendations should be 184 // considered while scaling up or scaling down. 185 // StabilizationWindowSeconds must be greater than or equal to zero and less than or equal to 3600 (one hour). 186 // If not set, use the default values: 187 // - For scale up: 0 (i.e. no stabilization is done). 188 // - For scale down: 300 (i.e. the stabilization window is 300 seconds long). 189 // +optional 190 StabilizationWindowSeconds *int32 `json:"stabilizationWindowSeconds,omitempty" protobuf:"varint,3,opt,name=stabilizationWindowSeconds"` 191 192 // selectPolicy is used to specify which policy should be used. 193 // If not set, the default value Max is used. 194 // +optional 195 SelectPolicy *ScalingPolicySelect `json:"selectPolicy,omitempty" protobuf:"bytes,1,opt,name=selectPolicy"` 196 197 // policies is a list of potential scaling polices which can be used during scaling. 198 // At least one policy must be specified, otherwise the HPAScalingRules will be discarded as invalid 199 // +listType=atomic 200 // +optional 201 Policies []HPAScalingPolicy `json:"policies,omitempty" listType:"atomic" protobuf:"bytes,2,rep,name=policies"` 202 } 203 204 // HPAScalingPolicyType is the type of the policy which could be used while making scaling decisions. 205 type HPAScalingPolicyType string 206 207 const ( 208 // PodsScalingPolicy is a policy used to specify a change in absolute number of pods. 209 PodsScalingPolicy HPAScalingPolicyType = "Pods" 210 // PercentScalingPolicy is a policy used to specify a relative amount of change with respect to 211 // the current number of pods. 212 PercentScalingPolicy HPAScalingPolicyType = "Percent" 213 ) 214 215 // HPAScalingPolicy is a single policy which must hold true for a specified past interval. 216 type HPAScalingPolicy struct { 217 // type is used to specify the scaling policy. 218 Type HPAScalingPolicyType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=HPAScalingPolicyType"` 219 220 // value contains the amount of change which is permitted by the policy. 221 // It must be greater than zero 222 Value int32 `json:"value" protobuf:"varint,2,opt,name=value"` 223 224 // periodSeconds specifies the window of time for which the policy should hold true. 225 // PeriodSeconds must be greater than zero and less than or equal to 1800 (30 min). 226 PeriodSeconds int32 `json:"periodSeconds" protobuf:"varint,3,opt,name=periodSeconds"` 227 } 228 229 // MetricSourceType indicates the type of metric. 230 type MetricSourceType string 231 232 const ( 233 // ObjectMetricSourceType is a metric describing a kubernetes object 234 // (for example, hits-per-second on an Ingress object). 235 ObjectMetricSourceType MetricSourceType = "Object" 236 // PodsMetricSourceType is a metric describing each pod in the current scale 237 // target (for example, transactions-processed-per-second). The values 238 // will be averaged together before being compared to the target value. 239 PodsMetricSourceType MetricSourceType = "Pods" 240 // ResourceMetricSourceType is a resource metric known to Kubernetes, as 241 // specified in requests and limits, describing each pod in the current 242 // scale target (e.g. CPU or memory). Such metrics are built in to 243 // Kubernetes, and have special scaling options on top of those available 244 // to normal per-pod metrics (the "pods" source). 245 ResourceMetricSourceType MetricSourceType = "Resource" 246 // ContainerResourceMetricSourceType is a resource metric known to Kubernetes, as 247 // specified in requests and limits, describing a single container in each pod in the current 248 // scale target (e.g. CPU or memory). Such metrics are built in to 249 // Kubernetes, and have special scaling options on top of those available 250 // to normal per-pod metrics (the "pods" source). 251 ContainerResourceMetricSourceType MetricSourceType = "ContainerResource" 252 // ExternalMetricSourceType is a global metric that is not associated 253 // with any Kubernetes object. It allows autoscaling based on information 254 // coming from components running outside of cluster 255 // (for example length of queue in cloud messaging service, or 256 // QPS from loadbalancer running outside of cluster). 257 ExternalMetricSourceType MetricSourceType = "External" 258 ) 259 260 // ObjectMetricSource indicates how to scale on a metric describing a 261 // kubernetes object (for example, hits-per-second on an Ingress object). 262 type ObjectMetricSource struct { 263 // describedObject specifies the descriptions of a object,such as kind,name apiVersion 264 DescribedObject CrossVersionObjectReference `json:"describedObject" protobuf:"bytes,1,name=describedObject"` 265 266 // target specifies the target value for the given metric 267 Target MetricTarget `json:"target" protobuf:"bytes,2,name=target"` 268 269 // metric identifies the target metric by name and selector 270 Metric MetricIdentifier `json:"metric" protobuf:"bytes,3,name=metric"` 271 } 272 273 // PodsMetricSource indicates how to scale on a metric describing each pod in 274 // the current scale target (for example, transactions-processed-per-second). 275 // The values will be averaged together before being compared to the target 276 // value. 277 type PodsMetricSource struct { 278 // metric identifies the target metric by name and selector 279 Metric MetricIdentifier `json:"metric" protobuf:"bytes,1,name=metric"` 280 281 // target specifies the target value for the given metric 282 Target MetricTarget `json:"target" protobuf:"bytes,2,name=target"` 283 } 284 285 // ResourceMetricSource indicates how to scale on a resource metric known to 286 // Kubernetes, as specified in requests and limits, describing each pod in the 287 // current scale target (e.g. CPU or memory). The values will be averaged 288 // together before being compared to the target. Such metrics are built in to 289 // Kubernetes, and have special scaling options on top of those available to 290 // normal per-pod metrics using the "pods" source. Only one "target" type 291 // should be set. 292 type ResourceMetricSource struct { 293 // name is the name of the resource in question. 294 Name v1.ResourceName `json:"name" protobuf:"bytes,1,name=name"` 295 296 // target specifies the target value for the given metric 297 Target MetricTarget `json:"target" protobuf:"bytes,2,name=target"` 298 } 299 300 // ContainerResourceMetricSource indicates how to scale on a resource metric known to 301 // Kubernetes, as specified in requests and limits, describing each pod in the 302 // current scale target (e.g. CPU or memory). The values will be averaged 303 // together before being compared to the target. Such metrics are built in to 304 // Kubernetes, and have special scaling options on top of those available to 305 // normal per-pod metrics using the "pods" source. Only one "target" type 306 // should be set. 307 type ContainerResourceMetricSource struct { 308 // name is the name of the resource in question. 309 Name v1.ResourceName `json:"name" protobuf:"bytes,1,name=name"` 310 311 // target specifies the target value for the given metric 312 Target MetricTarget `json:"target" protobuf:"bytes,2,name=target"` 313 314 // container is the name of the container in the pods of the scaling target 315 Container string `json:"container" protobuf:"bytes,3,opt,name=container"` 316 } 317 318 // ExternalMetricSource indicates how to scale on a metric not associated with 319 // any Kubernetes object (for example length of queue in cloud 320 // messaging service, or QPS from loadbalancer running outside of cluster). 321 type ExternalMetricSource struct { 322 // metric identifies the target metric by name and selector 323 Metric MetricIdentifier `json:"metric" protobuf:"bytes,1,name=metric"` 324 325 // target specifies the target value for the given metric 326 Target MetricTarget `json:"target" protobuf:"bytes,2,name=target"` 327 } 328 329 // MetricIdentifier defines the name and optionally selector for a metric 330 type MetricIdentifier struct { 331 // name is the name of the given metric 332 Name string `json:"name" protobuf:"bytes,1,name=name"` 333 334 // selector is the string-encoded form of a standard kubernetes label selector for the given metric 335 // When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping. 336 // When unset, just the metricName will be used to gather metrics. 337 // +optional 338 Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,2,name=selector"` 339 } 340 341 // MetricTarget defines the target value, average value, or average utilization of a specific metric 342 type MetricTarget struct { 343 // type represents whether the metric type is Utilization, Value, or AverageValue 344 Type MetricTargetType `json:"type" protobuf:"bytes,1,name=type"` 345 346 // value is the target value of the metric (as a quantity). 347 // +optional 348 Value *resource.Quantity `json:"value,omitempty" protobuf:"bytes,2,opt,name=value"` 349 350 // averageValue is the target value of the average of the 351 // metric across all relevant pods (as a quantity) 352 // +optional 353 AverageValue *resource.Quantity `json:"averageValue,omitempty" protobuf:"bytes,3,opt,name=averageValue"` 354 355 // averageUtilization is the target value of the average of the 356 // resource metric across all relevant pods, represented as a percentage of 357 // the requested value of the resource for the pods. 358 // Currently only valid for Resource metric source type 359 // +optional 360 AverageUtilization *int32 `json:"averageUtilization,omitempty" protobuf:"bytes,4,opt,name=averageUtilization"` 361 } 362 363 // MetricTargetType specifies the type of metric being targeted, and should be either 364 // "Value", "AverageValue", or "Utilization" 365 type MetricTargetType string 366 367 const ( 368 // UtilizationMetricType declares a MetricTarget is an AverageUtilization value 369 UtilizationMetricType MetricTargetType = "Utilization" 370 // ValueMetricType declares a MetricTarget is a raw value 371 ValueMetricType MetricTargetType = "Value" 372 // AverageValueMetricType declares a MetricTarget is an 373 AverageValueMetricType MetricTargetType = "AverageValue" 374 ) 375 376 // HorizontalPodAutoscalerStatus describes the current status of a horizontal pod autoscaler. 377 type HorizontalPodAutoscalerStatus struct { 378 // observedGeneration is the most recent generation observed by this autoscaler. 379 // +optional 380 ObservedGeneration *int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"` 381 382 // lastScaleTime is the last time the HorizontalPodAutoscaler scaled the number of pods, 383 // used by the autoscaler to control how often the number of pods is changed. 384 // +optional 385 LastScaleTime *metav1.Time `json:"lastScaleTime,omitempty" protobuf:"bytes,2,opt,name=lastScaleTime"` 386 387 // currentReplicas is current number of replicas of pods managed by this autoscaler, 388 // as last seen by the autoscaler. 389 // +optional 390 CurrentReplicas int32 `json:"currentReplicas,omitempty" protobuf:"varint,3,opt,name=currentReplicas"` 391 392 // desiredReplicas is the desired number of replicas of pods managed by this autoscaler, 393 // as last calculated by the autoscaler. 394 DesiredReplicas int32 `json:"desiredReplicas" protobuf:"varint,4,opt,name=desiredReplicas"` 395 396 // currentMetrics is the last read state of the metrics used by this autoscaler. 397 // +listType=atomic 398 // +optional 399 CurrentMetrics []MetricStatus `json:"currentMetrics" protobuf:"bytes,5,rep,name=currentMetrics"` 400 401 // conditions is the set of conditions required for this autoscaler to scale its target, 402 // and indicates whether or not those conditions are met. 403 // +patchMergeKey=type 404 // +patchStrategy=merge 405 // +listType=map 406 // +listMapKey=type 407 // +optional 408 Conditions []HorizontalPodAutoscalerCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" listType:"map" protobuf:"bytes,6,rep,name=conditions"` 409 } 410 411 // HorizontalPodAutoscalerConditionType are the valid conditions of 412 // a HorizontalPodAutoscaler. 413 type HorizontalPodAutoscalerConditionType string 414 415 const ( 416 // ScalingActive indicates that the HPA controller is able to scale if necessary: 417 // it's correctly configured, can fetch the desired metrics, and isn't disabled. 418 ScalingActive HorizontalPodAutoscalerConditionType = "ScalingActive" 419 // AbleToScale indicates a lack of transient issues which prevent scaling from occurring, 420 // such as being in a backoff window, or being unable to access/update the target scale. 421 AbleToScale HorizontalPodAutoscalerConditionType = "AbleToScale" 422 // ScalingLimited indicates that the calculated scale based on metrics would be above or 423 // below the range for the HPA, and has thus been capped. 424 ScalingLimited HorizontalPodAutoscalerConditionType = "ScalingLimited" 425 ) 426 427 // HorizontalPodAutoscalerCondition describes the state of 428 // a HorizontalPodAutoscaler at a certain point. 429 type HorizontalPodAutoscalerCondition struct { 430 // type describes the current condition 431 Type HorizontalPodAutoscalerConditionType `json:"type" protobuf:"bytes,1,name=type"` 432 433 // status is the status of the condition (True, False, Unknown) 434 Status v1.ConditionStatus `json:"status" protobuf:"bytes,2,name=status"` 435 436 // lastTransitionTime is the last time the condition transitioned from 437 // one status to another 438 // +optional 439 LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,3,opt,name=lastTransitionTime"` 440 441 // reason is the reason for the condition's last transition. 442 // +optional 443 Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"` 444 445 // message is a human-readable explanation containing details about 446 // the transition 447 // +optional 448 Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"` 449 } 450 451 // MetricStatus describes the last-read state of a single metric. 452 type MetricStatus struct { 453 // type is the type of metric source. It will be one of "ContainerResource", "External", 454 // "Object", "Pods" or "Resource", each corresponds to a matching field in the object. 455 // Note: "ContainerResource" type is available on when the feature-gate 456 // HPAContainerMetrics is enabled 457 Type MetricSourceType `json:"type" protobuf:"bytes,1,name=type"` 458 459 // object refers to a metric describing a single kubernetes object 460 // (for example, hits-per-second on an Ingress object). 461 // +optional 462 Object *ObjectMetricStatus `json:"object,omitempty" protobuf:"bytes,2,opt,name=object"` 463 464 // pods refers to a metric describing each pod in the current scale target 465 // (for example, transactions-processed-per-second). The values will be 466 // averaged together before being compared to the target value. 467 // +optional 468 Pods *PodsMetricStatus `json:"pods,omitempty" protobuf:"bytes,3,opt,name=pods"` 469 470 // resource refers to a resource metric (such as those specified in 471 // requests and limits) known to Kubernetes describing each pod in the 472 // current scale target (e.g. CPU or memory). Such metrics are built in to 473 // Kubernetes, and have special scaling options on top of those available 474 // to normal per-pod metrics using the "pods" source. 475 // +optional 476 Resource *ResourceMetricStatus `json:"resource,omitempty" protobuf:"bytes,4,opt,name=resource"` 477 478 // container resource refers to a resource metric (such as those specified in 479 // requests and limits) known to Kubernetes describing a single container in each pod in the 480 // current scale target (e.g. CPU or memory). Such metrics are built in to 481 // Kubernetes, and have special scaling options on top of those available 482 // to normal per-pod metrics using the "pods" source. 483 // +optional 484 ContainerResource *ContainerResourceMetricStatus `json:"containerResource,omitempty" protobuf:"bytes,7,opt,name=containerResource"` 485 486 // external refers to a global metric that is not associated 487 // with any Kubernetes object. It allows autoscaling based on information 488 // coming from components running outside of cluster 489 // (for example length of queue in cloud messaging service, or 490 // QPS from loadbalancer running outside of cluster). 491 // +optional 492 External *ExternalMetricStatus `json:"external,omitempty" protobuf:"bytes,5,opt,name=external"` 493 } 494 495 // ObjectMetricStatus indicates the current value of a metric describing a 496 // kubernetes object (for example, hits-per-second on an Ingress object). 497 type ObjectMetricStatus struct { 498 // metric identifies the target metric by name and selector 499 Metric MetricIdentifier `json:"metric" protobuf:"bytes,1,name=metric"` 500 501 // current contains the current value for the given metric 502 Current MetricValueStatus `json:"current" protobuf:"bytes,2,name=current"` 503 504 // DescribedObject specifies the descriptions of a object,such as kind,name apiVersion 505 DescribedObject CrossVersionObjectReference `json:"describedObject" protobuf:"bytes,3,name=describedObject"` 506 } 507 508 // PodsMetricStatus indicates the current value of a metric describing each pod in 509 // the current scale target (for example, transactions-processed-per-second). 510 type PodsMetricStatus struct { 511 // metric identifies the target metric by name and selector 512 Metric MetricIdentifier `json:"metric" protobuf:"bytes,1,name=metric"` 513 514 // current contains the current value for the given metric 515 Current MetricValueStatus `json:"current" protobuf:"bytes,2,name=current"` 516 } 517 518 // ResourceMetricStatus indicates the current value of a resource metric known to 519 // Kubernetes, as specified in requests and limits, describing each pod in the 520 // current scale target (e.g. CPU or memory). Such metrics are built in to 521 // Kubernetes, and have special scaling options on top of those available to 522 // normal per-pod metrics using the "pods" source. 523 type ResourceMetricStatus struct { 524 // name is the name of the resource in question. 525 Name v1.ResourceName `json:"name" protobuf:"bytes,1,name=name"` 526 527 // current contains the current value for the given metric 528 Current MetricValueStatus `json:"current" protobuf:"bytes,2,name=current"` 529 } 530 531 // ContainerResourceMetricStatus indicates the current value of a resource metric known to 532 // Kubernetes, as specified in requests and limits, describing a single container in each pod in the 533 // current scale target (e.g. CPU or memory). Such metrics are built in to 534 // Kubernetes, and have special scaling options on top of those available to 535 // normal per-pod metrics using the "pods" source. 536 type ContainerResourceMetricStatus struct { 537 // name is the name of the resource in question. 538 Name v1.ResourceName `json:"name" protobuf:"bytes,1,name=name"` 539 540 // current contains the current value for the given metric 541 Current MetricValueStatus `json:"current" protobuf:"bytes,2,name=current"` 542 543 // container is the name of the container in the pods of the scaling target 544 Container string `json:"container" protobuf:"bytes,3,opt,name=container"` 545 } 546 547 // ExternalMetricStatus indicates the current value of a global metric 548 // not associated with any Kubernetes object. 549 type ExternalMetricStatus struct { 550 // metric identifies the target metric by name and selector 551 Metric MetricIdentifier `json:"metric" protobuf:"bytes,1,name=metric"` 552 553 // current contains the current value for the given metric 554 Current MetricValueStatus `json:"current" protobuf:"bytes,2,name=current"` 555 } 556 557 // MetricValueStatus holds the current value for a metric 558 type MetricValueStatus struct { 559 // value is the current value of the metric (as a quantity). 560 // +optional 561 Value *resource.Quantity `json:"value,omitempty" protobuf:"bytes,1,opt,name=value"` 562 563 // averageValue is the current value of the average of the 564 // metric across all relevant pods (as a quantity) 565 // +optional 566 AverageValue *resource.Quantity `json:"averageValue,omitempty" protobuf:"bytes,2,opt,name=averageValue"` 567 568 // currentAverageUtilization is the current value of the average of the 569 // resource metric across all relevant pods, represented as a percentage of 570 // the requested value of the resource for the pods. 571 // +optional 572 AverageUtilization *int32 `json:"averageUtilization,omitempty" protobuf:"bytes,3,opt,name=averageUtilization"` 573 } 574 575 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 576 577 // HorizontalPodAutoscalerList is a list of horizontal pod autoscaler objects. 578 type HorizontalPodAutoscalerList struct { 579 metav1.TypeMeta `json:",inline"` 580 // metadata is the standard list metadata. 581 // +optional 582 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 583 584 // items is the list of horizontal pod autoscaler objects. 585 Items []HorizontalPodAutoscaler `json:"items" protobuf:"bytes,2,rep,name=items"` 586 } 587