cue.dev/x/k8s.io@v0.12.0

api/autoscaling/v2/schema.cue raw

  1package v2
  2
  3import (
  4	"cue.dev/x/k8s.io/apimachinery/pkg/api/resource"
  5	"cue.dev/x/k8s.io/apimachinery/pkg/apis/meta/v1"
  6)
  7
  8// ContainerResourceMetricSource indicates how to scale on a resource metric
  9// known to Kubernetes, as specified in requests and limits, describing each
 10// pod in the current scale target (e.g. CPU or memory). The values will be
 11// averaged together before being compared to the target. Such metrics are
 12// built in to Kubernetes, and have special scaling options on top of those
 13// available to normal per-pod metrics using the "pods" source. Only one
 14// "target" type should be set.
 15#ContainerResourceMetricSource: {
 16	// container is the name of the container in the pods of the scaling target
 17	"container"!: string
 18
 19	// name is the name of the resource in question.
 20	"name"!: string
 21
 22	// target specifies the target value for the given metric
 23	"target"!: #MetricTarget
 24}
 25
 26// ContainerResourceMetricStatus indicates the current value of a resource
 27// metric known to Kubernetes, as specified in requests and limits, describing
 28// a single container in each pod in the current scale target (e.g. CPU or
 29// memory). Such metrics are built in to Kubernetes, and have special scaling
 30// options on top of those available to normal per-pod metrics using the "pods"
 31// source.
 32#ContainerResourceMetricStatus: {
 33	// container is the name of the container in the pods of the scaling target
 34	"container"!: string
 35
 36	// current contains the current value for the given metric
 37	"current"!: #MetricValueStatus
 38
 39	// name is the name of the resource in question.
 40	"name"!: string
 41}
 42
 43// CrossVersionObjectReference contains enough information to let you identify
 44// the referred resource.
 45#CrossVersionObjectReference: {
 46	// apiVersion is the API version of the referent
 47	"apiVersion"?: string
 48
 49	// kind is the kind of the referent; More info:
 50	// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
 51	"kind"!: string
 52
 53	// name is the name of the referent; More info:
 54	// https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
 55	"name"!: string
 56}
 57
 58// ExternalMetricSource indicates how to scale on a metric not associated with
 59// any Kubernetes object (for example length of queue in cloud messaging
 60// service, or QPS from loadbalancer running outside of cluster).
 61#ExternalMetricSource: {
 62	// metric identifies the target metric by name and selector
 63	"metric"!: #MetricIdentifier
 64
 65	// target specifies the target value for the given metric
 66	"target"!: #MetricTarget
 67}
 68
 69// ExternalMetricStatus indicates the current value of a global metric not
 70// associated with any Kubernetes object.
 71#ExternalMetricStatus: {
 72	// current contains the current value for the given metric
 73	"current"!: #MetricValueStatus
 74
 75	// metric identifies the target metric by name and selector
 76	"metric"!: #MetricIdentifier
 77}
 78
 79// HPAScalingPolicy is a single policy which must hold true for a specified past interval.
 80#HPAScalingPolicy: {
 81	// periodSeconds specifies the window of time for which the policy should hold
 82	// true. PeriodSeconds must be greater than zero and less than or equal to 1800
 83	// (30 min).
 84	"periodSeconds"!: int32 & int
 85
 86	// type is used to specify the scaling policy.
 87	"type"!: string
 88
 89	// value contains the amount of change which is permitted by the policy. It must
 90	// be greater than zero
 91	"value"!: int32 & int
 92}
 93
 94// HPAScalingRules configures the scaling behavior for one direction via scaling
 95// Policy Rules and a configurable metric tolerance.
 96//
 97// Scaling Policy Rules are applied after calculating DesiredReplicas from
 98// metrics for the HPA. They can limit the scaling velocity by specifying
 99// scaling policies. They can prevent flapping by specifying the stabilization
