Matteo Scandolo | a428586 | 2020-12-01 18:10:10 -0800 | [diff] [blame^] | 1 | /* |
| 2 | Copyright 2018 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 v2beta2 |
| 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 | // +k8s:prerelease-lifecycle-gen:introduced=1.12 |
| 30 | // +k8s:prerelease-lifecycle-gen:deprecated=1.22 |
| 31 | |
| 32 | // HorizontalPodAutoscaler is the configuration for a horizontal pod |
| 33 | // autoscaler, which automatically manages the replica count of any resource |
| 34 | // implementing the scale subresource based on the metrics specified. |
| 35 | type HorizontalPodAutoscaler struct { |
| 36 | metav1.TypeMeta `json:",inline"` |
| 37 | // metadata is the standard object metadata. |
| 38 | // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata |
| 39 | // +optional |
| 40 | metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` |
| 41 | |
| 42 | // spec is the specification for the behaviour of the autoscaler. |
| 43 | // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status. |
| 44 | // +optional |
| 45 | Spec HorizontalPodAutoscalerSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` |
| 46 | |
| 47 | // status is the current information about the autoscaler. |
| 48 | // +optional |
| 49 | Status HorizontalPodAutoscalerStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` |
| 50 | } |
| 51 | |
| 52 | // HorizontalPodAutoscalerSpec describes the desired functionality of the HorizontalPodAutoscaler. |
| 53 | type HorizontalPodAutoscalerSpec struct { |
| 54 | // scaleTargetRef points to the target resource to scale, and is used to the pods for which metrics |
| 55 | // should be collected, as well as to actually change the replica count. |
| 56 | ScaleTargetRef CrossVersionObjectReference `json:"scaleTargetRef" protobuf:"bytes,1,opt,name=scaleTargetRef"` |
| 57 | // minReplicas is the lower limit for the number of replicas to which the autoscaler |
| 58 | // can scale down. It defaults to 1 pod. minReplicas is allowed to be 0 if the |
| 59 | // alpha feature gate HPAScaleToZero is enabled and at least one Object or External |
| 60 | // metric is configured. Scaling is active as long as at least one metric value is |
| 61 | // available. |
| 62 | // +optional |
| 63 | MinReplicas *int32 `json:"minReplicas,omitempty" protobuf:"varint,2,opt,name=minReplicas"` |
| 64 | // maxReplicas is the upper limit for the number of replicas to which the autoscaler can scale up. |
| 65 | // It cannot be less that minReplicas. |
| 66 | MaxReplicas int32 `json:"maxReplicas" protobuf:"varint,3,opt,name=maxReplicas"` |
| 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 | // +optional |
| 76 | Metrics []MetricSpec `json:"metrics,omitempty" protobuf:"bytes,4,rep,name=metrics"` |
| 77 | |
| 78 | // behavior configures the scaling behavior of the target |
| 79 | // in both Up and Down directions (scaleUp and scaleDown fields respectively). |
| 80 | // If not set, the default HPAScalingRules for scale up and scale down are used. |
| 81 | // +optional |
| 82 | Behavior *HorizontalPodAutoscalerBehavior `json:"behavior,omitempty" protobuf:"bytes,5,opt,name=behavior"` |
| 83 | } |
| 84 | |
| 85 | // CrossVersionObjectReference contains enough information to let you identify the referred resource. |
| 86 | type CrossVersionObjectReference struct { |
| 87 | // Kind of the referent; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds" |
| 88 | Kind string `json:"kind" protobuf:"bytes,1,opt,name=kind"` |
| 89 | // Name of the referent; More info: http://kubernetes.io/docs/user-guide/identifiers#names |
| 90 | Name string `json:"name" protobuf:"bytes,2,opt,name=name"` |
| 91 | // API version of the referent |
| 92 | // +optional |
| 93 | APIVersion string `json:"apiVersion,omitempty" protobuf:"bytes,3,opt,name=apiVersion"` |
| 94 | } |
| 95 | |
| 96 | // MetricSpec specifies how to scale based on a single metric |
| 97 | // (only `type` and one other matching field should be set at once). |
| 98 | type MetricSpec struct { |
| 99 | // type is the type of metric source. It should be one of "Object", |
| 100 | // "Pods" or "Resource", each mapping to a matching field in the object. |
| 101 | Type MetricSourceType `json:"type" protobuf:"bytes,1,name=type"` |
| 102 | |
| 103 | // object refers to a metric describing a single kubernetes object |
| 104 | // (for example, hits-per-second on an Ingress object). |
| 105 | // +optional |
| 106 | Object *ObjectMetricSource `json:"object,omitempty" protobuf:"bytes,2,opt,name=object"` |
| 107 | // pods refers to a metric describing each pod in the current scale target |
| 108 | // (for example, transactions-processed-per-second). The values will be |
| 109 | // averaged together before being compared to the target value. |
| 110 | // +optional |
| 111 | Pods *PodsMetricSource `json:"pods,omitempty" protobuf:"bytes,3,opt,name=pods"` |
| 112 | // resource refers to a resource metric (such as those specified in |
| 113 | // requests and limits) known to Kubernetes describing each pod in the |
| 114 | // current scale target (e.g. CPU or memory). Such metrics are built in to |
| 115 | // Kubernetes, and have special scaling options on top of those available |
| 116 | // to normal per-pod metrics using the "pods" source. |
| 117 | // +optional |
| 118 | Resource *ResourceMetricSource `json:"resource,omitempty" protobuf:"bytes,4,opt,name=resource"` |
| 119 | // external refers to a global metric that is not associated |
| 120 | // with any Kubernetes object. It allows autoscaling based on information |
| 121 | // coming from components running outside of cluster |
| 122 | // (for example length of queue in cloud messaging service, or |
| 123 | // QPS from loadbalancer running outside of cluster). |
| 124 | // +optional |
| 125 | External *ExternalMetricSource `json:"external,omitempty" protobuf:"bytes,5,opt,name=external"` |
| 126 | } |
| 127 | |
| 128 | // HorizontalPodAutoscalerBehavior configures the scaling behavior of the target |
| 129 | // in both Up and Down directions (scaleUp and scaleDown fields respectively). |
| 130 | type HorizontalPodAutoscalerBehavior struct { |
| 131 | // scaleUp is scaling policy for scaling Up. |
| 132 | // If not set, the default value is the higher of: |
| 133 | // * increase no more than 4 pods per 60 seconds |
| 134 | // * double the number of pods per 60 seconds |
| 135 | // No stabilization is used. |
| 136 | // +optional |
| 137 | ScaleUp *HPAScalingRules `json:"scaleUp,omitempty" protobuf:"bytes,1,opt,name=scaleUp"` |
| 138 | // scaleDown is scaling policy for scaling Down. |
| 139 | // If not set, the default value is to allow to scale down to minReplicas pods, with a |
| 140 | // 300 second stabilization window (i.e., the highest recommendation for |
| 141 | // the last 300sec is used). |
| 142 | // +optional |
| 143 | ScaleDown *HPAScalingRules `json:"scaleDown,omitempty" protobuf:"bytes,2,opt,name=scaleDown"` |
| 144 | } |
| 145 | |
| 146 | // ScalingPolicySelect is used to specify which policy should be used while scaling in a certain direction |
| 147 | type ScalingPolicySelect string |
| 148 | |
| 149 | const ( |
| 150 | // MaxPolicySelect selects the policy with the highest possible change. |
| 151 | MaxPolicySelect ScalingPolicySelect = "Max" |
| 152 | // MinPolicySelect selects the policy with the lowest possible change. |
| 153 | MinPolicySelect ScalingPolicySelect = "Min" |
| 154 | // DisabledPolicySelect disables the scaling in this direction. |
| 155 | DisabledPolicySelect ScalingPolicySelect = "Disabled" |
| 156 | ) |
| 157 | |
| 158 | // HPAScalingRules configures the scaling behavior for one direction. |
| 159 | // These Rules are applied after calculating DesiredReplicas from metrics for the HPA. |
| 160 | // They can limit the scaling velocity by specifying scaling policies. |
| 161 | // They can prevent flapping by specifying the stabilization window, so that the |
| 162 | // number of replicas is not set instantly, instead, the safest value from the stabilization |
| 163 | // window is chosen. |
| 164 | type HPAScalingRules struct { |
| 165 | // StabilizationWindowSeconds is the number of seconds for which past recommendations should be |
| 166 | // considered while scaling up or scaling down. |
| 167 | // StabilizationWindowSeconds must be greater than or equal to zero and less than or equal to 3600 (one hour). |
| 168 | // If not set, use the default values: |
| 169 | // - For scale up: 0 (i.e. no stabilization is done). |
| 170 | // - For scale down: 300 (i.e. the stabilization window is 300 seconds long). |
| 171 | // +optional |
| 172 | StabilizationWindowSeconds *int32 `json:"stabilizationWindowSeconds" protobuf:"varint,3,opt,name=stabilizationWindowSeconds"` |
| 173 | // selectPolicy is used to specify which policy should be used. |
| 174 | // If not set, the default value MaxPolicySelect is used. |
| 175 | // +optional |
| 176 | SelectPolicy *ScalingPolicySelect `json:"selectPolicy,omitempty" protobuf:"bytes,1,opt,name=selectPolicy"` |
| 177 | // policies is a list of potential scaling polices which can be used during scaling. |
| 178 | // At least one policy must be specified, otherwise the HPAScalingRules will be discarded as invalid |
| 179 | // +optional |
| 180 | Policies []HPAScalingPolicy `json:"policies,omitempty" protobuf:"bytes,2,rep,name=policies"` |
| 181 | } |
| 182 | |
| 183 | // HPAScalingPolicyType is the type of the policy which could be used while making scaling decisions. |
| 184 | type HPAScalingPolicyType string |
| 185 | |
| 186 | const ( |
| 187 | // PodsScalingPolicy is a policy used to specify a change in absolute number of pods. |
| 188 | PodsScalingPolicy HPAScalingPolicyType = "Pods" |
| 189 | // PercentScalingPolicy is a policy used to specify a relative amount of change with respect to |
| 190 | // the current number of pods. |
| 191 | PercentScalingPolicy HPAScalingPolicyType = "Percent" |
| 192 | ) |
| 193 | |
| 194 | // HPAScalingPolicy is a single policy which must hold true for a specified past interval. |
| 195 | type HPAScalingPolicy struct { |
| 196 | // Type is used to specify the scaling policy. |
| 197 | Type HPAScalingPolicyType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=HPAScalingPolicyType"` |
| 198 | // Value contains the amount of change which is permitted by the policy. |
| 199 | // It must be greater than zero |
| 200 | Value int32 `json:"value" protobuf:"varint,2,opt,name=value"` |
| 201 | // PeriodSeconds specifies the window of time for which the policy should hold true. |
| 202 | // PeriodSeconds must be greater than zero and less than or equal to 1800 (30 min). |
| 203 | PeriodSeconds int32 `json:"periodSeconds" protobuf:"varint,3,opt,name=periodSeconds"` |
| 204 | } |
| 205 | |
| 206 | // MetricSourceType indicates the type of metric. |
| 207 | type MetricSourceType string |
| 208 | |
| 209 | const ( |
| 210 | // ObjectMetricSourceType is a metric describing a kubernetes object |
| 211 | // (for example, hits-per-second on an Ingress object). |
| 212 | ObjectMetricSourceType MetricSourceType = "Object" |
| 213 | // PodsMetricSourceType is a metric describing each pod in the current scale |
| 214 | // target (for example, transactions-processed-per-second). The values |
| 215 | // will be averaged together before being compared to the target value. |
| 216 | PodsMetricSourceType MetricSourceType = "Pods" |
| 217 | // ResourceMetricSourceType is a resource metric known to Kubernetes, as |
| 218 | // specified in requests and limits, describing each pod in the current |
| 219 | // scale target (e.g. CPU or memory). Such metrics are built in to |
| 220 | // Kubernetes, and have special scaling options on top of those available |
| 221 | // to normal per-pod metrics (the "pods" source). |
| 222 | ResourceMetricSourceType MetricSourceType = "Resource" |
| 223 | // ExternalMetricSourceType is a global metric that is not associated |
| 224 | // with any Kubernetes object. It allows autoscaling based on information |
| 225 | // coming from components running outside of cluster |
| 226 | // (for example length of queue in cloud messaging service, or |
| 227 | // QPS from loadbalancer running outside of cluster). |
| 228 | ExternalMetricSourceType MetricSourceType = "External" |
| 229 | ) |
| 230 | |
| 231 | // ObjectMetricSource indicates how to scale on a metric describing a |
| 232 | // kubernetes object (for example, hits-per-second on an Ingress object). |
| 233 | type ObjectMetricSource struct { |
| 234 | DescribedObject CrossVersionObjectReference `json:"describedObject" protobuf:"bytes,1,name=describedObject"` |
| 235 | // target specifies the target value for the given metric |
| 236 | Target MetricTarget `json:"target" protobuf:"bytes,2,name=target"` |
| 237 | // metric identifies the target metric by name and selector |
| 238 | Metric MetricIdentifier `json:"metric" protobuf:"bytes,3,name=metric"` |
| 239 | } |
| 240 | |
| 241 | // PodsMetricSource indicates how to scale on a metric describing each pod in |
| 242 | // the current scale target (for example, transactions-processed-per-second). |
| 243 | // The values will be averaged together before being compared to the target |
| 244 | // value. |
| 245 | type PodsMetricSource struct { |
| 246 | // metric identifies the target metric by name and selector |
| 247 | Metric MetricIdentifier `json:"metric" protobuf:"bytes,1,name=metric"` |
| 248 | // target specifies the target value for the given metric |
| 249 | Target MetricTarget `json:"target" protobuf:"bytes,2,name=target"` |
| 250 | } |
| 251 | |
| 252 | // ResourceMetricSource indicates how to scale on a resource metric known to |
| 253 | // Kubernetes, as specified in requests and limits, describing each pod in the |
| 254 | // current scale target (e.g. CPU or memory). The values will be averaged |
| 255 | // together before being compared to the target. Such metrics are built in to |
| 256 | // Kubernetes, and have special scaling options on top of those available to |
| 257 | // normal per-pod metrics using the "pods" source. Only one "target" type |
| 258 | // should be set. |
| 259 | type ResourceMetricSource struct { |
| 260 | // name is the name of the resource in question. |
| 261 | Name v1.ResourceName `json:"name" protobuf:"bytes,1,name=name"` |
| 262 | // target specifies the target value for the given metric |
| 263 | Target MetricTarget `json:"target" protobuf:"bytes,2,name=target"` |
| 264 | } |
| 265 | |
| 266 | // ExternalMetricSource indicates how to scale on a metric not associated with |
| 267 | // any Kubernetes object (for example length of queue in cloud |
| 268 | // messaging service, or QPS from loadbalancer running outside of cluster). |
| 269 | type ExternalMetricSource struct { |
| 270 | // metric identifies the target metric by name and selector |
| 271 | Metric MetricIdentifier `json:"metric" protobuf:"bytes,1,name=metric"` |
| 272 | // target specifies the target value for the given metric |
| 273 | Target MetricTarget `json:"target" protobuf:"bytes,2,name=target"` |
| 274 | } |
| 275 | |
| 276 | // MetricIdentifier defines the name and optionally selector for a metric |
| 277 | type MetricIdentifier struct { |
| 278 | // name is the name of the given metric |
| 279 | Name string `json:"name" protobuf:"bytes,1,name=name"` |
| 280 | // selector is the string-encoded form of a standard kubernetes label selector for the given metric |
| 281 | // When set, it is passed as an additional parameter to the metrics server for more specific metrics scoping. |
| 282 | // When unset, just the metricName will be used to gather metrics. |
| 283 | // +optional |
| 284 | Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,2,name=selector"` |
| 285 | } |
| 286 | |
| 287 | // MetricTarget defines the target value, average value, or average utilization of a specific metric |
| 288 | type MetricTarget struct { |
| 289 | // type represents whether the metric type is Utilization, Value, or AverageValue |
| 290 | Type MetricTargetType `json:"type" protobuf:"bytes,1,name=type"` |
| 291 | // value is the target value of the metric (as a quantity). |
| 292 | // +optional |
| 293 | Value *resource.Quantity `json:"value,omitempty" protobuf:"bytes,2,opt,name=value"` |
| 294 | // averageValue is the target value of the average of the |
| 295 | // metric across all relevant pods (as a quantity) |
| 296 | // +optional |
| 297 | AverageValue *resource.Quantity `json:"averageValue,omitempty" protobuf:"bytes,3,opt,name=averageValue"` |
| 298 | // averageUtilization is the target value of the average of the |
| 299 | // resource metric across all relevant pods, represented as a percentage of |
| 300 | // the requested value of the resource for the pods. |
| 301 | // Currently only valid for Resource metric source type |
| 302 | // +optional |
| 303 | AverageUtilization *int32 `json:"averageUtilization,omitempty" protobuf:"bytes,4,opt,name=averageUtilization"` |
| 304 | } |
| 305 | |
| 306 | // MetricTargetType specifies the type of metric being targeted, and should be either |
| 307 | // "Value", "AverageValue", or "Utilization" |
| 308 | type MetricTargetType string |
| 309 | |
| 310 | const ( |
| 311 | // UtilizationMetricType declares a MetricTarget is an AverageUtilization value |
| 312 | UtilizationMetricType MetricTargetType = "Utilization" |
| 313 | // ValueMetricType declares a MetricTarget is a raw value |
| 314 | ValueMetricType MetricTargetType = "Value" |
| 315 | // AverageValueMetricType declares a MetricTarget is an |
| 316 | AverageValueMetricType MetricTargetType = "AverageValue" |
| 317 | ) |
| 318 | |
| 319 | // HorizontalPodAutoscalerStatus describes the current status of a horizontal pod autoscaler. |
| 320 | type HorizontalPodAutoscalerStatus struct { |
| 321 | // observedGeneration is the most recent generation observed by this autoscaler. |
| 322 | // +optional |
| 323 | ObservedGeneration *int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"` |
| 324 | |
| 325 | // lastScaleTime is the last time the HorizontalPodAutoscaler scaled the number of pods, |
| 326 | // used by the autoscaler to control how often the number of pods is changed. |
| 327 | // +optional |
| 328 | LastScaleTime *metav1.Time `json:"lastScaleTime,omitempty" protobuf:"bytes,2,opt,name=lastScaleTime"` |
| 329 | |
| 330 | // currentReplicas is current number of replicas of pods managed by this autoscaler, |
| 331 | // as last seen by the autoscaler. |
| 332 | CurrentReplicas int32 `json:"currentReplicas" protobuf:"varint,3,opt,name=currentReplicas"` |
| 333 | |
| 334 | // desiredReplicas is the desired number of replicas of pods managed by this autoscaler, |
| 335 | // as last calculated by the autoscaler. |
| 336 | DesiredReplicas int32 `json:"desiredReplicas" protobuf:"varint,4,opt,name=desiredReplicas"` |
| 337 | |
| 338 | // currentMetrics is the last read state of the metrics used by this autoscaler. |
| 339 | // +optional |
| 340 | CurrentMetrics []MetricStatus `json:"currentMetrics" protobuf:"bytes,5,rep,name=currentMetrics"` |
| 341 | |
| 342 | // conditions is the set of conditions required for this autoscaler to scale its target, |
| 343 | // and indicates whether or not those conditions are met. |
| 344 | Conditions []HorizontalPodAutoscalerCondition `json:"conditions" protobuf:"bytes,6,rep,name=conditions"` |
| 345 | } |
| 346 | |
| 347 | // HorizontalPodAutoscalerConditionType are the valid conditions of |
| 348 | // a HorizontalPodAutoscaler. |
| 349 | type HorizontalPodAutoscalerConditionType string |
| 350 | |
| 351 | const ( |
| 352 | // ScalingActive indicates that the HPA controller is able to scale if necessary: |
| 353 | // it's correctly configured, can fetch the desired metrics, and isn't disabled. |
| 354 | ScalingActive HorizontalPodAutoscalerConditionType = "ScalingActive" |
| 355 | // AbleToScale indicates a lack of transient issues which prevent scaling from occurring, |
| 356 | // such as being in a backoff window, or being unable to access/update the target scale. |
| 357 | AbleToScale HorizontalPodAutoscalerConditionType = "AbleToScale" |
| 358 | // ScalingLimited indicates that the calculated scale based on metrics would be above or |
| 359 | // below the range for the HPA, and has thus been capped. |
| 360 | ScalingLimited HorizontalPodAutoscalerConditionType = "ScalingLimited" |
| 361 | ) |
| 362 | |
| 363 | // HorizontalPodAutoscalerCondition describes the state of |
| 364 | // a HorizontalPodAutoscaler at a certain point. |
| 365 | type HorizontalPodAutoscalerCondition struct { |
| 366 | // type describes the current condition |
| 367 | Type HorizontalPodAutoscalerConditionType `json:"type" protobuf:"bytes,1,name=type"` |
| 368 | // status is the status of the condition (True, False, Unknown) |
| 369 | Status v1.ConditionStatus `json:"status" protobuf:"bytes,2,name=status"` |
| 370 | // lastTransitionTime is the last time the condition transitioned from |
| 371 | // one status to another |
| 372 | // +optional |
| 373 | LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,3,opt,name=lastTransitionTime"` |
| 374 | // reason is the reason for the condition's last transition. |
| 375 | // +optional |
| 376 | Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"` |
| 377 | // message is a human-readable explanation containing details about |
| 378 | // the transition |
| 379 | // +optional |
| 380 | Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"` |
| 381 | } |
| 382 | |
| 383 | // MetricStatus describes the last-read state of a single metric. |
| 384 | type MetricStatus struct { |
| 385 | // type is the type of metric source. It will be one of "Object", |
| 386 | // "Pods" or "Resource", each corresponds to a matching field in the object. |
| 387 | Type MetricSourceType `json:"type" protobuf:"bytes,1,name=type"` |
| 388 | |
| 389 | // object refers to a metric describing a single kubernetes object |
| 390 | // (for example, hits-per-second on an Ingress object). |
| 391 | // +optional |
| 392 | Object *ObjectMetricStatus `json:"object,omitempty" protobuf:"bytes,2,opt,name=object"` |
| 393 | // pods refers to a metric describing each pod in the current scale target |
| 394 | // (for example, transactions-processed-per-second). The values will be |
| 395 | // averaged together before being compared to the target value. |
| 396 | // +optional |
| 397 | Pods *PodsMetricStatus `json:"pods,omitempty" protobuf:"bytes,3,opt,name=pods"` |
| 398 | // resource refers to a resource metric (such as those specified in |
| 399 | // requests and limits) known to Kubernetes describing each pod in the |
| 400 | // current scale target (e.g. CPU or memory). Such metrics are built in to |
| 401 | // Kubernetes, and have special scaling options on top of those available |
| 402 | // to normal per-pod metrics using the "pods" source. |
| 403 | // +optional |
| 404 | Resource *ResourceMetricStatus `json:"resource,omitempty" protobuf:"bytes,4,opt,name=resource"` |
| 405 | // external refers to a global metric that is not associated |
| 406 | // with any Kubernetes object. It allows autoscaling based on information |
| 407 | // coming from components running outside of cluster |
| 408 | // (for example length of queue in cloud messaging service, or |
| 409 | // QPS from loadbalancer running outside of cluster). |
| 410 | // +optional |
| 411 | External *ExternalMetricStatus `json:"external,omitempty" protobuf:"bytes,5,opt,name=external"` |
| 412 | } |
| 413 | |
| 414 | // ObjectMetricStatus indicates the current value of a metric describing a |
| 415 | // kubernetes object (for example, hits-per-second on an Ingress object). |
| 416 | type ObjectMetricStatus struct { |
| 417 | // metric identifies the target metric by name and selector |
| 418 | Metric MetricIdentifier `json:"metric" protobuf:"bytes,1,name=metric"` |
| 419 | // current contains the current value for the given metric |
| 420 | Current MetricValueStatus `json:"current" protobuf:"bytes,2,name=current"` |
| 421 | |
| 422 | DescribedObject CrossVersionObjectReference `json:"describedObject" protobuf:"bytes,3,name=describedObject"` |
| 423 | } |
| 424 | |
| 425 | // PodsMetricStatus indicates the current value of a metric describing each pod in |
| 426 | // the current scale target (for example, transactions-processed-per-second). |
| 427 | type PodsMetricStatus struct { |
| 428 | // metric identifies the target metric by name and selector |
| 429 | Metric MetricIdentifier `json:"metric" protobuf:"bytes,1,name=metric"` |
| 430 | // current contains the current value for the given metric |
| 431 | Current MetricValueStatus `json:"current" protobuf:"bytes,2,name=current"` |
| 432 | } |
| 433 | |
| 434 | // ResourceMetricStatus indicates the current value of a resource metric known to |
| 435 | // Kubernetes, as specified in requests and limits, describing each pod in the |
| 436 | // current scale target (e.g. CPU or memory). Such metrics are built in to |
| 437 | // Kubernetes, and have special scaling options on top of those available to |
| 438 | // normal per-pod metrics using the "pods" source. |
| 439 | type ResourceMetricStatus struct { |
| 440 | // Name is the name of the resource in question. |
| 441 | Name v1.ResourceName `json:"name" protobuf:"bytes,1,name=name"` |
| 442 | // current contains the current value for the given metric |
| 443 | Current MetricValueStatus `json:"current" protobuf:"bytes,2,name=current"` |
| 444 | } |
| 445 | |
| 446 | // ExternalMetricStatus indicates the current value of a global metric |
| 447 | // not associated with any Kubernetes object. |
| 448 | type ExternalMetricStatus struct { |
| 449 | // metric identifies the target metric by name and selector |
| 450 | Metric MetricIdentifier `json:"metric" protobuf:"bytes,1,name=metric"` |
| 451 | // current contains the current value for the given metric |
| 452 | Current MetricValueStatus `json:"current" protobuf:"bytes,2,name=current"` |
| 453 | } |
| 454 | |
| 455 | // MetricValueStatus holds the current value for a metric |
| 456 | type MetricValueStatus struct { |
| 457 | // value is the current value of the metric (as a quantity). |
| 458 | // +optional |
| 459 | Value *resource.Quantity `json:"value,omitempty" protobuf:"bytes,1,opt,name=value"` |
| 460 | // averageValue is the current value of the average of the |
| 461 | // metric across all relevant pods (as a quantity) |
| 462 | // +optional |
| 463 | AverageValue *resource.Quantity `json:"averageValue,omitempty" protobuf:"bytes,2,opt,name=averageValue"` |
| 464 | // currentAverageUtilization is the current value of the average of the |
| 465 | // resource metric across all relevant pods, represented as a percentage of |
| 466 | // the requested value of the resource for the pods. |
| 467 | // +optional |
| 468 | AverageUtilization *int32 `json:"averageUtilization,omitempty" protobuf:"bytes,3,opt,name=averageUtilization"` |
| 469 | } |
| 470 | |
| 471 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 472 | // +k8s:prerelease-lifecycle-gen:introduced=1.12 |
| 473 | // +k8s:prerelease-lifecycle-gen:deprecated=1.22 |
| 474 | |
| 475 | // HorizontalPodAutoscalerList is a list of horizontal pod autoscaler objects. |
| 476 | type HorizontalPodAutoscalerList struct { |
| 477 | metav1.TypeMeta `json:",inline"` |
| 478 | // metadata is the standard list metadata. |
| 479 | // +optional |
| 480 | metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` |
| 481 | |
| 482 | // items is the list of horizontal pod autoscaler objects. |
| 483 | Items []HorizontalPodAutoscaler `json:"items" protobuf:"bytes,2,rep,name=items"` |
| 484 | } |