kubernetes-fluent-client 1.4.2 → 1.5.1
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/dist/fetch.d.ts +1 -1
- package/dist/fetch.js +1 -1
- package/dist/fluent/apply.d.ts +10 -0
- package/dist/fluent/apply.d.ts.map +1 -0
- package/dist/fluent/apply.js +4 -0
- package/dist/fluent/index.d.ts +1 -0
- package/dist/fluent/index.d.ts.map +1 -1
- package/dist/fluent/index.js +46 -4
- package/dist/fluent/index.test.js +50 -1
- package/dist/fluent/types.d.ts +35 -22
- package/dist/fluent/types.d.ts.map +1 -1
- package/dist/fluent/utils.d.ts +20 -8
- package/dist/fluent/utils.d.ts.map +1 -1
- package/dist/fluent/utils.js +20 -9
- package/dist/fluent/utils.test.js +1 -1
- package/dist/fluent/watch.d.ts +9 -2
- package/dist/fluent/watch.d.ts.map +1 -1
- package/dist/fluent/watch.js +18 -1
- package/dist/kinds.d.ts +6 -0
- package/dist/kinds.d.ts.map +1 -1
- package/dist/kinds.js +53 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/fetch.ts +1 -1
- package/src/fluent/apply.ts +12 -0
- package/src/fluent/index.test.ts +55 -1
- package/src/fluent/index.ts +50 -4
- package/src/fluent/types.ts +35 -22
- package/src/fluent/utils.test.ts +2 -1
- package/src/fluent/utils.ts +21 -8
- package/src/fluent/watch.ts +21 -3
- package/src/kinds.ts +53 -0
- package/src/types.ts +1 -1
package/dist/kinds.js
CHANGED
|
@@ -10,6 +10,7 @@ const gvkMap = {
|
|
|
10
10
|
* Events have a limited retention time and triggers and messages may evolve with time. Event consumers should not
|
|
11
11
|
* rely on the timing of an event with a given Reason reflecting a consistent underlying trigger, or the continued
|
|
12
12
|
* existence of events with that Reason. Events should be treated as informative, best-effort, supplemental data.
|
|
13
|
+
*
|
|
13
14
|
* @see {@link https://kubernetes.io/docs/reference/kubernetes-api/cluster-resources/event-v1/}
|
|
14
15
|
*/
|
|
15
16
|
CoreV1Event: {
|
|
@@ -20,6 +21,7 @@ const gvkMap = {
|
|
|
20
21
|
/**
|
|
21
22
|
* Represents a K8s ClusterRole resource.
|
|
22
23
|
* ClusterRole is a set of permissions that can be bound to a user or group in a cluster-wide scope.
|
|
24
|
+
*
|
|
23
25
|
* @see {@link https://kubernetes.io/docs/reference/access-authn-authz/rbac/#role-and-clusterrole}
|
|
24
26
|
*/
|
|
25
27
|
V1ClusterRole: {
|
|
@@ -30,6 +32,7 @@ const gvkMap = {
|
|
|
30
32
|
/**
|
|
31
33
|
* Represents a K8s ClusterRoleBinding resource.
|
|
32
34
|
* ClusterRoleBinding binds a ClusterRole to a user or group in a cluster-wide scope.
|
|
35
|
+
*
|
|
33
36
|
* @see {@link https://kubernetes.io/docs/reference/access-authn-authz/rbac/#rolebinding-and-clusterrolebinding}
|
|
34
37
|
*/
|
|
35
38
|
V1ClusterRoleBinding: {
|
|
@@ -40,6 +43,7 @@ const gvkMap = {
|
|
|
40
43
|
/**
|
|
41
44
|
* Represents a K8s Role resource.
|
|
42
45
|
* Role is a set of permissions that can be bound to a user or group in a namespace scope.
|
|
46
|
+
*
|
|
43
47
|
* @see {@link https://kubernetes.io/docs/reference/access-authn-authz/rbac/#role-and-clusterrole}
|
|
44
48
|
*/
|
|
45
49
|
V1Role: {
|
|
@@ -50,6 +54,7 @@ const gvkMap = {
|
|
|
50
54
|
/**
|
|
51
55
|
* Represents a K8s RoleBinding resource.
|
|
52
56
|
* RoleBinding binds a Role to a user or group in a namespace scope.
|
|
57
|
+
*
|
|
53
58
|
* @see {@link https://kubernetes.io/docs/reference/access-authn-authz/rbac/#rolebinding-and-clusterrolebinding}
|
|
54
59
|
*/
|
|
55
60
|
V1RoleBinding: {
|
|
@@ -60,6 +65,7 @@ const gvkMap = {
|
|
|
60
65
|
/**
|
|
61
66
|
* Represents a K8s ConfigMap resource.
|
|
62
67
|
* ConfigMap holds configuration data for pods to consume.
|
|
68
|
+
*
|
|
63
69
|
* @see {@link https://kubernetes.io/docs/concepts/configuration/configmap/}
|
|
64
70
|
*/
|
|
65
71
|
V1ConfigMap: {
|
|
@@ -70,6 +76,7 @@ const gvkMap = {
|
|
|
70
76
|
/**
|
|
71
77
|
* Represents a K8s Endpoints resource.
|
|
72
78
|
* Endpoints expose a service's IP addresses and ports to other resources.
|
|
79
|
+
*
|
|
73
80
|
* @see {@link https://kubernetes.io/docs/concepts/services-networking/service/#endpoints}
|
|
74
81
|
*/
|
|
75
82
|
V1Endpoint: {
|
|
@@ -81,6 +88,7 @@ const gvkMap = {
|
|
|
81
88
|
/**
|
|
82
89
|
* Represents a K8s LimitRange resource.
|
|
83
90
|
* LimitRange enforces constraints on the resource consumption of objects in a namespace.
|
|
91
|
+
*
|
|
84
92
|
* @see {@link https://kubernetes.io/docs/concepts/policy/limit-range/}
|
|
85
93
|
*/
|
|
86
94
|
V1LimitRange: {
|
|
@@ -91,6 +99,7 @@ const gvkMap = {
|
|
|
91
99
|
/**
|
|
92
100
|
* Represents a K8s Namespace resource.
|
|
93
101
|
* Namespace is a way to divide cluster resources between multiple users.
|
|
102
|
+
*
|
|
94
103
|
* @see {@link https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/}
|
|
95
104
|
*/
|
|
96
105
|
V1Namespace: {
|
|
@@ -101,6 +110,7 @@ const gvkMap = {
|
|
|
101
110
|
/**
|
|
102
111
|
* Represents a K8s Node resource.
|
|
103
112
|
* Node is a worker machine in Kubernetes.
|
|
113
|
+
*
|
|
104
114
|
* @see {@link https://kubernetes.io/docs/concepts/architecture/nodes/}
|
|
105
115
|
*/
|
|
106
116
|
V1Node: {
|
|
@@ -111,6 +121,7 @@ const gvkMap = {
|
|
|
111
121
|
/**
|
|
112
122
|
* Represents a K8s PersistentVolumeClaim resource.
|
|
113
123
|
* PersistentVolumeClaim is a user's request for and claim to a persistent volume.
|
|
124
|
+
*
|
|
114
125
|
* @see {@link https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims}
|
|
115
126
|
*/
|
|
116
127
|
V1PersistentVolumeClaim: {
|
|
@@ -121,6 +132,7 @@ const gvkMap = {
|
|
|
121
132
|
/**
|
|
122
133
|
* Represents a K8s PersistentVolume resource.
|
|
123
134
|
* PersistentVolume is a piece of storage in the cluster that has been provisioned by an administrator.
|
|
135
|
+
*
|
|
124
136
|
* @see {@link https://kubernetes.io/docs/concepts/storage/persistent-volumes/}
|
|
125
137
|
*/
|
|
126
138
|
V1PersistentVolume: {
|
|
@@ -131,6 +143,7 @@ const gvkMap = {
|
|
|
131
143
|
/**
|
|
132
144
|
* Represents a K8s Pod resource.
|
|
133
145
|
* Pod is the smallest and simplest unit in the Kubernetes object model.
|
|
146
|
+
*
|
|
134
147
|
* @see {@link https://kubernetes.io/docs/concepts/workloads/pods/}
|
|
135
148
|
*/
|
|
136
149
|
V1Pod: {
|
|
@@ -141,6 +154,7 @@ const gvkMap = {
|
|
|
141
154
|
/**
|
|
142
155
|
* Represents a K8s PodTemplate resource.
|
|
143
156
|
* PodTemplate is an object that describes the pod that will be created from a higher level abstraction.
|
|
157
|
+
*
|
|
144
158
|
* @see {@link https://kubernetes.io/docs/concepts/workloads/controllers/#pod-template}
|
|
145
159
|
*/
|
|
146
160
|
V1PodTemplate: {
|
|
@@ -151,6 +165,7 @@ const gvkMap = {
|
|
|
151
165
|
/**
|
|
152
166
|
* Represents a K8s ReplicationController resource.
|
|
153
167
|
* ReplicationController ensures that a specified number of pod replicas are running at any given time.
|
|
168
|
+
*
|
|
154
169
|
* @see {@link https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/}
|
|
155
170
|
*/
|
|
156
171
|
V1ReplicationController: {
|
|
@@ -161,6 +176,7 @@ const gvkMap = {
|
|
|
161
176
|
/**
|
|
162
177
|
* Represents a K8s ResourceQuota resource.
|
|
163
178
|
* ResourceQuota provides constraints that limit resource consumption per namespace.
|
|
179
|
+
*
|
|
164
180
|
* @see {@link https://kubernetes.io/docs/concepts/policy/resource-quotas/}
|
|
165
181
|
*/
|
|
166
182
|
V1ResourceQuota: {
|
|
@@ -171,6 +187,7 @@ const gvkMap = {
|
|
|
171
187
|
/**
|
|
172
188
|
* Represents a K8s Secret resource.
|
|
173
189
|
* Secret holds secret data of a certain type.
|
|
190
|
+
*
|
|
174
191
|
* @see {@link https://kubernetes.io/docs/concepts/configuration/secret/}
|
|
175
192
|
*/
|
|
176
193
|
V1Secret: {
|
|
@@ -181,6 +198,7 @@ const gvkMap = {
|
|
|
181
198
|
/**
|
|
182
199
|
* Represents a K8s ServiceAccount resource.
|
|
183
200
|
* ServiceAccount is an identity that processes in a pod can use to access the Kubernetes API.
|
|
201
|
+
*
|
|
184
202
|
* @see {@link https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/}
|
|
185
203
|
*/
|
|
186
204
|
V1ServiceAccount: {
|
|
@@ -191,6 +209,7 @@ const gvkMap = {
|
|
|
191
209
|
/**
|
|
192
210
|
* Represents a K8s Service resource.
|
|
193
211
|
* Service is an abstraction which defines a logical set of Pods and a policy by which to access them.
|
|
212
|
+
*
|
|
194
213
|
* @see {@link https://kubernetes.io/docs/concepts/services-networking/service/}
|
|
195
214
|
*/
|
|
196
215
|
V1Service: {
|
|
@@ -201,6 +220,7 @@ const gvkMap = {
|
|
|
201
220
|
/**
|
|
202
221
|
* Represents a K8s MutatingWebhookConfiguration resource.
|
|
203
222
|
* MutatingWebhookConfiguration configures a mutating admission webhook.
|
|
223
|
+
*
|
|
204
224
|
* @see {@link https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#configure-admission-webhooks-on-the-fly}
|
|
205
225
|
*/
|
|
206
226
|
V1MutatingWebhookConfiguration: {
|
|
@@ -211,6 +231,7 @@ const gvkMap = {
|
|
|
211
231
|
/**
|
|
212
232
|
* Represents a K8s ValidatingWebhookConfiguration resource.
|
|
213
233
|
* ValidatingWebhookConfiguration configures a validating admission webhook.
|
|
234
|
+
*
|
|
214
235
|
* @see {@link https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#configure-admission-webhooks-on-the-fly}
|
|
215
236
|
*/
|
|
216
237
|
V1ValidatingWebhookConfiguration: {
|
|
@@ -221,6 +242,7 @@ const gvkMap = {
|
|
|
221
242
|
/**
|
|
222
243
|
* Represents a K8s CustomResourceDefinition resource.
|
|
223
244
|
* CustomResourceDefinition is a custom resource in a Kubernetes cluster.
|
|
245
|
+
*
|
|
224
246
|
* @see {@link https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/}
|
|
225
247
|
*/
|
|
226
248
|
V1CustomResourceDefinition: {
|
|
@@ -231,6 +253,7 @@ const gvkMap = {
|
|
|
231
253
|
/**
|
|
232
254
|
* Represents a K8s APIService resource.
|
|
233
255
|
* APIService represents a server for a particular API version and group.
|
|
256
|
+
*
|
|
234
257
|
* @see {@link https://kubernetes.io/docs/tasks/access-kubernetes-api/setup-extension-api-server/}
|
|
235
258
|
*/
|
|
236
259
|
V1APIService: {
|
|
@@ -241,6 +264,7 @@ const gvkMap = {
|
|
|
241
264
|
/**
|
|
242
265
|
* Represents a K8s ControllerRevision resource.
|
|
243
266
|
* ControllerRevision is used to manage the history of a StatefulSet or DaemonSet.
|
|
267
|
+
*
|
|
244
268
|
* @see {@link https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#revision-history}
|
|
245
269
|
*/
|
|
246
270
|
V1ControllerRevision: {
|
|
@@ -251,6 +275,7 @@ const gvkMap = {
|
|
|
251
275
|
/**
|
|
252
276
|
* Represents a K8s DaemonSet resource.
|
|
253
277
|
* DaemonSet ensures that all (or some) nodes run a copy of a Pod.
|
|
278
|
+
*
|
|
254
279
|
* @see {@link https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/}
|
|
255
280
|
*/
|
|
256
281
|
V1DaemonSet: {
|
|
@@ -261,6 +286,7 @@ const gvkMap = {
|
|
|
261
286
|
/**
|
|
262
287
|
* Represents a K8s Deployment resource.
|
|
263
288
|
* Deployment provides declarative updates for Pods and ReplicaSets.
|
|
289
|
+
*
|
|
264
290
|
* @see {@link https://kubernetes.io/docs/concepts/workloads/controllers/deployment/}
|
|
265
291
|
*/
|
|
266
292
|
V1Deployment: {
|
|
@@ -271,6 +297,7 @@ const gvkMap = {
|
|
|
271
297
|
/**
|
|
272
298
|
* Represents a K8s ReplicaSet resource.
|
|
273
299
|
* ReplicaSet ensures that a specified number of pod replicas are running at any given time.
|
|
300
|
+
*
|
|
274
301
|
* @see {@link https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/}
|
|
275
302
|
*/
|
|
276
303
|
V1ReplicaSet: {
|
|
@@ -281,6 +308,7 @@ const gvkMap = {
|
|
|
281
308
|
/**
|
|
282
309
|
* Represents a K8s StatefulSet resource.
|
|
283
310
|
* StatefulSet is used to manage stateful applications.
|
|
311
|
+
*
|
|
284
312
|
* @see {@link https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/}
|
|
285
313
|
*/
|
|
286
314
|
V1StatefulSet: {
|
|
@@ -291,6 +319,7 @@ const gvkMap = {
|
|
|
291
319
|
/**
|
|
292
320
|
* Represents a K8s TokenReview resource.
|
|
293
321
|
* TokenReview attempts to authenticate a token to a known user.
|
|
322
|
+
*
|
|
294
323
|
* @see {@link https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#tokenreview-v1-authentication-k8s-io}
|
|
295
324
|
*/
|
|
296
325
|
V1TokenReview: {
|
|
@@ -301,6 +330,7 @@ const gvkMap = {
|
|
|
301
330
|
/**
|
|
302
331
|
* Represents a K8s LocalSubjectAccessReview resource.
|
|
303
332
|
* LocalSubjectAccessReview checks whether a specific user can perform a specific action in a specific namespace.
|
|
333
|
+
*
|
|
304
334
|
* @see {@link https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#localsubjectaccessreview-v1-authorization-k8s-io}
|
|
305
335
|
*/
|
|
306
336
|
V1LocalSubjectAccessReview: {
|
|
@@ -311,6 +341,7 @@ const gvkMap = {
|
|
|
311
341
|
/**
|
|
312
342
|
* Represents a K8s SelfSubjectAccessReview resource.
|
|
313
343
|
* SelfSubjectAccessReview checks whether the current user can perform a specific action.
|
|
344
|
+
*
|
|
314
345
|
* @see {@link https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#selfsubjectaccessreview-v1-authorization-k8s-io}
|
|
315
346
|
*/
|
|
316
347
|
V1SelfSubjectAccessReview: {
|
|
@@ -321,6 +352,7 @@ const gvkMap = {
|
|
|
321
352
|
/**
|
|
322
353
|
* Represents a K8s SelfSubjectRulesReview resource.
|
|
323
354
|
* SelfSubjectRulesReview lists the permissions a specific user has within a namespace.
|
|
355
|
+
*
|
|
324
356
|
* @see {@link https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#selfsubjectrulesreview-v1-authorization-k8s-io}
|
|
325
357
|
*/
|
|
326
358
|
V1SelfSubjectRulesReview: {
|
|
@@ -331,6 +363,7 @@ const gvkMap = {
|
|
|
331
363
|
/**
|
|
332
364
|
* Represents a K8s SubjectAccessReview resource.
|
|
333
365
|
* SubjectAccessReview checks whether a specific user can perform a specific action.
|
|
366
|
+
*
|
|
334
367
|
* @see {@link https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#subjectaccessreview-v1-authorization-k8s-io}
|
|
335
368
|
*/
|
|
336
369
|
V1SubjectAccessReview: {
|
|
@@ -341,6 +374,7 @@ const gvkMap = {
|
|
|
341
374
|
/**
|
|
342
375
|
* Represents a K8s HorizontalPodAutoscaler resource.
|
|
343
376
|
* HorizontalPodAutoscaler automatically scales the number of Pods in a replication controller, deployment, or replica set.
|
|
377
|
+
*
|
|
344
378
|
* @see {@link https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/}
|
|
345
379
|
*/
|
|
346
380
|
V1HorizontalPodAutoscaler: {
|
|
@@ -351,6 +385,7 @@ const gvkMap = {
|
|
|
351
385
|
/**
|
|
352
386
|
* Represents a K8s CronJob resource.
|
|
353
387
|
* CronJob manages time-based jobs, specifically those that run periodically and complete after a successful execution.
|
|
388
|
+
*
|
|
354
389
|
* @see {@link https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/}
|
|
355
390
|
*/
|
|
356
391
|
V1CronJob: {
|
|
@@ -361,6 +396,7 @@ const gvkMap = {
|
|
|
361
396
|
/**
|
|
362
397
|
* Represents a K8s Job resource.
|
|
363
398
|
* Job represents the configuration of a single job.
|
|
399
|
+
*
|
|
364
400
|
* @see {@link https://kubernetes.io/docs/concepts/workloads/controllers/job/}
|
|
365
401
|
*/
|
|
366
402
|
V1Job: {
|
|
@@ -371,6 +407,7 @@ const gvkMap = {
|
|
|
371
407
|
/**
|
|
372
408
|
* Represents a K8s CertificateSigningRequest resource.
|
|
373
409
|
* CertificateSigningRequest represents a certificate signing request.
|
|
410
|
+
*
|
|
374
411
|
* @see {@link https://kubernetes.io/docs/reference/access-authn-authz/certificate-signing-requests/}
|
|
375
412
|
*/
|
|
376
413
|
V1CertificateSigningRequest: {
|
|
@@ -381,6 +418,7 @@ const gvkMap = {
|
|
|
381
418
|
/**
|
|
382
419
|
* Represents a K8s EndpointSlice resource.
|
|
383
420
|
* EndpointSlice represents a scalable set of network endpoints for a Kubernetes Service.
|
|
421
|
+
*
|
|
384
422
|
* @see {@link https://kubernetes.io/docs/concepts/services-networking/endpoint-slices/}
|
|
385
423
|
*/
|
|
386
424
|
V1EndpointSlice: {
|
|
@@ -391,6 +429,7 @@ const gvkMap = {
|
|
|
391
429
|
/**
|
|
392
430
|
* Represents a K8s IngressClass resource.
|
|
393
431
|
* IngressClass represents the class of the Ingress, referenced by the Ingress spec.
|
|
432
|
+
*
|
|
394
433
|
* @see {@link https://kubernetes.io/docs/concepts/services-networking/ingress/}
|
|
395
434
|
*/
|
|
396
435
|
V1IngressClass: {
|
|
@@ -401,6 +440,7 @@ const gvkMap = {
|
|
|
401
440
|
/**
|
|
402
441
|
* Represents a K8s Ingress resource.
|
|
403
442
|
* Ingress exposes HTTP and HTTPS routes from outside the cluster to services within the cluster.
|
|
443
|
+
*
|
|
404
444
|
* @see {@link https://kubernetes.io/docs/concepts/services-networking/ingress/}
|
|
405
445
|
*/
|
|
406
446
|
V1Ingress: {
|
|
@@ -412,6 +452,7 @@ const gvkMap = {
|
|
|
412
452
|
/**
|
|
413
453
|
* Represents a K8s NetworkPolicy resource.
|
|
414
454
|
* NetworkPolicy defines a set of rules for how pods communicate with each other.
|
|
455
|
+
*
|
|
415
456
|
* @see {@link https://kubernetes.io/docs/concepts/services-networking/network-policies/}
|
|
416
457
|
*/
|
|
417
458
|
V1NetworkPolicy: {
|
|
@@ -422,6 +463,7 @@ const gvkMap = {
|
|
|
422
463
|
/**
|
|
423
464
|
* Represents a K8s RuntimeClass resource.
|
|
424
465
|
* RuntimeClass is a cluster-scoped resource that surfaces container runtime properties to the control plane.
|
|
466
|
+
*
|
|
425
467
|
* @see {@link https://kubernetes.io/docs/concepts/containers/runtime-class/}
|
|
426
468
|
*/
|
|
427
469
|
V1RuntimeClass: {
|
|
@@ -432,6 +474,7 @@ const gvkMap = {
|
|
|
432
474
|
/**
|
|
433
475
|
* Represents a K8s PodDisruptionBudget resource.
|
|
434
476
|
* PodDisruptionBudget is an API object that limits the number of pods of a replicated application that are down simultaneously.
|
|
477
|
+
*
|
|
435
478
|
* @see {@link https://kubernetes.io/docs/concepts/workloads/pods/disruptions/}
|
|
436
479
|
*/
|
|
437
480
|
V1PodDisruptionBudget: {
|
|
@@ -442,6 +485,7 @@ const gvkMap = {
|
|
|
442
485
|
/**
|
|
443
486
|
* Represents a K8s VolumeAttachment resource.
|
|
444
487
|
* VolumeAttachment captures the intent to attach or detach the specified volume to/from the specified node.
|
|
488
|
+
*
|
|
445
489
|
* @see {@link https://kubernetes.io/docs/concepts/storage/storage-classes/}
|
|
446
490
|
*/
|
|
447
491
|
V1VolumeAttachment: {
|
|
@@ -452,6 +496,7 @@ const gvkMap = {
|
|
|
452
496
|
/**
|
|
453
497
|
* Represents a K8s CSIDriver resource.
|
|
454
498
|
* CSIDriver captures information about a Container Storage Interface (CSI) volume driver.
|
|
499
|
+
*
|
|
455
500
|
* @see {@link https://kubernetes.io/docs/concepts/storage/volumes/}
|
|
456
501
|
*/
|
|
457
502
|
V1CSIDriver: {
|
|
@@ -462,6 +507,7 @@ const gvkMap = {
|
|
|
462
507
|
/**
|
|
463
508
|
* Represents a K8s CSIStorageCapacity resource.
|
|
464
509
|
* CSIStorageCapacity stores the reported storage capacity of a CSI node or storage class.
|
|
510
|
+
*
|
|
465
511
|
* @see {@link https://kubernetes.io/docs/concepts/storage/csi/}
|
|
466
512
|
*/
|
|
467
513
|
V1CSIStorageCapacity: {
|
|
@@ -472,6 +518,7 @@ const gvkMap = {
|
|
|
472
518
|
/**
|
|
473
519
|
* Represents a K8s StorageClass resource.
|
|
474
520
|
* StorageClass is a cluster-scoped resource that provides a way for administrators to describe the classes of storage they offer.
|
|
521
|
+
*
|
|
475
522
|
* @see {@link https://kubernetes.io/docs/concepts/storage/storage-classes/}
|
|
476
523
|
*/
|
|
477
524
|
V1StorageClass: {
|
|
@@ -480,6 +527,12 @@ const gvkMap = {
|
|
|
480
527
|
group: "storage.k8s.io",
|
|
481
528
|
},
|
|
482
529
|
};
|
|
530
|
+
/**
|
|
531
|
+
* Converts a model name to a GroupVersionKind
|
|
532
|
+
*
|
|
533
|
+
* @param key The name of the model
|
|
534
|
+
* @returns The GroupVersionKind for the model
|
|
535
|
+
*/
|
|
483
536
|
function modelToGroupVersionKind(key) {
|
|
484
537
|
return gvkMap[key];
|
|
485
538
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare class GenericKind implements KubernetesObject {
|
|
|
15
15
|
/**
|
|
16
16
|
* GroupVersionKind unambiguously identifies a kind. It doesn't anonymously include GroupVersion
|
|
17
17
|
* to avoid automatic coercion. It doesn't use a GroupVersion to avoid custom marshalling
|
|
18
|
-
|
|
18
|
+
*/
|
|
19
19
|
export interface GroupVersionKind {
|
|
20
20
|
/** The K8s resource kind, e..g "Pod". */
|
|
21
21
|
readonly kind: string;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAGjF,MAAM,MAAM,YAAY,GAAG,QAAQ,WAAW,GAAG,CAAC;AAElD;;;;GAIG;AACH,qBAAa,WAAY,YAAW,gBAAgB;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,YAAY,CAAC;IAExB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAGjF,MAAM,MAAM,YAAY,GAAG,QAAQ,WAAW,GAAG,CAAC;AAElD;;;;GAIG;AACH,qBAAa,WAAY,YAAW,gBAAgB;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,YAAY,CAAC;IAExB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,yCAAyC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,KAAK;IAEpB,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IACjE,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IACrD,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;CACvC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kubernetes-fluent-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "A @kubernetes/client-node fluent API wrapper that leverages K8s Server Side Apply",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"build": "tsc",
|
|
10
10
|
"semantic-release": "semantic-release",
|
|
11
11
|
"test": "jest src --coverage",
|
|
12
|
-
"format:check": "eslint && prettier . --check",
|
|
13
|
-
"format:fix": "eslint --fix && prettier . --write"
|
|
12
|
+
"format:check": "eslint src && prettier . --check",
|
|
13
|
+
"format:fix": "eslint --fix src && prettier . --write"
|
|
14
14
|
},
|
|
15
15
|
"engines": {
|
|
16
16
|
"node": ">=18.0.0"
|
|
@@ -46,8 +46,9 @@
|
|
|
46
46
|
"@commitlint/config-conventional": "17.7.0",
|
|
47
47
|
"@jest/globals": "29.7.0",
|
|
48
48
|
"@types/byline": "4.2.34",
|
|
49
|
-
"@typescript-eslint/eslint-plugin": "6.7.
|
|
50
|
-
"@typescript-eslint/parser": "6.7.
|
|
49
|
+
"@typescript-eslint/eslint-plugin": "6.7.4",
|
|
50
|
+
"@typescript-eslint/parser": "6.7.4",
|
|
51
|
+
"eslint-plugin-jsdoc": "46.8.2",
|
|
51
52
|
"jest": "29.7.0",
|
|
52
53
|
"nock": "13.3.3",
|
|
53
54
|
"prettier": "3.0.3",
|
package/src/fetch.ts
CHANGED
|
@@ -22,7 +22,7 @@ export type FetchResponse<T> = {
|
|
|
22
22
|
*
|
|
23
23
|
* @param url The URL or Request object to fetch
|
|
24
24
|
* @param init Additional options for the request
|
|
25
|
-
* @returns
|
|
25
|
+
* @returns The parsed JSON response
|
|
26
26
|
*/
|
|
27
27
|
export async function fetch<T>(
|
|
28
28
|
url: URL | RequestInfo,
|
package/src/fluent/index.test.ts
CHANGED
|
@@ -8,8 +8,50 @@ import { k8sExec } from "./utils";
|
|
|
8
8
|
// Setup mocks
|
|
9
9
|
jest.mock("./utils");
|
|
10
10
|
|
|
11
|
+
const generateFakePodManagedFields = (manager: string) => {
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
apiVersion: "v1",
|
|
15
|
+
fieldsType: "FieldsV1",
|
|
16
|
+
fieldsV1: {
|
|
17
|
+
"f:metadata": {
|
|
18
|
+
"f:labels": {
|
|
19
|
+
"f:fake": {},
|
|
20
|
+
},
|
|
21
|
+
"f:spec": {
|
|
22
|
+
"f:containers": {
|
|
23
|
+
'k:{"name":"fake"}': {
|
|
24
|
+
"f:image": {},
|
|
25
|
+
"f:name": {},
|
|
26
|
+
"f:resources": {
|
|
27
|
+
"f:limits": {
|
|
28
|
+
"f:cpu": {},
|
|
29
|
+
"f:memory": {},
|
|
30
|
+
},
|
|
31
|
+
"f:requests": {
|
|
32
|
+
"f:cpu": {},
|
|
33
|
+
"f:memory": {},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
manager: manager,
|
|
42
|
+
operation: "Apply",
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
};
|
|
11
46
|
describe("Kube", () => {
|
|
12
|
-
const fakeResource = {
|
|
47
|
+
const fakeResource = {
|
|
48
|
+
metadata: {
|
|
49
|
+
name: "fake",
|
|
50
|
+
namespace: "default",
|
|
51
|
+
managedFields: generateFakePodManagedFields("pepr"),
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
13
55
|
const mockedKubeExec = jest.mocked(k8sExec).mockResolvedValue(fakeResource);
|
|
14
56
|
|
|
15
57
|
beforeEach(() => {
|
|
@@ -140,6 +182,18 @@ describe("Kube", () => {
|
|
|
140
182
|
expect(result).toEqual(fakeResource);
|
|
141
183
|
});
|
|
142
184
|
|
|
185
|
+
it("should allow force apply to resolve FieldManagerConflict", async () => {
|
|
186
|
+
const kube = K8s(Pod);
|
|
187
|
+
const result = await kube.Apply(
|
|
188
|
+
{
|
|
189
|
+
metadata: { name: "fake", managedFields: generateFakePodManagedFields("kubectl") },
|
|
190
|
+
spec: { priority: 3 },
|
|
191
|
+
},
|
|
192
|
+
{ force: true },
|
|
193
|
+
);
|
|
194
|
+
expect(result).toEqual(fakeResource);
|
|
195
|
+
});
|
|
196
|
+
|
|
143
197
|
it("should throw an error if a Delete failed for a reason other than Not Found", async () => {
|
|
144
198
|
mockedKubeExec.mockRejectedValueOnce({ status: 500 }); // Internal Server Error on first call
|
|
145
199
|
const kube = K8s(Pod);
|
package/src/fluent/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { PartialDeep } from "type-fest";
|
|
|
8
8
|
|
|
9
9
|
import { modelToGroupVersionKind } from "../kinds";
|
|
10
10
|
import { GenericClass } from "../types";
|
|
11
|
+
import { ApplyCfg } from "./apply";
|
|
11
12
|
import { Filters, K8sInit, Paths, WatchAction } from "./types";
|
|
12
13
|
import { k8sExec } from "./utils";
|
|
13
14
|
import { ExecWatch, WatchCfg } from "./watch";
|
|
@@ -17,6 +18,7 @@ import { ExecWatch, WatchCfg } from "./watch";
|
|
|
17
18
|
*
|
|
18
19
|
* @param model - the model to use for the API
|
|
19
20
|
* @param filters - (optional) filter overrides, can also be chained
|
|
21
|
+
* @returns a fluent API for the model
|
|
20
22
|
*/
|
|
21
23
|
export function K8s<T extends GenericClass, K extends KubernetesObject = InstanceType<T>>(
|
|
22
24
|
model: T,
|
|
@@ -25,27 +27,44 @@ export function K8s<T extends GenericClass, K extends KubernetesObject = Instanc
|
|
|
25
27
|
const withFilters = { WithField, WithLabel, Get, Delete, Watch };
|
|
26
28
|
const matchedKind = filters.kindOverride || modelToGroupVersionKind(model.name);
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
/**
|
|
31
|
+
* @inheritdoc
|
|
32
|
+
* @see {@link K8sInit.InNamespace}
|
|
33
|
+
*/
|
|
34
|
+
function InNamespace(namespace: string) {
|
|
29
35
|
if (filters.namespace) {
|
|
30
36
|
throw new Error(`Namespace already specified: ${filters.namespace}`);
|
|
31
37
|
}
|
|
32
38
|
|
|
33
|
-
filters.namespace =
|
|
39
|
+
filters.namespace = namespace;
|
|
34
40
|
return withFilters;
|
|
35
41
|
}
|
|
36
42
|
|
|
43
|
+
/**
|
|
44
|
+
* @inheritdoc
|
|
45
|
+
* @see {@link K8sInit.WithField}
|
|
46
|
+
*/
|
|
37
47
|
function WithField<P extends Paths<K>>(key: P, value: string) {
|
|
38
48
|
filters.fields = filters.fields || {};
|
|
39
49
|
filters.fields[key] = value;
|
|
40
50
|
return withFilters;
|
|
41
51
|
}
|
|
42
52
|
|
|
53
|
+
/**
|
|
54
|
+
* @inheritdoc
|
|
55
|
+
* @see {@link K8sInit.WithLabel}
|
|
56
|
+
*/
|
|
43
57
|
function WithLabel(key: string, value: string) {
|
|
44
58
|
filters.labels = filters.labels || {};
|
|
45
59
|
filters.labels[key] = value;
|
|
46
60
|
return withFilters;
|
|
47
61
|
}
|
|
48
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Sync the filters with the provided payload.
|
|
65
|
+
*
|
|
66
|
+
* @param payload - the payload to sync with
|
|
67
|
+
*/
|
|
49
68
|
function syncFilters(payload: K) {
|
|
50
69
|
// Ensure the payload has metadata
|
|
51
70
|
payload.metadata = payload.metadata || {};
|
|
@@ -69,6 +88,10 @@ export function K8s<T extends GenericClass, K extends KubernetesObject = Instanc
|
|
|
69
88
|
|
|
70
89
|
async function Get(): Promise<KubernetesListObject<K>>;
|
|
71
90
|
async function Get(name: string): Promise<K>;
|
|
91
|
+
/**
|
|
92
|
+
* @inheritdoc
|
|
93
|
+
* @see {@link K8sInit.Get}
|
|
94
|
+
*/
|
|
72
95
|
async function Get(name?: string) {
|
|
73
96
|
if (name) {
|
|
74
97
|
if (filters.name) {
|
|
@@ -80,6 +103,10 @@ export function K8s<T extends GenericClass, K extends KubernetesObject = Instanc
|
|
|
80
103
|
return k8sExec<T, K | KubernetesListObject<K>>(model, filters, "GET");
|
|
81
104
|
}
|
|
82
105
|
|
|
106
|
+
/**
|
|
107
|
+
* @inheritdoc
|
|
108
|
+
* @see {@link K8sInit.Delete}
|
|
109
|
+
*/
|
|
83
110
|
async function Delete(filter?: K | string): Promise<void> {
|
|
84
111
|
if (typeof filter === "string") {
|
|
85
112
|
filters.name = filter;
|
|
@@ -100,16 +127,31 @@ export function K8s<T extends GenericClass, K extends KubernetesObject = Instanc
|
|
|
100
127
|
}
|
|
101
128
|
}
|
|
102
129
|
|
|
103
|
-
|
|
130
|
+
/**
|
|
131
|
+
* @inheritdoc
|
|
132
|
+
* @see {@link K8sInit.Apply}
|
|
133
|
+
*/
|
|
134
|
+
async function Apply(
|
|
135
|
+
resource: PartialDeep<K>,
|
|
136
|
+
applyCfg: ApplyCfg = { force: false },
|
|
137
|
+
): Promise<K> {
|
|
104
138
|
syncFilters(resource as K);
|
|
105
|
-
return k8sExec(model, filters, "APPLY", resource);
|
|
139
|
+
return k8sExec(model, filters, "APPLY", resource, applyCfg);
|
|
106
140
|
}
|
|
107
141
|
|
|
142
|
+
/**
|
|
143
|
+
* @inheritdoc
|
|
144
|
+
* @see {@link K8sInit.Create}
|
|
145
|
+
*/
|
|
108
146
|
async function Create(resource: K): Promise<K> {
|
|
109
147
|
syncFilters(resource);
|
|
110
148
|
return k8sExec(model, filters, "POST", resource);
|
|
111
149
|
}
|
|
112
150
|
|
|
151
|
+
/**
|
|
152
|
+
* @inheritdoc
|
|
153
|
+
* @see {@link K8sInit.Patch}
|
|
154
|
+
*/
|
|
113
155
|
async function Patch(payload: Operation[]): Promise<K> {
|
|
114
156
|
// If there are no operations, throw an error
|
|
115
157
|
if (payload.length < 1) {
|
|
@@ -119,6 +161,10 @@ export function K8s<T extends GenericClass, K extends KubernetesObject = Instanc
|
|
|
119
161
|
return k8sExec<T, K>(model, filters, "PATCH", payload);
|
|
120
162
|
}
|
|
121
163
|
|
|
164
|
+
/**
|
|
165
|
+
* @inheritdoc
|
|
166
|
+
* @see {@link K8sInit.Watch}
|
|
167
|
+
*/
|
|
122
168
|
async function Watch(callback: WatchAction<T>, watchCfg?: WatchCfg) {
|
|
123
169
|
return ExecWatch(model, filters, callback, watchCfg);
|
|
124
170
|
}
|