100// window, so that the number of replicas is not set instantly, instead, the
101// safest value from the stabilization window is chosen.
102//
103// The tolerance is applied to the metric values and prevents scaling too
104// eagerly for small metric variations. (Note that setting a tolerance requires
105// the beta HPAConfigurableTolerance feature gate to be enabled.)
106#HPAScalingRules: {
107	// policies is a list of potential scaling polices which can be used during
108	// scaling. If not set, use the default values: - For scale up: allow doubling
109	// the number of pods, or an absolute change of 4 pods in a 15s window. - For
110	// scale down: allow all pods to be removed in a 15s window.
111	"policies"?: [...#HPAScalingPolicy]
112
113	// selectPolicy is used to specify which policy should be used. If not set, the
114	// default value Max is used.
115	"selectPolicy"?: string
116
117	// stabilizationWindowSeconds is the number of seconds for which past
118	// recommendations should be considered while scaling up or scaling down.
119	// StabilizationWindowSeconds must be greater than or equal to zero and less
120	// than or equal to 3600 (one hour). If not set, use the default values: - For
121	// scale up: 0 (i.e. no stabilization is done). - For scale down: 300 (i.e. the
122	// stabilization window is 300 seconds long).
123	"stabilizationWindowSeconds"?: int32 & int
124
125	// tolerance is the tolerance on the ratio between the current and desired
126	// metric value under which no updates are made to the desired number of
127	// replicas (e.g. 0.01 for 1%). Must be greater than or equal to zero. If not
128	// set, the default cluster-wide tolerance is applied (by default 10%).
129	//
130	// For example, if autoscaling is configured with a memory consumption target of
131	// 100Mi, and scale-down and scale-up tolerances of 5% and 1% respectively,
132	// scaling will be triggered when the actual consumption falls below 95Mi or
133	// exceeds 101Mi.
134	//
135	// This is an beta field and requires the HPAConfigurableTolerance feature gate to be enabled.
136	"tolerance"?: resource.#Quantity
137}
138
139// HorizontalPodAutoscaler is the configuration for a horizontal pod autoscaler,
140// which automatically manages the replica count of any resource implementing
141// the scale subresource based on the metrics specified.
142#HorizontalPodAutoscaler: {
143	// APIVersion defines the versioned schema of this representation of an object.
144	// Servers should convert recognized schemas to the latest internal value, and
145	// may reject unrecognized values. More info:
146	// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
147	"apiVersion": "autoscaling/v2"
148
149	// Kind is a string value representing the REST resource this object represents.
150	// Servers may infer this from the endpoint the client submits requests to.
151	// Cannot be updated. In CamelCase. More info:
152	// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
153	"kind": "HorizontalPodAutoscaler"
154
155	// metadata is the standard object metadata. More info:
156	// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
157	"metadata"?: v1.#ObjectMeta
158
159	// spec is the specification for the behaviour of the autoscaler. More info:
160	// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status.
161	"spec"!: #HorizontalPodAutoscalerSpec
162
163	// status is the current information about the autoscaler.
164	"status"?: #HorizontalPodAutoscalerStatus
165}
166
167// HorizontalPodAutoscalerBehavior configures the scaling behavior of the target
168// in both Up and Down directions (scaleUp and scaleDown fields respectively).
169#HorizontalPodAutoscalerBehavior: {
170	// scaleDown is scaling policy for scaling Down. If not set, the default value
171	// is to allow to scale down to minReplicas pods, with a 300 second
172	// stabilization window (i.e., the highest recommendation for the last 300sec
173	// is used).
174	"scaleDown"?: #HPAScalingRules
175
176	// scaleUp is scaling policy for scaling Up. If not set, the default value is the higher of:
177	// * increase no more than 4 pods per 60 seconds
178	// * double the number of pods per 60 seconds
179	// No stabilization is used.
180	"scaleUp"?: #HPAScalingRules
181}
182
183// HorizontalPodAutoscalerCondition describes the state of a
184// HorizontalPodAutoscaler at a certain point.
185#HorizontalPodAutoscalerCondition: {
186	// lastTransitionTime is the last time the condition transitioned from one status to another
187	"lastTransitionTime"?: v1.#Time
188
189	// message is a human-readable explanation containing details about the transition
190	"message"?: string
191
192	// reason is the reason for the condition's last transition.
193	"reason"?: string
194
195	// status is the status of the condition (True, False, Unknown)
196	"status"!: string
197
198	// type describes the current condition
199	"type"!: string
200}
201
202// HorizontalPodAutoscalerList is a list of horizontal pod autoscaler objects.
203#HorizontalPodAutoscalerList: {
204	// APIVersion defines the versioned schema of this representation of an object.
205	// Servers should convert recognized schemas to the latest internal value, and
206	// may reject unrecognized values. More info:
207	// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
208	"apiVersion": "autoscaling/v2"
209
210	// items is the list of horizontal pod autoscaler objects.
211	"items"!: [...#HorizontalPodAutoscaler]
212
213	// Kind is a string value representing the REST resource this object represents.
214	// Servers may infer this from the endpoint the client submits requests to.
215	// Cannot be updated. In CamelCase. More info:
216	// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
217	"kind": "HorizontalPodAutoscalerList"
218
219	// metadata is the standard list metadata.
220	"metadata"?: v1.#ListMeta
221}
222
223// HorizontalPodAutoscalerSpec describes the desired functionality of the HorizontalPodAutoscaler.
224#HorizontalPodAutoscalerSpec: {
225	// behavior configures the scaling behavior of the target in both Up and Down
226	// directions (scaleUp and scaleDown fields respectively). If not set, the
227	// default HPAScalingRules for scale up and scale down are used.
228	"behavior"?: #HorizontalPodAutoscalerBehavior
229
230	// maxReplicas is the upper limit for the number of replicas to which the
231	// autoscaler can scale up. It cannot be less that minReplicas.
232	"maxReplicas"!: int32 & int
233
234	// metrics contains the specifications for which to use to calculate the desired
235	// replica count (the maximum replica count across all metrics will be used).
236	// The desired replica count is calculated multiplying the ratio between the
237	// target value and the current value by the current number of pods. Ergo,
238	// metrics used must decrease as the pod count is increased, and vice-versa.
239	// See the individual metric source types for more information about how each
240	// type of metric must respond. If not set, the default metric will be set to
241	// 80% average CPU utilization.
242	"metrics"?: [...#MetricSpec]
243
244	// minReplicas is the lower limit for the number of replicas to which the
245	// autoscaler can scale down. It defaults to 1 pod. minReplicas is allowed to
246	// be 0 if the alpha feature gate HPAScaleToZero is enabled and at least one
247	// Object or External metric is configured. Scaling is active as long as at
248	// least one metric value is available.
249	"minReplicas"?: int32 & int
250
251	// scaleTargetRef points to the target resource to scale, and is used to the
252	// pods for which metrics should be collected, as well as to actually change
253	// the replica count.
254	"scaleTargetRef"!: #CrossVersionObjectReference
255}
256
257// HorizontalPodAutoscalerStatus describes the current status of a horizontal pod autoscaler.
258#HorizontalPodAutoscalerStatus: {
259	// conditions is the set of conditions required for this autoscaler to scale its
260	// target, and indicates whether or not those conditions are met.
261	"conditions"?: [...#HorizontalPodAutoscalerCondition]
262
263	// currentMetrics is the last read state of the metrics used by this autoscaler.
264	"currentMetrics"?: [...#MetricStatus]
265
266	// currentReplicas is current number of replicas of pods managed by this
267	// autoscaler, as last seen by the autoscaler.
268	"currentReplicas"?: int32 & int
269
270	// desiredReplicas is the desired number of replicas of pods managed by this
271	// autoscaler, as last calculated by the autoscaler.
272	"desiredReplicas"!: int32 & int
273
274	// lastScaleTime is the last time the HorizontalPodAutoscaler scaled the number
275	// of pods, used by the autoscaler to control how often the number of pods is
276	// changed.
277	"lastScaleTime"?: v1.#Time
278
279	// observedGeneration is the most recent generation observed by this autoscaler.
280	"observedGeneration"?: int64 & int
281}
282
283// MetricIdentifier defines the name and optionally selector for a metric
284#MetricIdentifier: {
285	// name is the name of the given metric
286	"name"!: string
287
288	// selector is the string-encoded form of a standard kubernetes label selector
289	// for the given metric When set, it is passed as an additional parameter to
290	// the metrics server for more specific metrics scoping. When unset, just the
291	// metricName will be used to gather metrics.
292	"selector"?: v1.#LabelSelector
293}
294
295// MetricSpec specifies how to scale based on a single metric (only `type` and
296// one other matching field should be set at once).
297#MetricSpec: {
298	// containerResource refers to a resource metric (such as those specified in
299	// requests and limits) known to Kubernetes describing a single container in
300	// each pod of the current scale target (e.g. CPU or memory). Such metrics are
301	// built in to Kubernetes, and have special scaling options on top of those
302	// available to normal per-pod metrics using the "pods" source.
303	"containerResource"?: #ContainerResourceMetricSource
304
305	// external refers to a global metric that is not associated with any Kubernetes
306	// object. It allows autoscaling based on information coming from components
307	// running outside of cluster (for example length of queue in cloud messaging
308	// service, or QPS from loadbalancer running outside of cluster).
309	"external"?: #ExternalMetricSource
310
311	// object refers to a metric describing a single kubernetes object (for example,
312	// hits-per-second on an Ingress object).
313	"object"?: #ObjectMetricSource
314
315	// pods refers to a metric describing each pod in the current scale target (for
316	// example, transactions-processed-per-second). The values will be averaged
317	// together before being compared to the target value.
318	"pods"?: #PodsMetricSource
319
320	// resource refers to a resource metric (such as those specified in requests and
321	// limits) known to Kubernetes describing each pod in the current scale target
322	// (e.g. CPU or memory). Such metrics are built in to Kubernetes, and have
323	// special scaling options on top of those available to normal per-pod metrics
324	// using the "pods" source.
325	"resource"?: #ResourceMetricSource
326
327	// type is the type of metric source. It should be one of "ContainerResource",
328	// "External", "Object", "Pods" or "Resource", each mapping to a matching field
329	// in the object.
330	"type"!: string
331}
332
333// MetricStatus describes the last-read state of a single metric.
334#MetricStatus: {
335	// container resource refers to a resource metric (such as those specified in
336	// requests and limits) known to Kubernetes describing a single container in
337	// each pod in the current scale target (e.g. CPU or memory). Such metrics are
338	// built in to Kubernetes, and have special scaling options on top of those
339	// available to normal per-pod metrics using the "pods" source.
340	"containerResource"?: #ContainerResourceMetricStatus
341
342	// external refers to a global metric that is not associated with any Kubernetes
343	// object. It allows autoscaling based on information coming from components
344	// running outside of cluster (for example length of queue in cloud messaging
345	// service, or QPS from loadbalancer running outside of cluster).
346	"external"?: #ExternalMetricStatus
347
348	// object refers to a metric describing a single kubernetes object (for example,
349	// hits-per-second on an Ingress object).
350	"object"?: #ObjectMetricStatus
351
352	// pods refers to a metric describing each pod in the current scale target (for
353	// example, transactions-processed-per-second). The values will be averaged
354	// together before being compared to the target value.
355	"pods"?: #PodsMetricStatus
356
357	// resource refers to a resource metric (such as those specified in requests and
358	// limits) known to Kubernetes describing each pod in the current scale target
359	// (e.g. CPU or memory). Such metrics are built in to Kubernetes, and have
360	// special scaling options on top of those available to normal per-pod metrics
361	// using the "pods" source.
362	"resource"?: #ResourceMetricStatus
363
364	// type is the type of metric source. It will be one of "ContainerResource",
365	// "External", "Object", "Pods" or "Resource", each corresponds to a matching
366	// field in the object.
367	"type"!: string
368}
369
370// MetricTarget defines the target value, average value, or average utilization of a specific metric
371#MetricTarget: {
372	// averageUtilization is the target value of the average of the resource metric
373	// across all relevant pods, represented as a percentage of the requested value
374	// of the resource for the pods. Currently only valid for Resource metric
375	// source type
376	"averageUtilization"?: int32 & int
377
378	// averageValue is the target value of the average of the metric across all
379	// relevant pods (as a quantity)
380	"averageValue"?: resource.#Quantity
381
382	// type represents whether the metric type is Utilization, Value, or AverageValue
383	"type"!: string
384
385	// value is the target value of the metric (as a quantity).
386	"value"?: resource.#Quantity
387}
388
389// MetricValueStatus holds the current value for a metric
390#MetricValueStatus: {
391	// currentAverageUtilization is the current value of the average of the resource
392	// metric across all relevant pods, represented as a percentage of the
393	// requested value of the resource for the pods.
394	"averageUtilization"?: int32 & int
395
396	// averageValue is the current value of the average of the metric across all
397	// relevant pods (as a quantity)
398	"averageValue"?: resource.#Quantity
399
400	// value is the current value of the metric (as a quantity).
401	"value"?: resource.#Quantity
402}
403
404// ObjectMetricSource indicates how to scale on a metric describing a kubernetes
405// object (for example, hits-per-second on an Ingress object).
406#ObjectMetricSource: {
407	// describedObject specifies the descriptions of a object,such as kind,name apiVersion
408	"describedObject"!: #CrossVersionObjectReference
409
410	// metric identifies the target metric by name and selector
411	"metric"!: #MetricIdentifier
412
413	// target specifies the target value for the given metric
414	"target"!: #MetricTarget
415}
416
417// ObjectMetricStatus indicates the current value of a metric describing a
418// kubernetes object (for example, hits-per-second on an Ingress object).
419#ObjectMetricStatus: {
420	// current contains the current value for the given metric
421	"current"!: #MetricValueStatus
422
423	// DescribedObject specifies the descriptions of a object,such as kind,name apiVersion
424	"describedObject"!: #CrossVersionObjectReference
425
426	// metric identifies the target metric by name and selector
427	"metric"!: #MetricIdentifier
428}
429
430// PodsMetricSource indicates how to scale on a metric describing each pod in
431// the current scale target (for example, transactions-processed-per-second).
432// The values will be averaged together before being compared to the target
433// value.
434#PodsMetricSource: {
435	// metric identifies the target metric by name and selector
436	"metric"!: #MetricIdentifier
437
438	// target specifies the target value for the given metric
439	"target"!: #MetricTarget
440}
441
442// PodsMetricStatus indicates the current value of a metric describing each pod
443// in the current scale target (for example,
444// transactions-processed-per-second).
445#PodsMetricStatus: {
446	// current contains the current value for the given metric
447	"current"!: #MetricValueStatus
448
449	// metric identifies the target metric by name and selector
450	"metric"!: #MetricIdentifier
451}
452
453// ResourceMetricSource indicates how to scale on a resource metric known to
454// Kubernetes, as specified in requests and limits, describing each pod in the
455// current scale target (e.g. CPU or memory). The values will be averaged
456// together before being compared to the target. Such metrics are built in to
457// Kubernetes, and have special scaling options on top of those available to
458// normal per-pod metrics using the "pods" source. Only one "target" type
459// should be set.
460#ResourceMetricSource: {
461	// name is the name of the resource in question.
462	"name"!: string
463
464	// target specifies the target value for the given metric
465	"target"!: #MetricTarget
466}
467
468// ResourceMetricStatus indicates the current value of a resource metric known
469// to Kubernetes, as specified in requests and limits, describing each pod in
470// the current scale target (e.g. CPU or memory). Such metrics are built in to
471// Kubernetes, and have special scaling options on top of those available to
472// normal per-pod metrics using the "pods" source.
473#ResourceMetricStatus: {
474	// current contains the current value for the given metric
475	"current"!: #MetricValueStatus
476
477	// name is the name of the resource in question.
478	"name"!: string
479}