cdk8s-plus-31 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.backportrc.json +17 -0
- package/.jsii +90235 -0
- package/CODE_OF_CONDUCT.md +3 -0
- package/CONTRIBUTING.md +185 -0
- package/DCO +34 -0
- package/LICENSE +202 -0
- package/NOTICE +1 -0
- package/OWNERS.md +5 -0
- package/README.md +32 -0
- package/SECURITY.md +5 -0
- package/cdk8s.yaml +8 -0
- package/docs/java.md +23855 -0
- package/docs/plus/config-map.md +98 -0
- package/docs/plus/container.md +133 -0
- package/docs/plus/cronjob.md +67 -0
- package/docs/plus/deployment.md +232 -0
- package/docs/plus/horizontal-pod-autoscaler.md +226 -0
- package/docs/plus/ingress.md +68 -0
- package/docs/plus/job.md +48 -0
- package/docs/plus/namespace.md +58 -0
- package/docs/plus/network-policy.md +341 -0
- package/docs/plus/pod.md +455 -0
- package/docs/plus/pv.md +82 -0
- package/docs/plus/pvc.md +77 -0
- package/docs/plus/rbac.md +104 -0
- package/docs/plus/secret.md +32 -0
- package/docs/plus/service-account.md +35 -0
- package/docs/plus/service.md +41 -0
- package/docs/plus/volume.md +38 -0
- package/docs/python.md +26079 -0
- package/docs/typescript.md +19565 -0
- package/git-hooks/README.md +9 -0
- package/git-hooks/prepare-commit-msg +18 -0
- package/git-hooks/setup.sh +10 -0
- package/lib/_action.d.ts +21 -0
- package/lib/_action.js +32 -0
- package/lib/api-resource.d.ts +298 -0
- package/lib/api-resource.js +430 -0
- package/lib/base.d.ts +79 -0
- package/lib/base.js +92 -0
- package/lib/config-map.d.ts +126 -0
- package/lib/config-map.js +159 -0
- package/lib/container.d.ts +1057 -0
- package/lib/container.js +845 -0
- package/lib/cron-job.d.ts +138 -0
- package/lib/cron-job.js +103 -0
- package/lib/daemon-set.d.ts +45 -0
- package/lib/daemon-set.js +55 -0
- package/lib/deployment.d.ts +223 -0
- package/lib/deployment.js +214 -0
- package/lib/handler.d.ts +62 -0
- package/lib/handler.js +54 -0
- package/lib/horizontal-pod-autoscaler.d.ts +500 -0
- package/lib/horizontal-pod-autoscaler.js +569 -0
- package/lib/imports/k8s.d.ts +21534 -0
- package/lib/imports/k8s.js +16496 -0
- package/lib/index.d.ts +26 -0
- package/lib/index.js +39 -0
- package/lib/ingress.d.ts +230 -0
- package/lib/ingress.js +246 -0
- package/lib/job.d.ts +64 -0
- package/lib/job.js +54 -0
- package/lib/namespace.d.ts +128 -0
- package/lib/namespace.js +109 -0
- package/lib/network-policy.d.ts +311 -0
- package/lib/network-policy.js +344 -0
- package/lib/pod.d.ts +1080 -0
- package/lib/pod.js +1139 -0
- package/lib/probe.d.ts +141 -0
- package/lib/probe.js +77 -0
- package/lib/pv.d.ts +375 -0
- package/lib/pv.js +273 -0
- package/lib/pvc.d.ts +163 -0
- package/lib/pvc.js +152 -0
- package/lib/role-binding.d.ts +138 -0
- package/lib/role-binding.js +165 -0
- package/lib/role.d.ts +268 -0
- package/lib/role.js +401 -0
- package/lib/secret.d.ts +195 -0
- package/lib/secret.js +185 -0
- package/lib/service-account.d.ts +83 -0
- package/lib/service-account.js +105 -0
- package/lib/service.d.ts +289 -0
- package/lib/service.js +182 -0
- package/lib/stateful-set.d.ts +169 -0
- package/lib/stateful-set.js +174 -0
- package/lib/utils.d.ts +4 -0
- package/lib/utils.js +34 -0
- package/lib/volume.d.ts +573 -0
- package/lib/volume.js +371 -0
- package/lib/workload.d.ts +121 -0
- package/lib/workload.js +122 -0
- package/node_modules/balanced-match/.github/FUNDING.yml +2 -0
- package/node_modules/balanced-match/LICENSE.md +21 -0
- package/node_modules/balanced-match/README.md +97 -0
- package/node_modules/balanced-match/index.js +62 -0
- package/node_modules/balanced-match/package.json +48 -0
- package/node_modules/concat-map/.travis.yml +4 -0
- package/node_modules/concat-map/LICENSE +18 -0
- package/node_modules/concat-map/README.markdown +62 -0
- package/node_modules/concat-map/example/map.js +6 -0
- package/node_modules/concat-map/index.js +13 -0
- package/node_modules/concat-map/package.json +43 -0
- package/node_modules/concat-map/test/map.js +39 -0
- package/node_modules/minimatch/LICENSE +15 -0
- package/node_modules/minimatch/README.md +230 -0
- package/node_modules/minimatch/minimatch.js +947 -0
- package/node_modules/minimatch/node_modules/brace-expansion/LICENSE +21 -0
- package/node_modules/minimatch/node_modules/brace-expansion/README.md +129 -0
- package/node_modules/minimatch/node_modules/brace-expansion/index.js +201 -0
- package/node_modules/minimatch/node_modules/brace-expansion/package.json +47 -0
- package/node_modules/minimatch/package.json +33 -0
- package/package.json +186 -0
- package/rotate.md +84 -0
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
import { ApiObject, Duration } from 'cdk8s';
|
|
2
|
+
import { Construct } from 'constructs';
|
|
3
|
+
import { Resource, ResourceProps, IResource } from './base';
|
|
4
|
+
import * as container from './container';
|
|
5
|
+
import * as k8s from './imports/k8s';
|
|
6
|
+
import * as pod from './pod';
|
|
7
|
+
/**
|
|
8
|
+
* Properties used to configure the target of an Autoscaler.
|
|
9
|
+
*/
|
|
10
|
+
export interface ScalingTarget {
|
|
11
|
+
/**
|
|
12
|
+
* The object kind (e.g. "Deployment").
|
|
13
|
+
*/
|
|
14
|
+
readonly kind: string;
|
|
15
|
+
/**
|
|
16
|
+
* The object's API version (e.g. "authorization.k8s.io/v1")
|
|
17
|
+
*/
|
|
18
|
+
readonly apiVersion: string;
|
|
19
|
+
/**
|
|
20
|
+
* The Kubernetes name of this resource.
|
|
21
|
+
*/
|
|
22
|
+
readonly name: string;
|
|
23
|
+
/**
|
|
24
|
+
* Container definitions associated with the target.
|
|
25
|
+
*/
|
|
26
|
+
readonly containers: container.Container[];
|
|
27
|
+
/**
|
|
28
|
+
* The fixed number of replicas defined on the target. This is used
|
|
29
|
+
* for validation purposes as Scalable targets should not have a
|
|
30
|
+
* fixed number of replicas.
|
|
31
|
+
*/
|
|
32
|
+
readonly replicas?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Represents a scalable workload.
|
|
36
|
+
*/
|
|
37
|
+
export interface IScalable {
|
|
38
|
+
/**
|
|
39
|
+
* If this is a target of an autoscaler.
|
|
40
|
+
*/
|
|
41
|
+
hasAutoscaler: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Called on all IScalable targets when they are associated with an autoscaler.
|
|
44
|
+
*/
|
|
45
|
+
markHasAutoscaler(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Return the target spec properties of this Scalable.
|
|
48
|
+
*/
|
|
49
|
+
toScalingTarget(): ScalingTarget;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Properties for HorizontalPodAutoscaler
|
|
53
|
+
*/
|
|
54
|
+
export interface HorizontalPodAutoscalerProps extends ResourceProps {
|
|
55
|
+
/**
|
|
56
|
+
* The workload to scale up or down.
|
|
57
|
+
*
|
|
58
|
+
* Scalable workload types:
|
|
59
|
+
* * Deployment
|
|
60
|
+
* * StatefulSet
|
|
61
|
+
*/
|
|
62
|
+
readonly target: IScalable;
|
|
63
|
+
/**
|
|
64
|
+
* The maximum number of replicas that can be scaled up to.
|
|
65
|
+
*/
|
|
66
|
+
readonly maxReplicas: number;
|
|
67
|
+
/**
|
|
68
|
+
* The minimum number of replicas that can be scaled down to.
|
|
69
|
+
*
|
|
70
|
+
* Can be set to 0 if the alpha feature gate `HPAScaleToZero` is enabled and
|
|
71
|
+
* at least one Object or External metric is configured.
|
|
72
|
+
*
|
|
73
|
+
* @default 1
|
|
74
|
+
*/
|
|
75
|
+
readonly minReplicas?: number;
|
|
76
|
+
/**
|
|
77
|
+
* The metric conditions that trigger a scale up or scale down.
|
|
78
|
+
*
|
|
79
|
+
* @default - If metrics are not provided, then the target resource
|
|
80
|
+
* constraints (e.g. cpu limit) will be used as scaling metrics.
|
|
81
|
+
*/
|
|
82
|
+
readonly metrics?: Metric[];
|
|
83
|
+
/**
|
|
84
|
+
* The scaling behavior when scaling up.
|
|
85
|
+
*
|
|
86
|
+
* @default - Is the higher of:
|
|
87
|
+
* * Increase no more than 4 pods per 60 seconds
|
|
88
|
+
* * Double the number of pods per 60 seconds
|
|
89
|
+
*/
|
|
90
|
+
readonly scaleUp?: ScalingRules;
|
|
91
|
+
/**
|
|
92
|
+
* The scaling behavior when scaling down.
|
|
93
|
+
*
|
|
94
|
+
* @default - Scale down to minReplica count with a 5 minute stabilization window.
|
|
95
|
+
*/
|
|
96
|
+
readonly scaleDown?: ScalingRules;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* A HorizontalPodAutoscaler scales a workload up or down in response to a metric
|
|
100
|
+
* change. This allows your services to scale up when demand is high and scale down
|
|
101
|
+
* when they are no longer needed.
|
|
102
|
+
*
|
|
103
|
+
*
|
|
104
|
+
* Typical use cases for HorizontalPodAutoscaler:
|
|
105
|
+
*
|
|
106
|
+
* * When Memory usage is above 70%, scale up the number of replicas to meet the demand.
|
|
107
|
+
* * When CPU usage is below 30%, scale down the number of replicas to save resources.
|
|
108
|
+
* * When a service is experiencing a spike in traffic, scale up the number of replicas
|
|
109
|
+
* to meet the demand. Then, when the traffic subsides, scale down the number of
|
|
110
|
+
* replicas to save resources.
|
|
111
|
+
*
|
|
112
|
+
* The autoscaler uses the following algorithm to determine the number of replicas to scale:
|
|
113
|
+
*
|
|
114
|
+
* `desiredReplicas = ceil[currentReplicas * ( currentMetricValue / desiredMetricValue )]`
|
|
115
|
+
*
|
|
116
|
+
* HorizontalPodAutoscaler's can be used to with any `Scalable` workload:
|
|
117
|
+
* * Deployment
|
|
118
|
+
* * StatefulSet
|
|
119
|
+
*
|
|
120
|
+
* **Targets that already have a replica count defined:**
|
|
121
|
+
*
|
|
122
|
+
* Remove any replica counts from the target resource before associating with a
|
|
123
|
+
* HorizontalPodAutoscaler. If this isn't done, then any time a change to that object is applied,
|
|
124
|
+
* Kubernetes will scale the current number of Pods to the value of the target.replicas key. This
|
|
125
|
+
* may not be desired and could lead to unexpected behavior.
|
|
126
|
+
*
|
|
127
|
+
* @see https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#implicit-maintenance-mode-deactivation
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* const backend = new kplus.Deployment(this, 'Backend', ...);
|
|
131
|
+
*
|
|
132
|
+
* const hpa = new kplus.HorizontalPodAutoscaler(chart, 'Hpa', {
|
|
133
|
+
* target: backend,
|
|
134
|
+
* maxReplicas: 10,
|
|
135
|
+
* scaleUp: {
|
|
136
|
+
* policies: [
|
|
137
|
+
* {
|
|
138
|
+
* replicas: kplus.Replicas.absolute(3),
|
|
139
|
+
* duration: Duration.minutes(5),
|
|
140
|
+
* },
|
|
141
|
+
* ],
|
|
142
|
+
* },
|
|
143
|
+
* });
|
|
144
|
+
*/
|
|
145
|
+
export declare class HorizontalPodAutoscaler extends Resource {
|
|
146
|
+
/**
|
|
147
|
+
* @see base.Resource.apiObject
|
|
148
|
+
*/
|
|
149
|
+
protected readonly apiObject: ApiObject;
|
|
150
|
+
readonly resourceType = "horizontalpodautoscaler";
|
|
151
|
+
/**
|
|
152
|
+
* The workload to scale up or down.
|
|
153
|
+
*/
|
|
154
|
+
readonly target: IScalable;
|
|
155
|
+
/**
|
|
156
|
+
* The maximum number of replicas that can be scaled up to.
|
|
157
|
+
*/
|
|
158
|
+
readonly maxReplicas: number;
|
|
159
|
+
/**
|
|
160
|
+
* The minimum number of replicas that can be scaled down to.
|
|
161
|
+
*/
|
|
162
|
+
readonly minReplicas: number;
|
|
163
|
+
/**
|
|
164
|
+
* The metric conditions that trigger a scale up or scale down.
|
|
165
|
+
*/
|
|
166
|
+
readonly metrics?: Metric[];
|
|
167
|
+
/**
|
|
168
|
+
* The scaling behavior when scaling up.
|
|
169
|
+
*/
|
|
170
|
+
readonly scaleUp: ScalingRules;
|
|
171
|
+
/**
|
|
172
|
+
* The scaling behavior when scaling down.
|
|
173
|
+
*/
|
|
174
|
+
readonly scaleDown: ScalingRules;
|
|
175
|
+
private readonly _defaultScalingDuration;
|
|
176
|
+
constructor(scope: Construct, id: string, props: HorizontalPodAutoscalerProps);
|
|
177
|
+
/**
|
|
178
|
+
* Validate a list of scaling policies.
|
|
179
|
+
* @internal
|
|
180
|
+
*/
|
|
181
|
+
private _validateScalingPolicies;
|
|
182
|
+
/**
|
|
183
|
+
* Validate `ScalingPolicy.duration` is within the allowed range.
|
|
184
|
+
*
|
|
185
|
+
* `duration` range: 1 second - 30 min
|
|
186
|
+
*
|
|
187
|
+
* Kubernetes name: `ScalingPolicy.periodSeconds`.
|
|
188
|
+
* @see https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/horizontal-pod-autoscaler-v2/#HorizontalPodAutoscalerSpec
|
|
189
|
+
* @internal
|
|
190
|
+
*/
|
|
191
|
+
private _validateScalingPolicyDuration;
|
|
192
|
+
/**
|
|
193
|
+
* Validate `ScalingRules.stabilizationWindow` is within the allowed range.
|
|
194
|
+
*
|
|
195
|
+
* `stabilizationWindow` range: 0 seconds - 1 hour
|
|
196
|
+
*
|
|
197
|
+
* @see https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/horizontal-pod-autoscaler-v2/#HorizontalPodAutoscalerSpec
|
|
198
|
+
* @internal
|
|
199
|
+
*/
|
|
200
|
+
private _validateStabilizationWindow;
|
|
201
|
+
/**
|
|
202
|
+
* Guarantee the HPA has a metric to scale on.
|
|
203
|
+
* Verify that metrics are configured, if not check every pod container has a resource limit or
|
|
204
|
+
* request defined.
|
|
205
|
+
* @internal
|
|
206
|
+
*/
|
|
207
|
+
private _validateTargetContainers;
|
|
208
|
+
/**
|
|
209
|
+
* Prevent the HPA from scaling a target with a replica count defined.
|
|
210
|
+
* @see https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#implicit-maintenance-mode-deactivation
|
|
211
|
+
* @internal
|
|
212
|
+
*/
|
|
213
|
+
private _validateTargetReplicas;
|
|
214
|
+
/**
|
|
215
|
+
* Validate that the container has at least one CPU/memory request/limit defined.
|
|
216
|
+
* @internal
|
|
217
|
+
*/
|
|
218
|
+
private _hasRequestsOrLimits;
|
|
219
|
+
/**
|
|
220
|
+
* @internal
|
|
221
|
+
*/
|
|
222
|
+
_toKube(): k8s.HorizontalPodAutoscalerSpecV2;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Base options for a Metric
|
|
226
|
+
*/
|
|
227
|
+
export interface MetricOptions {
|
|
228
|
+
/**
|
|
229
|
+
* The target metric value that will trigger scaling.
|
|
230
|
+
*/
|
|
231
|
+
readonly target: MetricTarget;
|
|
232
|
+
/**
|
|
233
|
+
* The name of the metric to scale on.
|
|
234
|
+
*/
|
|
235
|
+
readonly name: string;
|
|
236
|
+
/**
|
|
237
|
+
* A selector to find a metric by label.
|
|
238
|
+
*
|
|
239
|
+
* When set, it is passed as an additional parameter to the metrics server
|
|
240
|
+
* for more specific metrics scoping.
|
|
241
|
+
*
|
|
242
|
+
* @default - Just the metric 'name' will be used to gather metrics.
|
|
243
|
+
*/
|
|
244
|
+
readonly labelSelector?: pod.LabelSelector;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Options for `Metric.containerResource()`
|
|
248
|
+
*/
|
|
249
|
+
export interface MetricContainerResourceOptions {
|
|
250
|
+
/**
|
|
251
|
+
* Container where the metric can be found.
|
|
252
|
+
*/
|
|
253
|
+
readonly container: container.Container;
|
|
254
|
+
/**
|
|
255
|
+
* Target metric value that will trigger scaling.
|
|
256
|
+
*/
|
|
257
|
+
readonly target: MetricTarget;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Options for `Metric.object()`
|
|
261
|
+
*/
|
|
262
|
+
export interface MetricObjectOptions extends MetricOptions {
|
|
263
|
+
/**
|
|
264
|
+
* Resource where the metric can be found.
|
|
265
|
+
*/
|
|
266
|
+
readonly object: IResource;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* A metric condition that HorizontalPodAutoscaler's scale on.
|
|
270
|
+
*/
|
|
271
|
+
export declare class Metric {
|
|
272
|
+
private readonly metric;
|
|
273
|
+
/**
|
|
274
|
+
* Metric that tracks the CPU of a container. This metric
|
|
275
|
+
* will be tracked across all pods of the current scale target.
|
|
276
|
+
*
|
|
277
|
+
*/
|
|
278
|
+
static containerCpu(options: MetricContainerResourceOptions): Metric;
|
|
279
|
+
/**
|
|
280
|
+
* Metric that tracks the Memory of a container. This metric
|
|
281
|
+
* will be tracked across all pods of the current scale target.
|
|
282
|
+
*
|
|
283
|
+
*/
|
|
284
|
+
static containerMemory(options: MetricContainerResourceOptions): Metric;
|
|
285
|
+
/**
|
|
286
|
+
* Metric that tracks the volume size of a container. This metric
|
|
287
|
+
* will be tracked across all pods of the current scale target.
|
|
288
|
+
*
|
|
289
|
+
*/
|
|
290
|
+
static containerStorage(options: MetricContainerResourceOptions): Metric;
|
|
291
|
+
/**
|
|
292
|
+
* Metric that tracks the local ephemeral storage of a container. This metric
|
|
293
|
+
* will be tracked across all pods of the current scale target.
|
|
294
|
+
*
|
|
295
|
+
*/
|
|
296
|
+
static containerEphemeralStorage(options: MetricContainerResourceOptions): Metric;
|
|
297
|
+
/**
|
|
298
|
+
* A global metric that is not associated with any Kubernetes object.
|
|
299
|
+
* Allows for autoscaling based on information coming from components running outside of
|
|
300
|
+
* the cluster.
|
|
301
|
+
*
|
|
302
|
+
* Use case:
|
|
303
|
+
* * Scale up when the length of an SQS queue is greater than 10 messages.
|
|
304
|
+
* * Scale down when an outside load balancer's queries are less than 10000 per second.
|
|
305
|
+
*/
|
|
306
|
+
static external(options: MetricOptions): Metric;
|
|
307
|
+
/**
|
|
308
|
+
* Metric that describes a metric of a kubernetes object
|
|
309
|
+
*
|
|
310
|
+
* Use case:
|
|
311
|
+
* * Scale on a Kubernetes Ingress's hits-per-second metric.
|
|
312
|
+
*/
|
|
313
|
+
static object(options: MetricObjectOptions): Metric;
|
|
314
|
+
/**
|
|
315
|
+
* A pod metric that will be averaged across all pods of the current scale target.
|
|
316
|
+
*
|
|
317
|
+
* Use case:
|
|
318
|
+
* * Average CPU utilization across all pods
|
|
319
|
+
* * Transactions processed per second across all pods
|
|
320
|
+
*/
|
|
321
|
+
static pods(options: MetricOptions): Metric;
|
|
322
|
+
/**
|
|
323
|
+
* Tracks the available CPU of the pods in a target.
|
|
324
|
+
*
|
|
325
|
+
* Note: Since the resource usages of all the containers are summed up the total
|
|
326
|
+
* pod utilization may not accurately represent the individual container resource
|
|
327
|
+
* usage. This could lead to situations where a single container might be running
|
|
328
|
+
* with high usage and the HPA will not scale out because the overall pod usage
|
|
329
|
+
* is still within acceptable limits.
|
|
330
|
+
*
|
|
331
|
+
* Use case:
|
|
332
|
+
* * Scale up when CPU is above 40%.
|
|
333
|
+
*/
|
|
334
|
+
static resourceCpu(target: MetricTarget): Metric;
|
|
335
|
+
/**
|
|
336
|
+
* Tracks the available Memory of the pods in a target.
|
|
337
|
+
*
|
|
338
|
+
* Note: Since the resource usages of all the containers are summed up the total
|
|
339
|
+
* pod utilization may not accurately represent the individual container resource
|
|
340
|
+
* usage. This could lead to situations where a single container might be running
|
|
341
|
+
* with high usage and the HPA will not scale out because the overall pod usage
|
|
342
|
+
* is still within acceptable limits.
|
|
343
|
+
*
|
|
344
|
+
* Use case:
|
|
345
|
+
* * Scale up when Memory is above 512MB.
|
|
346
|
+
*/
|
|
347
|
+
static resourceMemory(target: MetricTarget): Metric;
|
|
348
|
+
/**
|
|
349
|
+
* Tracks the available Storage of the pods in a target.
|
|
350
|
+
*
|
|
351
|
+
* Note: Since the resource usages of all the containers are summed up the total
|
|
352
|
+
* pod utilization may not accurately represent the individual container resource
|
|
353
|
+
* usage. This could lead to situations where a single container might be running
|
|
354
|
+
* with high usage and the HPA will not scale out because the overall pod usage
|
|
355
|
+
* is still within acceptable limits.
|
|
356
|
+
*
|
|
357
|
+
*/
|
|
358
|
+
static resourceStorage(target: MetricTarget): Metric;
|
|
359
|
+
/**
|
|
360
|
+
* Tracks the available Ephemeral Storage of the pods in a target.
|
|
361
|
+
*
|
|
362
|
+
* Note: Since the resource usages of all the containers are summed up the total
|
|
363
|
+
* pod utilization may not accurately represent the individual container resource
|
|
364
|
+
* usage. This could lead to situations where a single container might be running
|
|
365
|
+
* with high usage and the HPA will not scale out because the overall pod usage
|
|
366
|
+
* is still within acceptable limits.
|
|
367
|
+
*
|
|
368
|
+
*/
|
|
369
|
+
static resourceEphemeralStorage(target: MetricTarget): Metric;
|
|
370
|
+
readonly type: string;
|
|
371
|
+
private constructor();
|
|
372
|
+
/**
|
|
373
|
+
* @internal
|
|
374
|
+
*/
|
|
375
|
+
_toKube(): k8s.MetricSpecV2;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* A metric condition that will trigger scaling behavior when satisfied.
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
*
|
|
382
|
+
* MetricTarget.averageUtilization(70); // 70% average utilization
|
|
383
|
+
*
|
|
384
|
+
*/
|
|
385
|
+
export declare class MetricTarget {
|
|
386
|
+
private readonly metric;
|
|
387
|
+
/**
|
|
388
|
+
* Target a specific target value.
|
|
389
|
+
*
|
|
390
|
+
* @param value The target value.
|
|
391
|
+
*/
|
|
392
|
+
static value(value: number): MetricTarget;
|
|
393
|
+
/**
|
|
394
|
+
* Target the average value across all relevant pods.
|
|
395
|
+
*
|
|
396
|
+
* @param averageValue The average metric value.
|
|
397
|
+
*/
|
|
398
|
+
static averageValue(averageValue: number): MetricTarget;
|
|
399
|
+
/**
|
|
400
|
+
* Target a percentage value across all relevant pods.
|
|
401
|
+
*
|
|
402
|
+
* @param averageUtilization The percentage of the utilization metric. e.g. `50` for 50%.
|
|
403
|
+
*/
|
|
404
|
+
static averageUtilization(averageUtilization: number): MetricTarget;
|
|
405
|
+
private constructor();
|
|
406
|
+
/**
|
|
407
|
+
* @internal
|
|
408
|
+
*/
|
|
409
|
+
_toKube(): k8s.MetricSpecV2;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Defines the scaling behavior for one direction.
|
|
413
|
+
*/
|
|
414
|
+
export interface ScalingRules {
|
|
415
|
+
/**
|
|
416
|
+
* Defines the window of past metrics that the autoscaler should consider when calculating
|
|
417
|
+
* wether or not autoscaling should occur.
|
|
418
|
+
*
|
|
419
|
+
* Minimum duration is 1 second, max is 1 hour.
|
|
420
|
+
*
|
|
421
|
+
* @example
|
|
422
|
+
* stabilizationWindow: Duration.minutes(30)
|
|
423
|
+
* // Autoscaler considers the last 30 minutes of metrics when deciding whether to scale.
|
|
424
|
+
*
|
|
425
|
+
* @default * On scale down no stabilization is performed.
|
|
426
|
+
* * On scale up stabilization is performed for 5 minutes.
|
|
427
|
+
*/
|
|
428
|
+
readonly stabilizationWindow?: Duration;
|
|
429
|
+
/**
|
|
430
|
+
* The strategy to use when scaling.
|
|
431
|
+
*
|
|
432
|
+
* @default MAX_CHANGE
|
|
433
|
+
*/
|
|
434
|
+
readonly strategy?: ScalingStrategy;
|
|
435
|
+
/**
|
|
436
|
+
* The scaling policies.
|
|
437
|
+
*
|
|
438
|
+
* @default * Scale up
|
|
439
|
+
* * Increase no more than 4 pods per 60 seconds
|
|
440
|
+
* * Double the number of pods per 60 seconds
|
|
441
|
+
* * Scale down
|
|
442
|
+
* * Decrease to minReplica count
|
|
443
|
+
*/
|
|
444
|
+
readonly policies?: ScalingPolicy[];
|
|
445
|
+
}
|
|
446
|
+
export declare enum ScalingStrategy {
|
|
447
|
+
/**
|
|
448
|
+
* Use the policy that provisions the most changes.
|
|
449
|
+
*/
|
|
450
|
+
MAX_CHANGE = "Max",
|
|
451
|
+
/**
|
|
452
|
+
* Use the policy that provisions the least amount of changes.
|
|
453
|
+
*/
|
|
454
|
+
MIN_CHANGE = "Min",
|
|
455
|
+
/**
|
|
456
|
+
* Disables scaling in this direction.
|
|
457
|
+
*
|
|
458
|
+
* @deprecated - Omit the ScalingRule instead
|
|
459
|
+
*/
|
|
460
|
+
DISABLED = "Disabled"
|
|
461
|
+
}
|
|
462
|
+
export interface ScalingPolicy {
|
|
463
|
+
/**
|
|
464
|
+
* The type and quantity of replicas to change.
|
|
465
|
+
*/
|
|
466
|
+
readonly replicas: Replicas;
|
|
467
|
+
/**
|
|
468
|
+
* The amount of time the scaling policy has to
|
|
469
|
+
* continue scaling before the target metric must be
|
|
470
|
+
* revalidated.
|
|
471
|
+
*
|
|
472
|
+
* Must be greater than 0 seconds and no longer than 30 minutes.
|
|
473
|
+
*
|
|
474
|
+
* @default - 15 seconds
|
|
475
|
+
*/
|
|
476
|
+
readonly duration?: Duration;
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* The amount of replicas that will change.
|
|
480
|
+
*/
|
|
481
|
+
export declare class Replicas {
|
|
482
|
+
private readonly replicas;
|
|
483
|
+
/**
|
|
484
|
+
* Changes the pods by a percentage of the it's current value.
|
|
485
|
+
*
|
|
486
|
+
* @param value The percentage of change to apply. Must be greater than 0.
|
|
487
|
+
*/
|
|
488
|
+
static percent(value: number): Replicas;
|
|
489
|
+
/**
|
|
490
|
+
* Changes the pods by a percentage of the it's current value.
|
|
491
|
+
*
|
|
492
|
+
* @param value The amount of change to apply. Must be greater than 0.
|
|
493
|
+
*/
|
|
494
|
+
static absolute(value: number): Replicas;
|
|
495
|
+
private constructor();
|
|
496
|
+
/**
|
|
497
|
+
* @internal
|
|
498
|
+
*/
|
|
499
|
+
_toKube(): Pick<k8s.HpaScalingPolicyV2, 'type' | 'value'>;
|
|
500
|
+
}
|