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.
Files changed (114) hide show
  1. package/.backportrc.json +17 -0
  2. package/.jsii +90235 -0
  3. package/CODE_OF_CONDUCT.md +3 -0
  4. package/CONTRIBUTING.md +185 -0
  5. package/DCO +34 -0
  6. package/LICENSE +202 -0
  7. package/NOTICE +1 -0
  8. package/OWNERS.md +5 -0
  9. package/README.md +32 -0
  10. package/SECURITY.md +5 -0
  11. package/cdk8s.yaml +8 -0
  12. package/docs/java.md +23855 -0
  13. package/docs/plus/config-map.md +98 -0
  14. package/docs/plus/container.md +133 -0
  15. package/docs/plus/cronjob.md +67 -0
  16. package/docs/plus/deployment.md +232 -0
  17. package/docs/plus/horizontal-pod-autoscaler.md +226 -0
  18. package/docs/plus/ingress.md +68 -0
  19. package/docs/plus/job.md +48 -0
  20. package/docs/plus/namespace.md +58 -0
  21. package/docs/plus/network-policy.md +341 -0
  22. package/docs/plus/pod.md +455 -0
  23. package/docs/plus/pv.md +82 -0
  24. package/docs/plus/pvc.md +77 -0
  25. package/docs/plus/rbac.md +104 -0
  26. package/docs/plus/secret.md +32 -0
  27. package/docs/plus/service-account.md +35 -0
  28. package/docs/plus/service.md +41 -0
  29. package/docs/plus/volume.md +38 -0
  30. package/docs/python.md +26079 -0
  31. package/docs/typescript.md +19565 -0
  32. package/git-hooks/README.md +9 -0
  33. package/git-hooks/prepare-commit-msg +18 -0
  34. package/git-hooks/setup.sh +10 -0
  35. package/lib/_action.d.ts +21 -0
  36. package/lib/_action.js +32 -0
  37. package/lib/api-resource.d.ts +298 -0
  38. package/lib/api-resource.js +430 -0
  39. package/lib/base.d.ts +79 -0
  40. package/lib/base.js +92 -0
  41. package/lib/config-map.d.ts +126 -0
  42. package/lib/config-map.js +159 -0
  43. package/lib/container.d.ts +1057 -0
  44. package/lib/container.js +845 -0
  45. package/lib/cron-job.d.ts +138 -0
  46. package/lib/cron-job.js +103 -0
  47. package/lib/daemon-set.d.ts +45 -0
  48. package/lib/daemon-set.js +55 -0
  49. package/lib/deployment.d.ts +223 -0
  50. package/lib/deployment.js +214 -0
  51. package/lib/handler.d.ts +62 -0
  52. package/lib/handler.js +54 -0
  53. package/lib/horizontal-pod-autoscaler.d.ts +500 -0
  54. package/lib/horizontal-pod-autoscaler.js +569 -0
  55. package/lib/imports/k8s.d.ts +21534 -0
  56. package/lib/imports/k8s.js +16496 -0
  57. package/lib/index.d.ts +26 -0
  58. package/lib/index.js +39 -0
  59. package/lib/ingress.d.ts +230 -0
  60. package/lib/ingress.js +246 -0
  61. package/lib/job.d.ts +64 -0
  62. package/lib/job.js +54 -0
  63. package/lib/namespace.d.ts +128 -0
  64. package/lib/namespace.js +109 -0
  65. package/lib/network-policy.d.ts +311 -0
  66. package/lib/network-policy.js +344 -0
  67. package/lib/pod.d.ts +1080 -0
  68. package/lib/pod.js +1139 -0
  69. package/lib/probe.d.ts +141 -0
  70. package/lib/probe.js +77 -0
  71. package/lib/pv.d.ts +375 -0
  72. package/lib/pv.js +273 -0
  73. package/lib/pvc.d.ts +163 -0
  74. package/lib/pvc.js +152 -0
  75. package/lib/role-binding.d.ts +138 -0
  76. package/lib/role-binding.js +165 -0
  77. package/lib/role.d.ts +268 -0
  78. package/lib/role.js +401 -0
  79. package/lib/secret.d.ts +195 -0
  80. package/lib/secret.js +185 -0
  81. package/lib/service-account.d.ts +83 -0
  82. package/lib/service-account.js +105 -0
  83. package/lib/service.d.ts +289 -0
  84. package/lib/service.js +182 -0
  85. package/lib/stateful-set.d.ts +169 -0
  86. package/lib/stateful-set.js +174 -0
  87. package/lib/utils.d.ts +4 -0
  88. package/lib/utils.js +34 -0
  89. package/lib/volume.d.ts +573 -0
  90. package/lib/volume.js +371 -0
  91. package/lib/workload.d.ts +121 -0
  92. package/lib/workload.js +122 -0
  93. package/node_modules/balanced-match/.github/FUNDING.yml +2 -0
  94. package/node_modules/balanced-match/LICENSE.md +21 -0
  95. package/node_modules/balanced-match/README.md +97 -0
  96. package/node_modules/balanced-match/index.js +62 -0
  97. package/node_modules/balanced-match/package.json +48 -0
  98. package/node_modules/concat-map/.travis.yml +4 -0
  99. package/node_modules/concat-map/LICENSE +18 -0
  100. package/node_modules/concat-map/README.markdown +62 -0
  101. package/node_modules/concat-map/example/map.js +6 -0
  102. package/node_modules/concat-map/index.js +13 -0
  103. package/node_modules/concat-map/package.json +43 -0
  104. package/node_modules/concat-map/test/map.js +39 -0
  105. package/node_modules/minimatch/LICENSE +15 -0
  106. package/node_modules/minimatch/README.md +230 -0
  107. package/node_modules/minimatch/minimatch.js +947 -0
  108. package/node_modules/minimatch/node_modules/brace-expansion/LICENSE +21 -0
  109. package/node_modules/minimatch/node_modules/brace-expansion/README.md +129 -0
  110. package/node_modules/minimatch/node_modules/brace-expansion/index.js +201 -0
  111. package/node_modules/minimatch/node_modules/brace-expansion/package.json +47 -0
  112. package/node_modules/minimatch/package.json +33 -0
  113. package/package.json +186 -0
  114. package/rotate.md +84 -0
