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