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
@@ -0,0 +1,104 @@
1
+ # Role Based Access Control
2
+
3
+ Role Based Access Control(RBAC) helps you restrict actions that can be performed on specific Kubernetes resources. To make this possible, RBAC lets you create roles with rules which define access permissions for your specified resource.
4
+
5
+ These roles can then be binded to Kubernetes subjects, which could be User, Group or ServiceAccount.
6
+
7
+ !!! note
8
+ Rules or permissions are purely additive and there are no deny rules.
9
+
10
+ Now, there are two types of roles available,
11
+ * Role: These set permissions within a particular namespace i.e. is for namespaced resources, like, pods, deployments.
12
+ * ClusterRole: These set permissions for non-namespaced resources, like, nodes, urls.
13
+
14
+ and, similarly there are two types of binding available,
15
+ * RoleBinding: These grant permissions within a specific namespace.
16
+ * ClusterRoleBinding: These grant cluster wide permissions .
17
+
18
+ !!! tip "Learn more"
19
+ * [Role API Reference](../../reference/cdk8s-plus-31/typescript.md#role)
20
+ * [RoleBinding API Reference](../../reference/cdk8s-plus-31/typescript.md#role-binding)
21
+
22
+ ## Role
23
+
24
+ ### Create role and add rules to it
25
+
26
+ ```typescript
27
+ import * as kplus from 'cdk8s-plus-31';
28
+ import { Construct } from 'constructs';
29
+ import { App, Chart, ChartProps } from 'cdk8s';
30
+
31
+ export class MyChart extends Chart {
32
+ constructor(scope: Construct, id: string, props: ChartProps = { }) {
33
+ super(scope, id, props);
34
+
35
+ // Creating RBAC Role
36
+ const role = new kplus.Role(this, 'SampleRole');
37
+
38
+ // The convenience method here `allowReadWrite` would add
39
+ // `get, list, watch, create, update, patch, delete,
40
+ // deletecollection` rules to the role for deployment resources.
41
+ role.allowReadWrite(kplus.ApiResource.DEPLOYMENTS);
42
+
43
+ const user = kplus.User.fromName(this, 'SampleUser', 'Jane');
44
+ const group = kplus.Group.fromName(this, 'SampleGroup', 'sample-group');
45
+ const serviceAccount = new kplus.ServiceAccount(this, 'SampleServiceAccount');
46
+
47
+ // You can bind this role to a specific user, group or service account
48
+ role.bind(user, group, serviceAccount);
49
+ }
50
+ }
51
+
52
+ const app = new App();
53
+ new MyChart(app, 'rbac-docs');
54
+ app.synth();
55
+ ```
56
+
57
+ ## ClusterRole
58
+
59
+ ### Create ClusterRole and add rules to it
60
+
61
+ ```typescript
62
+ // Creating RBAC ClusterRole
63
+ const clusterRole = new kplus.ClusterRole(this, 'SampleClusterRole');
64
+
65
+ // Adding list of rules to the ClusterRole for 'Nodes' and 'URL' non-namespaced resource
66
+ clusterRole.allowReadWrite(kplus.ApiResource.NODES, kplus.NonApiResource.of('/healthz'));
67
+
68
+ const user = kplus.User.fromName(this, 'SampleUser', 'Jane');
69
+ const group = kplus.Group.fromName(this, 'SampleGroup', 'sample-group');
70
+ const serviceAccount = new kplus.ServiceAccount(this, 'SampleServiceAccount');
71
+
72
+ // You can bind this cluster role to a specific user, group or service account
73
+ clusterRole.bind(user, group, serviceAccount);
74
+ ```
75
+
76
+ ## Resource Permission Methods
77
+
78
+ You can use convenience methods like `grantRead` and `grantReadWrite` which would make it easier to grant list of subjects set of permissions for the resource.
79
+
80
+ ### `grantReadWrite` Method
81
+
82
+ ```typescript
83
+ // Creating a Pod resource
84
+ const pod = new kplus.Pod(this, 'Pod', {
85
+ containers: [{ image: 'image' }],
86
+ });
87
+
88
+ const user = kplus.User.fromName(this, 'SampleUser', 'Jane');
89
+ const group = kplus.Group.fromName(this, 'SampleGroup', 'sample-group');
90
+ const serviceAccount = new kplus.ServiceAccount(this, 'SampleServiceAccount');
91
+
92
+ // You can grant permissions to specific user, group or service account.
93
+ pod.permissions.grantReadWrite(user, group, serviceAccount);
94
+ ```
95
+
96
+ ## Add subjects to an already bound role
97
+
98
+ ```typescript
99
+ const user = kplus.User.fromName(this, 'SampleUser', 'Jane');
100
+ const binding = role.bind(user);
101
+
102
+ const anotherUser = kplus.User.fromName(this, 'AnotherSampleUser', 'James');
103
+ binding.addSubjects(anotherUser);
104
+ ```
@@ -0,0 +1,32 @@
1
+ # Secret
2
+
3
+ Secrets are used to store confidential information. Never store such information on the definition of the pod itself.
4
+
5
+ !!! tip ""
6
+ [API Reference](../../reference/cdk8s-plus-31/typescript.md#secret)
7
+
8
+ ## Use an existing `Secret`
9
+
10
+ To reference a secret created outside of your deployment definition, use the following. Note that this does not create a new object,
11
+ and will therefore not be included in the resulting manifest.
12
+
13
+ ```typescript
14
+ import * as kplus from 'cdk8s-plus-31';
15
+
16
+ const secret = kplus.Secret.fromSecretName('aws-creds');
17
+ ```
18
+
19
+ ## Adding data
20
+
21
+ To create a new secret with some data, use:
22
+
23
+ ```typescript
24
+ import * as kplus from 'cdk8s-plus-31';
25
+ import * as k from 'cdk8s';
26
+
27
+ const app = new k.App();
28
+ const chart = new k.Chart(app, 'Chart');
29
+
30
+ const secret = new kplus.Secret(chart, 'Secret');
31
+ secret.addStringData('password', 'some-encrypted-data');
32
+ ```
@@ -0,0 +1,35 @@
1
+ # ServiceAccount
2
+
3
+ Use service accounts to provide an identity for pods.
4
+
5
+ !!! tip ""
6
+ [API Reference](../../reference/cdk8s-plus-31/typescript.md#serviceaccount)
7
+
8
+ ## Use an existing `ServiceAccount`
9
+
10
+ To reference a service account created outside of your deployment definition, use the following. Note that this does not create a new object,
11
+ and will therefore not be included in the resulting manifest.
12
+
13
+ ```typescript
14
+ import * as kplus from 'cdk8s-plus-31';
15
+
16
+ const serviceAccount = kplus.ServiceAccount.fromServiceAccountName('aws-service');
17
+ ```
18
+
19
+ ## Allowing access to secrets
20
+
21
+ To create a new service account, and give it access to some secrets, use the following:
22
+
23
+ ```typescript
24
+ import * as kplus from 'cdk8s-plus-31';
25
+ import * as k from 'cdk8s';
26
+
27
+ const app = new k.App();
28
+ const chart = new k.Chart(app, 'Chart');
29
+
30
+ const awsCreds = kplus.Secret.fromSecretName('aws-creds');
31
+ const awsService = new kplus.ServiceAccount(chart, 'AWS');
32
+
33
+ // give access to the aws creds secret.
34
+ awsService.addSecret(awsCreds);
35
+ ```
@@ -0,0 +1,41 @@
1
+ # Service
2
+
3
+ Use services when you want to expose a set of pods using a stable network
4
+ identity. They can also be used for externalizing endpoints to clients outside
5
+ of the kubernetes cluster.
6
+
7
+ !!! tip ""
8
+ [API Reference](../../reference/cdk8s-plus-31/typescript.md#service)
9
+
10
+ ## Selectors
11
+
12
+ Services must be configured with selectors that tell it which pods should it serve.
13
+ The most common selector method is using labels.
14
+
15
+ ```typescript
16
+ import * as k from 'cdk8s';
17
+ import * as kplus from 'cdk8s-plus-31';
18
+
19
+ const app = new k.App();
20
+ const chart = new k.Chart(app, 'Chart');
21
+ const frontends = new kplus.Service(chart, 'FrontEnds');
22
+
23
+ // this will cause the service to select all pods with the 'run: frontend' label.
24
+ frontends.select(kplus.LabelSelector.equals('run', 'frontend'));
25
+ ```
26
+
27
+ ## Ports
28
+
29
+ Ports that the service will listen and redirect to can be configured like so:
30
+
31
+ ```typescript
32
+ import * as k from 'cdk8s';
33
+ import * as kplus from 'cdk8s-plus-31';
34
+
35
+ const app = new k.App();
36
+ const chart = new k.Chart(app, 'Chart');
37
+ const frontends = new kplus.Service(chart, 'FrontEnds');
38
+
39
+ // make the service bind to port 9000 and redirect to port 80 on the associated containers.
40
+ frontends.bind({port: 9000, targetPort: 80)
41
+ ```
@@ -0,0 +1,38 @@
1
+ # Volume
2
+
3
+ Volume represents a named volume in a pod that may be accessed by any container in the pod.
4
+
5
+ !!! tip ""
6
+ [API Reference](../../reference/cdk8s-plus-31/typescript.md#volume)
7
+
8
+ ## Create from a ConfigMap
9
+
10
+ A very useful operation is to create a volume from a `ConfigMap`. Kubernetes will translate every key in the config map to a file,
11
+ who's content is the value of the key.
12
+
13
+ ```typescript
14
+ import * as kplus from 'cdk8s-plus-31';
15
+
16
+ const configMap = kplus.ConfigMap.fromConfigMapName('redis-config');
17
+ const configVolume = kplus.Volume.fromConfigMap(configMap);
18
+ ```
19
+
20
+ ## Create from an EmptyDir
21
+
22
+ The easiest way to allocate some persistent storage to your container is to create a volume from an empty directory.
23
+ This volume, as the name suggests, is initially empty, and can be written to by containers who mount it.
24
+ The data in the volume is preserved throughout the lifecycle of the pod, but is deleted forever as soon as the pod itself is removed.
25
+
26
+ ```typescript
27
+ import * as kplus from 'cdk8s-plus-31';
28
+
29
+ const data = kplus.Volume.fromEmptyDir(configMap);
30
+
31
+ const pod = new kplus.Pod(this, 'Pod');
32
+ const redis = pod.addContainer({
33
+ image: 'redis'
34
+ })
35
+
36
+ // mount to the redis container.
37
+ redis.mount('/var/lib/redis', data);
38
+ ```