package/lib/pod.d.ts ADDED
@@ -0,0 +1,1080 @@
1
+ import { ApiObject, ApiObjectMetadataDefinition, Duration } from 'cdk8s';
2
+ import { Construct, IConstruct } from 'constructs';
3
+ import * as base from './base';
4
+ import * as container from './container';
5
+ import * as k8s from './imports/k8s';
6
+ import * as namespace from './namespace';
7
+ import * as networkpolicy from './network-policy';
8
+ import * as rb from './role-binding';
9
+ import * as secret from './secret';
10
+ import * as serviceaccount from './service-account';
11
+ import * as volume from './volume';
12
+ export declare abstract class AbstractPod extends base.Resource implements IPodSelector, networkpolicy.INetworkPolicyPeer, rb.ISubject {
13
+ readonly restartPolicy?: RestartPolicy;
14
+ readonly serviceAccount?: serviceaccount.IServiceAccount;
15
+ readonly securityContext: PodSecurityContext;
16
+ readonly dns: PodDns;
17
+ readonly dockerRegistryAuth?: secret.ISecret;
18
+ readonly automountServiceAccountToken: boolean;
19
+ readonly hostNetwork?: boolean;
20
+ readonly terminationGracePeriod?: Duration;
21
+ protected readonly isolate: boolean;
22
+ private readonly _containers;
23
+ private readonly _initContainers;
24
+ private readonly _hostAliases;
25
+ private readonly _volumes;
26
+ abstract readonly podMetadata: ApiObjectMetadataDefinition;
27
+ constructor(scope: Construct, id: string, props?: AbstractPodProps);
28
+ get containers(): container.Container[];
29
+ get initContainers(): container.Container[];
30
+ get volumes(): volume.Volume[];
31
+ get hostAliases(): HostAlias[];
32
+ /**
33
+ * @see IPodSelector.toPodSelectorConfig()
34
+ */
35
+ toPodSelectorConfig(): PodSelectorConfig;
36
+ /**
37
+ * @see INetworkPolicyPeer.toNetworkPolicyPeerConfig()
38
+ */
39
+ toNetworkPolicyPeerConfig(): networkpolicy.NetworkPolicyPeerConfig;
40
+ /**
41
+ * @see INetworkPolicyPeer.toPodSelector()
42
+ */
43
+ toPodSelector(): IPodSelector | undefined;
44
+ addContainer(cont: container.ContainerProps): container.Container;
45
+ attachContainer(cont: container.Container): void;
46
+ addInitContainer(cont: container.ContainerProps): container.Container;
47
+ private isSidecarContainer;
48
+ addHostAlias(hostAlias: HostAlias): void;
49
+ addVolume(vol: volume.Volume): void;
50
+ /**
51
+ * @see ISubect.toSubjectConfiguration()
52
+ */
53
+ toSubjectConfiguration(): rb.SubjectConfiguration;
54
+ /**
55
+ * @internal
56
+ */
57
+ _toPodSpec(): k8s.PodSpec;
58
+ }
59
+ /**
60
+ * Sysctl defines a kernel parameter to be set
61
+ */
62
+ export interface Sysctl {
63
+ /**
64
+ * Name of a property to set
65
+ */
66
+ readonly name: string;
67
+ /**
68
+ * Value of a property to set
69
+ */
70
+ readonly value: string;
71
+ }
72
+ /**
73
+ * Properties for `PodSecurityContext`
74
+ */
75
+ export interface PodSecurityContextProps {
76
+ /**
77
+ * Modify the ownership and permissions of pod volumes to this GID.
78
+ *
79
+ * @default - Volume ownership is not changed.
80
+ */
81
+ readonly fsGroup?: number;
82
+ /**
83
+ * Defines behavior of changing ownership and permission of the volume before being exposed inside Pod.
84
+ * This field will only apply to volume types which support fsGroup based ownership(and permissions).
85
+ * It will have no effect on ephemeral volume types such as: secret, configmaps and emptydir.
86
+ *
87
+ * @default FsGroupChangePolicy.ALWAYS
88
+ */
89
+ readonly fsGroupChangePolicy?: FsGroupChangePolicy;
90
+ /**
91
+ * The UID to run the entrypoint of the container process.
92
+ *
93
+ * @default - User specified in image metadata
94
+ */
95
+ readonly user?: number;
96
+ /**
97
+ * The GID to run the entrypoint of the container process.
98
+ *
99
+ * @default - Group configured by container runtime
100
+ */
101
+ readonly group?: number;
102
+ /**
103
+ * Indicates that the container must run as a non-root user.
104
+ * If true, the Kubelet will validate the image at runtime to ensure that it does
105
+ * not run as UID 0 (root) and fail to start the container if it does.
106
+ *
107
+ * @default true
108
+ */
109
+ readonly ensureNonRoot?: boolean;
110
+ /**
111
+ * Sysctls hold a list of namespaced sysctls used for the pod.
112
+ * Pods with unsupported sysctls (by the container runtime) might fail to launch.
113
+ *
114
+ * @default - No sysctls
115
+ */
116
+ readonly sysctls?: Sysctl[];
117
+ }
118
+ /**
119
+ * Properties for `AbstractPod`.
120
+ */
121
+ export interface AbstractPodProps extends base.ResourceProps {
122
+ /**
123
+ * List of containers belonging to the pod. Containers cannot currently be
124
+ * added or removed. There must be at least one container in a Pod.
125
+ *
126
+ * You can add additionnal containers using `podSpec.addContainer()`
127
+ *
128
+ * @default - No containers. Note that a pod spec must include at least one container.
129
+ */
130
+ readonly containers?: container.ContainerProps[];
131
+ /**
132
+ * List of initialization containers belonging to the pod.
133
+ * Init containers are executed in order prior to containers being started.
134
+ * If any init container fails, the pod is considered to have failed and is handled according to its restartPolicy.
135
+ * The name for an init container or normal container must be unique among all containers.
136
+ * Init containers may not have Lifecycle actions, Readiness probes, Liveness probes, or Startup probes.
137
+ * The resourceRequirements of an init container are taken into account during scheduling by finding the highest request/limit
138
+ * for each resource type, and then using the max of of that value or the sum of the normal containers.
139
+ * Limits are applied to init containers in a similar fashion.
140
+ *
141
+ * Init containers cannot currently be added ,removed or updated.
142
+ *
143
+ * @see https://kubernetes.io/docs/concepts/workloads/pods/init-containers/
144
+ * @default - No init containers.
145
+ */
146
+ readonly initContainers?: container.ContainerProps[];
147
+ /**
148
+ * List of volumes that can be mounted by containers belonging to the pod.
149
+ *
150
+ * You can also add volumes later using `podSpec.addVolume()`
151
+ *
152
+ * @see https://kubernetes.io/docs/concepts/storage/volumes
153
+ *
154
+ * @default - No volumes.
155
+ */
156
+ readonly volumes?: volume.Volume[];
157
+ /**
158
+ * Restart policy for all containers within the pod.
159
+ *
160
+ * @see https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy
161
+ *
162
+ * @default RestartPolicy.ALWAYS
163
+ */
164
+ readonly restartPolicy?: RestartPolicy;
165
+ /**
166
+ * A service account provides an identity for processes that run in a Pod.
167
+ *
168
+ * When you (a human) access the cluster (for example, using kubectl), you are
169
+ * authenticated by the apiserver as a particular User Account (currently this
170
+ * is usually admin, unless your cluster administrator has customized your
171
+ * cluster). Processes in containers inside pods can also contact the
172
+ * apiserver. When they do, they are authenticated as a particular Service
173
+ * Account (for example, default).
174
+ *
175
+ * @see https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
176
+ *
177
+ * @default - No service account.
178
+ */
179
+ readonly serviceAccount?: serviceaccount.IServiceAccount;
180
+ /**
181
+ * SecurityContext holds pod-level security attributes and common container settings.
182
+ *
183
+ * @default
184
+ *
185
+ * fsGroupChangePolicy: FsGroupChangePolicy.FsGroupChangePolicy.ALWAYS
186
+ * ensureNonRoot: true
187
+ */
188
+ readonly securityContext?: PodSecurityContextProps;
189
+ /**
190
+ * HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the pod's hosts file.
191
+ *
192
+ * @schema io.k8s.api.core.v1.HostAlias
193
+ */
194
+ readonly hostAliases?: HostAlias[];
195
+ /**
196
+ * DNS settings for the pod.
197
+ *
198
+ * @see https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/
199
+ *
200
+ * @default
201
+ *
202
+ * policy: DnsPolicy.CLUSTER_FIRST
203
+ * hostnameAsFQDN: false
204
+ */
205
+ readonly dns?: PodDnsProps;
206
+ /**
207
+ * A secret containing docker credentials for authenticating to a registry.
208
+ *
209
+ * @default - No auth. Images are assumed to be publicly available.
210
+ */
211
+ readonly dockerRegistryAuth?: secret.ISecret;
212
+ /**
213
+ * Indicates whether a service account token should be automatically mounted.
214
+ *
215
+ * @default false
216
+ * @see https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#use-the-default-service-account-to-access-the-api-server
217
+ */
218
+ readonly automountServiceAccountToken?: boolean;
219
+ /**
220
+ * Isolates the pod. This will prevent any ingress or egress connections to / from this pod.
221
+ * You can however allow explicit connections post instantiation by using the `.connections` property.
222
+ *
223
+ * @default false
224
+ */
225
+ readonly isolate?: boolean;
226
+ /**
227
+ * Host network for the pod.
228
+ *
229
+ * @default false
230
+ */
231
+ readonly hostNetwork?: boolean;
232
+ /**
233
+ * Grace period until the pod is terminated
234
+ *
235
+ * @default Duration.seconds(30)
236
+ */
237
+ readonly terminationGracePeriod?: Duration;
238
+ }
239
+ /**
240
+ * Properties for `Pod`.
241
+ */
242
+ export interface PodProps extends AbstractPodProps {
243
+ }
244
+ /**
245
+ * Options for `LabelSelector.of`.
246
+ */
247
+ export interface LabelSelectorOptions {
248
+ /**
249
+ * Strict label matchers.
250
+ */
251
+ readonly labels?: {
252
+ [key: string]: string;
253
+ };
254
+ /**
255
+ * Expression based label matchers.
256
+ */
257
+ readonly expressions?: LabelExpression[];
258
+ }
259
+ /**
260
+ * Match a resource by labels.
261
+ */
262
+ export declare class LabelSelector {
263
+ private readonly expressions;
264
+ private readonly labels;
265
+ static of(options?: LabelSelectorOptions): LabelSelector;
266
+ private constructor();
267
+ isEmpty(): boolean;
268
+ /**
269
+ * @internal
270
+ */
271
+ _toKube(): k8s.LabelSelector;
272
+ }
273
+ /**
274
+ * Configuration for selecting pods, optionally in particular namespaces.
275
+ */
276
+ export interface PodSelectorConfig {
277
+ /**
278
+ * A selector to select pods by labels.
279
+ */
280
+ readonly labelSelector: LabelSelector;
281
+ /**
282
+ * Configuration for selecting which namepsaces are the pods allowed to be in.
283
+ */
284
+ readonly namespaces?: namespace.NamespaceSelectorConfig;
285
+ }
286
+ /**
287
+ * Represents an object that can select pods.
288
+ */
289
+ export interface IPodSelector extends IConstruct {
290
+ /**
291
+ * Return the configuration of this selector.
292
+ */
293
+ toPodSelectorConfig(): PodSelectorConfig;
294
+ }
295
+ /**
296
+ * Pod is a collection of containers that can run on a host. This resource is
297
+ * created by clients and scheduled onto hosts.
298
+ */
299
+ export declare class Pod extends AbstractPod {
300
+ /**
301
+ * This label is autoamtically added by cdk8s to any pod. It provides
302
+ * a unique and stable identifier for the pod.
303
+ */
304
+ static readonly ADDRESS_LABEL = "cdk8s.io/metadata.addr";
305
+ /**
306
+ * @see base.Resource.apiObject
307
+ */
308
+ protected readonly apiObject: ApiObject;
309
+ readonly resourceType = "pods";
310
+ readonly scheduling: PodScheduling;
311
+ readonly connections: PodConnections;
312
+ constructor(scope: Construct, id: string, props?: PodProps);
313
+ get podMetadata(): ApiObjectMetadataDefinition;
314
+ /**
315
+ * @internal
316
+ */
317
+ _toKube(): k8s.PodSpec;
318
+ }
319
+ /**
320
+ * Properties for `PodDns`.
321
+ */
322
+ export interface PodDnsProps {
323
+ /**
324
+ * Specifies the hostname of the Pod.
325
+ *
326
+ * @default - Set to a system-defined value.
327
+ */
328
+ readonly hostname?: string;
329
+ /**
330
+ * If specified, the fully qualified Pod hostname will be "<hostname>.<subdomain>.<pod namespace>.svc.<cluster domain>".
331
+ *
332
+ * @default - No subdomain.
333
+ */
334
+ readonly subdomain?: string;
335
+ /**
336
+ * If true the pod's hostname will be configured as the pod's FQDN, rather than the leaf name (the default).
337
+ * In Linux containers, this means setting the FQDN in the hostname field of the kernel (the nodename field of struct utsname).
338
+ * In Windows containers, this means setting the registry value of hostname for the registry
339
+ * key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters to FQDN.
340
+ * If a pod does not have FQDN, this has no effect.
341
+ *
342
+ * @default false
343
+ */
344
+ readonly hostnameAsFQDN?: boolean;
345
+ /**
346
+ * Set DNS policy for the pod.
347
+ *
348
+ * If policy is set to `None`, other configuration must be supplied.
349
+ *
350
+ * @default DnsPolicy.CLUSTER_FIRST
351
+ */
352
+ readonly policy?: DnsPolicy;
353
+ /**
354
+ * A list of IP addresses that will be used as DNS servers for the Pod. There can be at most 3 IP addresses specified.
355
+ * When the policy is set to "NONE", the list must contain at least one IP address,
356
+ * otherwise this property is optional.
357
+ * The servers listed will be combined to the base nameservers generated from
358
+ * the specified DNS policy with duplicate addresses removed.
359
+ */
360
+ readonly nameservers?: string[];
361
+ /**
362
+ * A list of DNS search domains for hostname lookup in the Pod.
363
+ * When specified, the provided list will be merged into the base
364
+ * search domain names generated from the chosen DNS policy.
365
+ * Duplicate domain names are removed.
366
+ *
367
+ * Kubernetes allows for at most 6 search domains.
368
+ */
369
+ readonly searches?: string[];
370
+ /**
371
+ * List of objects where each object may have a name property (required)
372
+ * and a value property (optional). The contents in this property
373
+ * will be merged to the options generated from the specified DNS policy.
374
+ * Duplicate entries are removed.
375
+ */
376
+ readonly options?: DnsOption[];
377
+ }
378
+ /**
379
+ * Holds dns settings of the pod.
380
+ */
381
+ export declare class PodDns {
382
+ /**
383
+ * The DNS policy of this pod.
384
+ */
385
+ readonly policy: DnsPolicy;
386
+ /**
387
+ * The configured hostname of the pod. Undefined means its set to a system-defined value.
388
+ */
389
+ readonly hostname?: string;
390
+ /**
391
+ * The configured subdomain of the pod.
392
+ */
393
+ readonly subdomain?: string;
394
+ /**
395
+ * Whether or not the pods hostname is set to its FQDN.
396
+ */
397
+ readonly hostnameAsFQDN: boolean;
398
+ private readonly _nameservers;
399
+ private readonly _searches;
400
+ private readonly _options;
401
+ constructor(props?: PodDnsProps);
402
+ /**
403
+ * Nameservers defined for this pod.
404
+ */
405
+ get nameservers(): string[];
406
+ /**
407
+ * Search domains defined for this pod.
408
+ */
409
+ get searches(): string[];
410
+ /**
411
+ * Custom dns options defined for this pod.
412
+ */
413
+ get options(): DnsOption[];
414
+ /**
415
+ * Add a nameserver.
416
+ */
417
+ addNameserver(...nameservers: string[]): void;
418
+ /**
419
+ * Add a search domain.
420
+ */
421
+ addSearch(...searches: string[]): void;
422
+ /**
423
+ * Add a custom option.
424
+ */
425
+ addOption(...options: DnsOption[]): void;
426
+ /**
427
+ * @internal
428
+ */
429
+ _toKube(): {
430
+ hostname?: string;
431
+ subdomain?: string;
432
+ hostnameAsFQDN: boolean;
433
+ policy: string;
434
+ config: k8s.PodDnsConfig;
435
+ };
436
+ }
437
+ /**
438
+ * Holds pod-level security attributes and common container settings.
439
+ */
440
+ export declare class PodSecurityContext {
441
+ readonly ensureNonRoot: boolean;
442
+ readonly user?: number;
443
+ readonly group?: number;
444
+ readonly fsGroup?: number;
445
+ readonly fsGroupChangePolicy: FsGroupChangePolicy;
446
+ private readonly _sysctls;
447
+ constructor(props?: PodSecurityContextProps);
448
+ get sysctls(): Sysctl[];
449
+ /**
450
+ * @internal
451
+ */
452
+ _toKube(): k8s.PodSecurityContext;
453
+ }
454
+ /**
455
+ * Restart policy for all containers within the pod.
456
+ */
457
+ export declare enum RestartPolicy {
458
+ /**
459
+ * Always restart the pod after it exits.
460
+ */
461
+ ALWAYS = "Always",
462
+ /**
463
+ * Only restart if the pod exits with a non-zero exit code.
464
+ */
465
+ ON_FAILURE = "OnFailure",
466
+ /**
467
+ * Never restart the pod.
468
+ */
469
+ NEVER = "Never"
470
+ }
471
+ export declare enum FsGroupChangePolicy {
472
+ /**
473
+ * Only change permissions and ownership if permission and ownership of root directory does
474
+ * not match with expected permissions of the volume.
475
+ * This could help shorten the time it takes to change ownership and permission of a volume
476
+ */
477
+ ON_ROOT_MISMATCH = "OnRootMismatch",
478
+ /**
479
+ * Always change permission and ownership of the volume when volume is mounted.
480
+ */
481
+ ALWAYS = "Always"
482
+ }
483
+ /**
484
+ * Custom DNS option.
485
+ */
486
+ export interface DnsOption {
487
+ /**
488
+ * Option name.
489
+ */
490
+ readonly name: string;
491
+ /**
492
+ * Option value.
493
+ *
494
+ * @default - No value.
495
+ */
496
+ readonly value?: string;
497
+ }
498
+ /**
499
+ * Pod DNS policies.
500
+ */
501
+ export declare enum DnsPolicy {
502
+ /**
503
+ * Any DNS query that does not match the configured cluster domain suffix,
504
+ * such as "www.kubernetes.io", is forwarded to the
505
+ * upstream nameserver inherited from the node.
506
+ * Cluster administrators may have extra stub-domain and upstream DNS servers configured.
507
+ */
508
+ CLUSTER_FIRST = "ClusterFirst",
509
+ /**
510
+ * For Pods running with hostNetwork, you should
511
+ * explicitly set its DNS policy "ClusterFirstWithHostNet".
512
+ */
513
+ CLUSTER_FIRST_WITH_HOST_NET = "ClusterFirstWithHostNet",
514
+ /**
515
+ * The Pod inherits the name resolution configuration
516
+ * from the node that the pods run on.
517
+ */
518
+ DEFAULT = "Default",
519
+ /**
520
+ * It allows a Pod to ignore DNS settings from the Kubernetes environment.
521
+ * All DNS settings are supposed to be provided using the dnsConfig
522
+ * field in the Pod Spec.
523
+ */
524
+ NONE = "None"
525
+ }
526
+ /**
527
+ * HostAlias holds the mapping between IP and hostnames that will be injected as
528
+ * an entry in the pod's /etc/hosts file.
529
+ */
530
+ export interface HostAlias {
531
+ /**
532
+ * Hostnames for the chosen IP address.
533
+ */
534
+ readonly hostnames: string[];
535
+ /**
536
+ * IP address of the host file entry.
537
+ */
538
+ readonly ip: string;
539
+ }
540
+ /**
541
+ * Represents a query that can be performed against nodes with labels.
542
+ */
543
+ export declare class NodeLabelQuery {
544
+ private readonly key;
545
+ private readonly operator;
546
+ private readonly values?;
547
+ /**
548
+ * Requires value of label `key` to equal `value`.
549
+ */
550
+ static is(key: string, value: string): NodeLabelQuery;
551
+ /**
552
+ * Requires value of label `key` to be one of `values`.
553
+ */
554
+ static in(key: string, values: string[]): NodeLabelQuery;
555
+ /**
556
+ * Requires value of label `key` to be none of `values`.
557
+ */
558
+ static notIn(key: string, values: string[]): NodeLabelQuery;
559
+ /**
560
+ * Requires label `key` to exist.
561
+ */
562
+ static exists(key: string): NodeLabelQuery;
563
+ /**
564
+ * Requires label `key` to not exist.
565
+ */
566
+ static doesNotExist(key: string): NodeLabelQuery;
567
+ /**
568
+ * Requires value of label `key` to greater than all elements in `values`.
569
+ */
570
+ static gt(key: string, values: string[]): NodeLabelQuery;
571
+ /**
572
+ * Requires value of label `key` to less than all elements in `values`.
573
+ */
574
+ static lt(key: string, values: string[]): NodeLabelQuery;
575
+ private constructor();
576
+ /**
577
+ * @internal
578
+ */
579
+ _toKube(): k8s.NodeSelectorRequirement;
580
+ }
581
+ /**
582
+ * Represents a query that can be performed against resources with labels.
583
+ */
584
+ export declare class LabelExpression {
585
+ readonly key: string;
586
+ readonly operator: string;
587
+ readonly values?: string[] | undefined;
588
+ /**
589
+ * Requires value of label `key` to be one of `values`.
590
+ */
591
+ static in(key: string, values: string[]): LabelExpression;
592
+ /**
593
+ * Requires value of label `key` to be none of `values`.
594
+ */
595
+ static notIn(key: string, values: string[]): LabelExpression;
596
+ /**
597
+ * Requires label `key` to exist.
598
+ */
599
+ static exists(key: string): LabelExpression;
600
+ /**
601
+ * Requires label `key` to not exist.
602
+ */
603
+ static doesNotExist(key: string): LabelExpression;
604
+ private constructor();
605
+ }
606
+ /**
607
+ * Taint effects.
608
+ */
609
+ export declare enum TaintEffect {
610
+ /**
611
+ * This means that no pod will be able to schedule
612
+ * onto the node unless it has a matching toleration.
613
+ */
614
+ NO_SCHEDULE = "NoSchedule",
615
+ /**
616
+ * This is a "preference" or "soft" version of `NO_SCHEDULE` -- the system
617
+ * will try to avoid placing a pod that does not tolerate the taint on the node,
618
+ * but it is not required
619
+ */
620
+ PREFER_NO_SCHEDULE = "PreferNoSchedule",
621
+ /**
622
+ * This affects pods that are already running on the node as follows:
623
+ *
624
+ * - Pods that do not tolerate the taint are evicted immediately.
625
+ * - Pods that tolerate the taint without specifying `duration` remain bound forever.
626
+ * - Pods that tolerate the taint with a specified `duration` remain bound for
627
+ * the specified amount of time.
628
+ */
629
+ NO_EXECUTE = "NoExecute"
630
+ }
631
+ /**
632
+ * Options for `NodeTaintQuery`.
633
+ */
634
+ export interface NodeTaintQueryOptions {
635
+ /**
636
+ * The taint effect to match.
637
+ *
638
+ * @default - all effects are matched.
639
+ */
640
+ readonly effect?: TaintEffect;
641
+ /**
642
+ * How much time should a pod that tolerates the `NO_EXECUTE` effect
643
+ * be bound to the node. Only applies for the `NO_EXECUTE` effect.
644
+ *
645
+ * @default - bound forever.
646
+ */
647
+ readonly evictAfter?: Duration;
648
+ }
649
+ /**
650
+ * Taint queries that can be perfomed against nodes.
651
+ */
652
+ export declare class NodeTaintQuery {
653
+ private readonly operator;
654
+ private readonly key?;
655
+ private readonly value?;
656
+ private readonly effect?;
657
+ private readonly evictAfter?;
658
+ /**
659
+ * Matches a taint with a specific key and value.
660
+ */
661
+ static is(key: string, value: string, options?: NodeTaintQueryOptions): NodeTaintQuery;
662
+ /**
663
+ * Matches a tain with any value of a specific key.
664
+ */
665
+ static exists(key: string, options?: NodeTaintQueryOptions): NodeTaintQuery;
666
+ /**
667
+ * Matches any taint.
668
+ */
669
+ static any(): NodeTaintQuery;
670
+ private constructor();
671
+ /**
672
+ * @internal
673
+ */
674
+ _toKube(): k8s.Toleration;
675
+ }
676
+ /**
677
+ * Options for `Pods.all`.
678
+ */
679
+ export interface PodsAllOptions {
680
+ /**
681
+ * Namespaces the pods are allowed to be in.
682
+ * Use `Namespaces.all()` to allow all namespaces.
683
+ *
684
+ * @default - unset, implies the namespace of the resource this selection is used in.
685
+ */
686
+ readonly namespaces?: namespace.Namespaces;
687
+ }
688
+ /**
689
+ * Options for `Pods.select`.
690
+ */
691
+ export interface PodsSelectOptions {
692
+ /**
693
+ * Labels the pods must have.
694
+ *
695
+ * @default - no strict labels requirements.
696
+ */
697
+ readonly labels?: {
698
+ [key: string]: string;
699
+ };
700
+ /**
701
+ * Expressions the pods must satisify.
702
+ *
703
+ * @default - no expressions requirements.
704
+ */
705
+ readonly expressions?: LabelExpression[];
706
+ /**
707
+ * Namespaces the pods are allowed to be in.
708
+ * Use `Namespaces.all()` to allow all namespaces.
709
+ *
710
+ * @default - unset, implies the namespace of the resource this selection is used in.
711
+ */
712
+ readonly namespaces?: namespace.Namespaces;
713
+ }
714
+ /**
715
+ * Represents a group of pods.
716
+ */
717
+ export declare class Pods extends Construct implements IPodSelector {
718
+ private readonly expressions?;
719
+ private readonly labels?;
720
+ private readonly namespaces?;
721
+ /**
722
+ * Select pods in the cluster with various selectors.
723
+ */
724
+ static select(scope: Construct, id: string, options: PodsSelectOptions): Pods;
725
+ /**
726
+ * Select all pods.
727
+ */
728
+ static all(scope: Construct, id: string, options?: PodsAllOptions): Pods;
729
+ constructor(scope: Construct, id: string, expressions?: LabelExpression[] | undefined, labels?: {
730
+ [key: string]: string;
731
+ } | undefined, namespaces?: namespace.INamespaceSelector | undefined);
732
+ /**
733
+ * @see IPodSelector.toPodSelectorConfig()
734
+ */
735
+ toPodSelectorConfig(): PodSelectorConfig;
736
+ /**
737
+ * @see INetworkPolicyPeer.toNetworkPolicyPeerConfig()
738
+ */
739
+ toNetworkPolicyPeerConfig(): networkpolicy.NetworkPolicyPeerConfig;
740
+ /**
741
+ * @see INetworkPolicyPeer.toPodSelector()
742
+ */
743
+ toPodSelector(): IPodSelector | undefined;
744
+ }
745
+ /**
746
+ * A node that is matched by label selectors.
747
+ */
748
+ export declare class LabeledNode {
749
+ readonly labelSelector: NodeLabelQuery[];
750
+ constructor(labelSelector: NodeLabelQuery[]);
751
+ }
752
+ /**
753
+ * A node that is matched by taint selectors.
754
+ */
755
+ export declare class TaintedNode {
756
+ readonly taintSelector: NodeTaintQuery[];
757
+ constructor(taintSelector: NodeTaintQuery[]);
758
+ }
759
+ /**
760
+ * A node that is matched by its name.
761
+ */
762
+ export declare class NamedNode {
763
+ readonly name: string;
764
+ constructor(name: string);
765
+ }
766
+ /**
767
+ * Represents a node in the cluster.
768
+ */
769
+ export declare class Node {
770
+ /**
771
+ * Match a node by its labels.
772
+ */
773
+ static labeled(...labelSelector: NodeLabelQuery[]): LabeledNode;
774
+ /**
775
+ * Match a node by its name.
776
+ */
777
+ static named(nodeName: string): NamedNode;
778
+ /**
779
+ * Match a node by its taints.
780
+ */
781
+ static tainted(...taintSelector: NodeTaintQuery[]): TaintedNode;
782
+ }
783
+ /**
784
+ * Available topology domains.
785
+ */
786
+ export declare class Topology {
787
+ readonly key: string;
788
+ /**
789
+ * A hostname represents a single node in the cluster.
790
+ *
791
+ * @see https://kubernetes.io/docs/reference/labels-annotations-taints/#kubernetesiohostname
792
+ */
793
+ static readonly HOSTNAME: Topology;
794
+ /**
795
+ * A zone represents a logical failure domain. It is common for Kubernetes clusters to
796
+ * span multiple zones for increased availability. While the exact definition of a zone is
797
+ * left to infrastructure implementations, common properties of a zone include very low
798
+ * network latency within a zone, no-cost network traffic within a zone, and failure
799
+ * independence from other zones. For example, nodes within a zone might share a network
800
+ * switch, but nodes in different zones should not.
801
+ *
802
+ * @see https://kubernetes.io/docs/reference/labels-annotations-taints/#topologykubernetesiozone
803
+ */
804
+ static readonly ZONE: Topology;
805
+ /**
806
+ * A region represents a larger domain, made up of one or more zones. It is uncommon
807
+ * for Kubernetes clusters to span multiple regions. While the exact definition of a
808
+ * zone or region is left to infrastructure implementations, common properties of a region
809
+ * include higher network latency between them than within them, non-zero cost for network
810
+ * traffic between them, and failure independence from other zones or regions.
811
+ *
812
+ * For example, nodes within a region might share power infrastructure (e.g. a UPS or generator), but
813
+ * nodes in different regions typically would not.
814
+ *
815
+ * @see https://kubernetes.io/docs/reference/labels-annotations-taints/#topologykubernetesioregion
816
+ */
817
+ static readonly REGION: Topology;
818
+ /**
819
+ * Custom key for the node label that the system uses to denote the topology domain.
820
+ */
821
+ static custom(key: string): Topology;
822
+ private constructor();
823
+ }
824
+ /**
825
+ * Options for `PodScheduling.colocate`.
826
+ */
827
+ export interface PodSchedulingColocateOptions {
828
+ /**
829
+ * Which topology to coloate on.
830
+ *
831
+ * @default - Topology.HOSTNAME
832
+ */
833
+ readonly topology?: Topology;
834
+ /**
835
+ * Indicates the co-location is optional (soft), with this weight score.
836
+ *
837
+ * @default - no weight. co-location is assumed to be required (hard).
838
+ */
839
+ readonly weight?: number;
840
+ }
841
+ /**
842
+ * Options for `PodScheduling.separate`.
843
+ */
844
+ export interface PodSchedulingSeparateOptions {
845
+ /**
846
+ * Which topology to separate on.
847
+ *
848
+ * @default - Topology.HOSTNAME
849
+ */
850
+ readonly topology?: Topology;
851
+ /**
852
+ * Indicates the separation is optional (soft), with this weight score.
853
+ *
854
+ * @default - no weight. separation is assumed to be required (hard).
855
+ */
856
+ readonly weight?: number;
857
+ }
858
+ /**
859
+ * Options for `PodScheduling.attract`.
860
+ */
861
+ export interface PodSchedulingAttractOptions {
862
+ /**
863
+ * Indicates the attraction is optional (soft), with this weight score.
864
+ *
865
+ * @default - no weight. assignment is assumed to be required (hard).
866
+ */
867
+ readonly weight?: number;
868
+ }
869
+ /**
870
+ * Controls the pod scheduling strategy.
871
+ */
872
+ export declare class PodScheduling {
873
+ protected readonly instance: AbstractPod;
874
+ private _nodeAffinityPreferred;
875
+ private _nodeAffinityRequired;
876
+ private _podAffinityPreferred;
877
+ private _podAffinityRequired;
878
+ private _podAntiAffinityPreferred;
879
+ private _podAntiAffinityRequired;
880
+ private _tolerations;
881
+ private _nodeName?;
882
+ constructor(instance: AbstractPod);
883
+ /**
884
+ * Assign this pod a specific node by name.
885
+ *
886
+ * The scheduler ignores the Pod, and the kubelet on the named node
887
+ * tries to place the Pod on that node. Overrules any affinity rules of the pod.
888
+ *
889
+ * Some limitations of static assignment are:
890
+ *
891
+ * - If the named node does not exist, the Pod will not run, and in some
892
+ * cases may be automatically deleted.
893
+ * - If the named node does not have the resources to accommodate the Pod,
894
+ * the Pod will fail and its reason will indicate why, for example OutOfmemory or OutOfcpu.
895
+ * - Node names in cloud environments are not always predictable or stable.
896
+ *
897
+ * Will throw is the pod is already assigned to named node.
898
+ *
899
+ * Under the hood, this method utilizes the `nodeName` property.
900
+ */
901
+ assign(node: NamedNode): void;
902
+ /**
903
+ * Allow this pod to tolerate taints matching these tolerations.
904
+ *
905
+ * You can put multiple taints on the same node and multiple tolerations on the same pod.
906
+ * The way Kubernetes processes multiple taints and tolerations is like a filter: start with
907
+ * all of a node's taints, then ignore the ones for which the pod has a matching toleration;
908
+ * the remaining un-ignored taints have the indicated effects on the pod. In particular:
909
+ *
910
+ * - if there is at least one un-ignored taint with effect NoSchedule then Kubernetes will
911
+ * not schedule the pod onto that node
912
+ * - if there is no un-ignored taint with effect NoSchedule but there is at least one un-ignored
913
+ * taint with effect PreferNoSchedule then Kubernetes will try to not schedule the pod onto the node
914
+ * - if there is at least one un-ignored taint with effect NoExecute then the pod will be evicted from
915
+ * the node (if it is already running on the node), and will not be scheduled onto the node (if it is
916
+ * not yet running on the node).
917
+ *
918
+ * Under the hood, this method utilizes the `tolerations` property.
919
+ *
920
+ * @see https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/
921
+ */
922
+ tolerate(node: TaintedNode): void;
923
+ /**
924
+ * Attract this pod to a node matched by selectors.
925
+ * You can select a node by using `Node.labeled()`.
926
+ *
927
+ * Attracting to multiple nodes (i.e invoking this method multiple times) acts as
928
+ * an OR condition, meaning the pod will be assigned to either one of the nodes.
929
+ *
930
+ * Under the hood, this method utilizes the `nodeAffinity` property.
931
+ *
932
+ * @see https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity
933
+ */
934
+ attract(node: LabeledNode, options?: PodSchedulingAttractOptions): void;
935
+ /**
936
+ * Co-locate this pod with a scheduling selection.
937
+ *
938
+ * A selection can be one of:
939
+ *
940
+ * - An instance of a `Pod`.
941
+ * - An instance of a `Workload` (e.g `Deployment`, `StatefulSet`).
942
+ * - An un-managed pod that can be selected via `Pods.select()`.
943
+ *
944
+ * Co-locating with multiple selections ((i.e invoking this method multiple times)) acts as
945
+ * an AND condition. meaning the pod will be assigned to a node that satisfies all
946
+ * selections (i.e runs at least one pod that satisifies each selection).
947
+ *
948
+ * Under the hood, this method utilizes the `podAffinity` property.
949
+ *
950
+ * @see https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity
951
+ */
952
+ colocate(selector: IPodSelector, options?: PodSchedulingColocateOptions): void;
953
+ /**
954
+ * Seperate this pod from a scheduling selection.
955
+ *
956
+ * A selection can be one of:
957
+ *
958
+ * - An instance of a `Pod`.
959
+ * - An instance of a `Workload` (e.g `Deployment`, `StatefulSet`).
960
+ * - An un-managed pod that can be selected via `Pods.select()`.
961
+ *
962
+ * Seperating from multiple selections acts as an AND condition. meaning the pod
963
+ * will not be assigned to a node that satisfies all selections (i.e runs at least one pod that satisifies each selection).
964
+ *
965
+ * Under the hood, this method utilizes the `podAntiAffinity` property.
966
+ *
967
+ * @see https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity
968
+ */
969
+ separate(selector: IPodSelector, options?: PodSchedulingSeparateOptions): void;
970
+ private createPodAffinityTerm;
971
+ private createNodeAffinityTerm;
972
+ private validateWeight;
973
+ /**
974
+ * @internal
975
+ */
976
+ _toKube(): {
977
+ affinity?: k8s.Affinity;
978
+ nodeName?: string;
979
+ tolerations?: k8s.Toleration[];
980
+ };
981
+ }
982
+ /**
983
+ * Isolation determines which policies are created
984
+ * when allowing connections from a a pod / workload to peers.
985
+ */
986
+ export declare enum PodConnectionsIsolation {
987
+ /**
988
+ * Only creates network policies that select the pod.
989
+ */
990
+ POD = "POD",
991
+ /**
992
+ * Only creates network policies that select the peer.
993
+ */
994
+ PEER = "PEER"
995
+ }
996
+ /**
997
+ * Options for `PodConnections.allowTo`.
998
+ */
999
+ export interface PodConnectionsAllowToOptions {
1000
+ /**
1001
+ * Which isolation should be applied to establish the connection.
1002
+ *
1003
+ * @default - unset, isolates both the pod and the peer.
1004
+ */
1005
+ readonly isolation?: PodConnectionsIsolation;
1006
+ /**
1007
+ * Ports to allow outgoing traffic to.
1008
+ *
1009
+ * @default - If the peer is a managed pod, take its ports. Otherwise, all ports are allowed.
1010
+ */
1011
+ readonly ports?: networkpolicy.NetworkPolicyPort[];
1012
+ }
1013
+ /**
1014
+ * Options for `PodConnections.allowFrom`.
1015
+ */
1016
+ export interface PodConnectionsAllowFromOptions {
1017
+ /**
1018
+ * Which isolation should be applied to establish the connection.
1019
+ *
1020
+ * @default - unset, isolates both the pod and the peer.
1021
+ */
1022
+ readonly isolation?: PodConnectionsIsolation;
1023
+ /**
1024
+ * Ports to allow incoming traffic to.
1025
+ *
1026
+ * @default - The pod ports.
1027
+ */
1028
+ readonly ports?: networkpolicy.NetworkPolicyPort[];
1029
+ }
1030
+ /**
1031
+ * Controls network isolation rules for inter-pod communication.
1032
+ */
1033
+ export declare class PodConnections {
1034
+ protected readonly instance: AbstractPod;
1035
+ constructor(instance: AbstractPod);
1036
+ /**
1037
+ * Allow network traffic from this pod to the peer.
1038
+ *
1039
+ * By default, this will create an egress network policy for this pod, and an ingress
1040
+ * network policy for the peer. This is required if both sides are already isolated.
1041
+ * Use `options.isolation` to control this behavior.
1042
+ *
1043
+ * @example
1044
+ *
1045
+ * // create only an egress policy that selects the 'web' pod to allow outgoing traffic
1046
+ * // to the 'redis' pod. this requires the 'redis' pod to not be isolated for ingress.
1047
+ * web.connections.allowTo(redis, { isolation: Isolation.POD })
1048
+ *
1049
+ * // create only an ingress policy that selects the 'redis' peer to allow incoming traffic
1050
+ * // from the 'web' pod. this requires the 'web' pod to not be isolated for egress.
1051
+ * web.connections.allowTo(redis, { isolation: Isolation.PEER })
1052
+ *
1053
+ */
1054
+ allowTo(peer: networkpolicy.INetworkPolicyPeer, options?: PodConnectionsAllowToOptions): void;
1055
+ /**
1056
+ * Allow network traffic from the peer to this pod.
1057
+ *
1058
+ * By default, this will create an ingress network policy for this pod, and an egress
1059
+ * network policy for the peer. This is required if both sides are already isolated.
1060
+ * Use `options.isolation` to control this behavior.
1061
+ *
1062
+ * @example
1063
+ *
1064
+ * // create only an egress policy that selects the 'web' pod to allow outgoing traffic
1065
+ * // to the 'redis' pod. this requires the 'redis' pod to not be isolated for ingress.
1066
+ * redis.connections.allowFrom(web, { isolation: Isolation.PEER })
1067
+ *
1068
+ * // create only an ingress policy that selects the 'redis' peer to allow incoming traffic
1069
+ * // from the 'web' pod. this requires the 'web' pod to not be isolated for egress.
1070
+ * redis.connections.allowFrom(web, { isolation: Isolation.POD })
1071
+ *
1072
+ */
1073
+ allowFrom(peer: networkpolicy.INetworkPolicyPeer, options?: PodConnectionsAllowFromOptions): void;
1074
+ private allow;
1075
+ private extractPorts;
1076
+ /**
1077
+ * Sets the default network policy for Pod/Workload to have all egress and ingress connections as disabled
1078
+ */
1079
+ isolate(): void;
1080
+ }