kubernetes-fluent-client 3.4.10 → 3.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fluent/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAwB,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAOjF,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAA0B,OAAO,EAAE,OAAO,EAAsB,MAAM,SAAS,CAAC;AAKvF;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,YAAY,EAAE,CAAC,SAAS,gBAAgB,GAAG,YAAY,CAAC,CAAC,CAAC,EACtF,KAAK,EAAE,CAAC,EACR,OAAO,GAAE,OAAY,GACpB,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CA0Pf"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fluent/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAwB,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAOjF,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAA0B,OAAO,EAAE,OAAO,EAAsB,MAAM,SAAS,CAAC;AAKvF;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,YAAY,EAAE,CAAC,SAAS,gBAAgB,GAAG,YAAY,CAAC,CAAC,CAAC,EACtF,KAAK,EAAE,CAAC,EACR,OAAO,GAAE,OAAY,GACpB,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAyRf"}
@@ -18,7 +18,7 @@ const upstream_1 = require("../upstream");
18
18
  * @returns a fluent API for the model
19
19
  */
20
20
  function K8s(model, filters = {}) {
21
- const withFilters = { WithField, WithLabel, Get, Delete, Watch, Logs };
21
+ const withFilters = { WithField, WithLabel, Get, Delete, Evict, Watch, Logs };
22
22
  const matchedKind = filters.kindOverride || (0, kinds_1.modelToGroupVersionKind)(model.name);
23
23
  /**
24
24
  * @inheritdoc
@@ -185,6 +185,37 @@ function K8s(model, filters = {}) {
185
185
  syncFilters(resource);
186
186
  return (0, utils_1.k8sExec)(model, filters, "POST", resource);
187
187
  }
188
+ /**
189
+ * @inheritdoc
190
+ * @see {@link K8sInit.Evict}
191
+ */
192
+ async function Evict(filter) {
193
+ if (typeof filter === "string") {
194
+ filters.name = filter;
195
+ }
196
+ else if (filter) {
197
+ syncFilters(filter);
198
+ }
199
+ try {
200
+ const evictionPayload = {
201
+ apiVersion: "policy/v1",
202
+ kind: "Eviction",
203
+ metadata: {
204
+ name: filters.name,
205
+ namespace: filters.namespace,
206
+ },
207
+ };
208
+ // Try to evict the resource
209
+ await (0, utils_1.k8sExec)(model, filters, "POST", evictionPayload);
210
+ }
211
+ catch (e) {
212
+ // If the resource doesn't exist, ignore the error
213
+ if (e.status === http_status_codes_1.StatusCodes.NOT_FOUND) {
214
+ return;
215
+ }
216
+ throw e;
217
+ }
218
+ }
188
219
  /**
189
220
  * @inheritdoc
190
221
  * @see {@link K8sInit.Patch}
@@ -36,7 +36,7 @@ export declare enum WatchPhase {
36
36
  Bookmark = "BOOKMARK",
37
37
  Error = "ERROR"
38
38
  }
39
- export type FetchMethods = "GET" | "APPLY" | "POST" | "PUT" | "DELETE" | "PATCH" | "WATCH" | "PATCH_STATUS" | "LOG";
39
+ export type FetchMethods = "APPLY" | "DELETE" | "GET" | "LOG" | "PATCH" | "PATCH_STATUS" | "POST" | "PUT" | "WATCH";
40
40
  export interface Filters {
41
41
  kindOverride?: GroupVersionKind;
42
42
  fields?: Record<string, string>;
@@ -76,6 +76,12 @@ export type K8sFilteredActions<T extends GenericClass, K extends KubernetesObjec
76
76
  * @param filter - the resource or resource name to delete
77
77
  */
78
78
  Delete: (filter?: K | string) => Promise<void>;
79
+ /**
80
+ * Evict the resource matching the filters.
81
+ *
82
+ * @param filter - the resource or resource name to evict
83
+ */
84
+ Evict: (filter?: K | string) => Promise<void>;
79
85
  /**
80
86
  * Watch the resource matching the filters.
81
87
  *
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/fluent/types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,0BAA0B,EAAE,MAAM,OAAO,CAAC;AAKnD,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,YAAY,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAC,CAAC;AAEvF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,IAAI,CAC7B,0BAA0B,EAC1B,IAAI,GAAG,MAAM,GAAG,KAAK,GAAG,oBAAoB,CAC7C,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,KAAK,CAAC,EAAE,KAAK,CAAC,KAAK,GAAG;QAAE,OAAO,CAAC,EAAE,YAAY,CAAA;KAAE,CAAC;CAClD;AAED;;GAEG;AACH,oBAAY,UAAU;IACpB,KAAK,UAAU;IACf,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,KAAK,UAAU;CAChB;AAED,MA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AAI,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAkBvF;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS,CAqBvE;AACD;;;;GAIG;AACH,wBAAsB,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAMvD;AACD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,YAAY,EAChD,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,OAAO,EAChB,WAAW,UAAQ,OAwDpB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,gBAAgB,CA+BnE;AASD;;;;;;;;;;GAUG;AACH,wBAAsB,OAAO,CAAC,CAAC,SAAS,YAAY,EAAE,CAAC,EACrD,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE,CAAC,GAAG,OAAO,EACrB,QAAQ,GAAE,QAA2B,cA+DtC"}
@@ -169,6 +169,11 @@ async function k8sCfg(method) {
169
169
  };
170
170
  return { opts: undiciRequestUnit, serverUrl: cluster.server };
171
171
  }
172
+ const isEvictionPayload = (payload) => payload !== null &&
173
+ payload !== undefined &&
174
+ typeof payload === "object" &&
175
+ "kind" in payload &&
176
+ payload.kind === "Eviction";
172
177
  /**
173
178
  * Execute a request against the Kubernetes API server.
174
179
  *
@@ -184,9 +189,14 @@ async function k8sExec(model, filters, method, payload, applyCfg = { force: fals
184
189
  const reconstruct = async (method) => {
185
190
  const configMethod = method === "LOG" ? "GET" : method;
186
191
  const { opts, serverUrl } = await k8sCfg(configMethod);
187
- const isPost = method === "POST";
188
- const baseUrl = pathBuilder(serverUrl.toString(), model, filters, isPost);
189
- if (method === "LOG") {
192
+ // Build the base path once, using excludeName only for standard POST requests
193
+ const shouldExcludeName = method === "POST" && !(payload && isEvictionPayload(payload));
194
+ const baseUrl = pathBuilder(serverUrl.toString(), model, filters, shouldExcludeName);
195
+ // Append appropriate subresource paths
196
+ if (payload && isEvictionPayload(payload)) {
197
+ baseUrl.pathname = `${baseUrl.pathname}/eviction`;
198
+ }
199
+ else if (method === "LOG") {
190
200
  baseUrl.pathname = `${baseUrl.pathname}/log`;
191
201
  }
192
202
  return {
@@ -1,4 +1,4 @@
1
1
  /** a is a collection of K8s types to be used within an action: `When(a.Configmap)` */
2
- export { CoreV1Event as CoreEvent, EventsV1Event as Event, V1APIService as APIService, V1CertificateSigningRequest as CertificateSigningRequest, V1ClusterRole as ClusterRole, V1ClusterRoleBinding as ClusterRoleBinding, V1ConfigMap as ConfigMap, V1ControllerRevision as ControllerRevision, V1CronJob as CronJob, V1CSIDriver as CSIDriver, V1CustomResourceDefinition as CustomResourceDefinition, V1DaemonSet as DaemonSet, V1Deployment as Deployment, V1EndpointSlice as EndpointSlice, V1HorizontalPodAutoscaler as HorizontalPodAutoscaler, V1Ingress as Ingress, V1IngressClass as IngressClass, V1Job as Job, V1LimitRange as LimitRange, V1LocalSubjectAccessReview as LocalSubjectAccessReview, V1MutatingWebhookConfiguration as MutatingWebhookConfiguration, V1Namespace as Namespace, V1NetworkPolicy as NetworkPolicy, V1Node as Node, V1PersistentVolume as PersistentVolume, V1PersistentVolumeClaim as PersistentVolumeClaim, V1Pod as Pod, V1PodDisruptionBudget as PodDisruptionBudget, V1PodTemplate as PodTemplate, V1ReplicaSet as ReplicaSet, V1ReplicationController as ReplicationController, V1ResourceQuota as ResourceQuota, V1Role as Role, V1RoleBinding as RoleBinding, V1RuntimeClass as RuntimeClass, V1Secret as Secret, V1SelfSubjectAccessReview as SelfSubjectAccessReview, V1SelfSubjectRulesReview as SelfSubjectRulesReview, V1Service as Service, V1ServiceAccount as ServiceAccount, V1StatefulSet as StatefulSet, V1StorageClass as StorageClass, V1SubjectAccessReview as SubjectAccessReview, V1TokenReview as TokenReview, V1ValidatingWebhookConfiguration as ValidatingWebhookConfiguration, V1VolumeAttachment as VolumeAttachment, V1Endpoints as Endpoints, } from "@kubernetes/client-node";
2
+ export { CoreV1Event as CoreEvent, EventsV1Event as Event, V1APIService as APIService, V1CSIDriver as CSIDriver, V1CertificateSigningRequest as CertificateSigningRequest, V1ClusterRole as ClusterRole, V1ClusterRoleBinding as ClusterRoleBinding, V1ConfigMap as ConfigMap, V1ControllerRevision as ControllerRevision, V1CronJob as CronJob, V1CustomResourceDefinition as CustomResourceDefinition, V1DaemonSet as DaemonSet, V1Deployment as Deployment, V1EndpointSlice as EndpointSlice, V1Endpoints as Endpoints, V1HorizontalPodAutoscaler as HorizontalPodAutoscaler, V1Ingress as Ingress, V1IngressClass as IngressClass, V1Job as Job, V1LimitRange as LimitRange, V1LocalSubjectAccessReview as LocalSubjectAccessReview, V1MutatingWebhookConfiguration as MutatingWebhookConfiguration, V1Namespace as Namespace, V1NetworkPolicy as NetworkPolicy, V1Node as Node, V1PersistentVolume as PersistentVolume, V1PersistentVolumeClaim as PersistentVolumeClaim, V1Pod as Pod, V1PodDisruptionBudget as PodDisruptionBudget, V1PodTemplate as PodTemplate, V1ReplicaSet as ReplicaSet, V1ReplicationController as ReplicationController, V1ResourceQuota as ResourceQuota, V1Role as Role, V1RoleBinding as RoleBinding, V1RuntimeClass as RuntimeClass, V1Secret as Secret, V1SelfSubjectAccessReview as SelfSubjectAccessReview, V1SelfSubjectRulesReview as SelfSubjectRulesReview, V1Service as Service, V1ServiceAccount as ServiceAccount, V1StatefulSet as StatefulSet, V1StorageClass as StorageClass, V1SubjectAccessReview as SubjectAccessReview, V1TokenReview as TokenReview, V1ValidatingWebhookConfiguration as ValidatingWebhookConfiguration, V1VolumeAttachment as VolumeAttachment, } from "@kubernetes/client-node";
3
3
  export { GenericKind } from "./types";
4
4
  //# sourceMappingURL=upstream.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"upstream.d.ts","sourceRoot":"","sources":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AAsB,EAClD,SAAS,IAAI,OAAO,EACpB,gBAAgB,IAAI,cAAc,EAClC,aAAa,IAAI,WAAW,EAC5B,cAAc,IAAI,YAAY,EAC9B,qBAAqB,IAAI,mBAAmB,EAC5C,aAAa,IAAI,WAAW,EAC5B,gCAAgC,IAAI,8BAA8B,EAClE,kBAAkB,IAAI,gBAAgB,GACvC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
package/dist/upstream.js CHANGED
@@ -2,23 +2,24 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  // SPDX-FileCopyrightText: 2023-Present The Kubernetes Fluent Client Authors
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.GenericKind = exports.Endpoints = exports.VolumeAttachment = exports.ValidatingWebhookConfiguration = exports.TokenReview = exports.SubjectAccessReview = exports.StorageClass = exports.StatefulSet = exports.ServiceAccount = exports.Service = exports.SelfSubjectRulesReview = exports.SelfSubjectAccessReview = exports.Secret = exports.RuntimeClass = exports.RoleBinding = exports.Role = exports.ResourceQuota = exports.ReplicationController = exports.ReplicaSet = exports.PodTemplate = exports.PodDisruptionBudget = exports.Pod = exports.PersistentVolumeClaim = exports.PersistentVolume = exports.Node = exports.NetworkPolicy = exports.Namespace = exports.MutatingWebhookConfiguration = exports.LocalSubjectAccessReview = exports.LimitRange = exports.Job = exports.IngressClass = exports.Ingress = exports.HorizontalPodAutoscaler = exports.EndpointSlice = exports.Deployment = exports.DaemonSet = exports.CustomResourceDefinition = exports.CSIDriver = exports.CronJob = exports.ControllerRevision = exports.ConfigMap = exports.ClusterRoleBinding = exports.ClusterRole = exports.CertificateSigningRequest = exports.APIService = exports.Event = exports.CoreEvent = void 0;
5
+ exports.GenericKind = exports.VolumeAttachment = exports.ValidatingWebhookConfiguration = exports.TokenReview = exports.SubjectAccessReview = exports.StorageClass = exports.StatefulSet = exports.ServiceAccount = exports.Service = exports.SelfSubjectRulesReview = exports.SelfSubjectAccessReview = exports.Secret = exports.RuntimeClass = exports.RoleBinding = exports.Role = exports.ResourceQuota = exports.ReplicationController = exports.ReplicaSet = exports.PodTemplate = exports.PodDisruptionBudget = exports.Pod = exports.PersistentVolumeClaim = exports.PersistentVolume = exports.Node = exports.NetworkPolicy = exports.Namespace = exports.MutatingWebhookConfiguration = exports.LocalSubjectAccessReview = exports.LimitRange = exports.Job = exports.IngressClass = exports.Ingress = exports.HorizontalPodAutoscaler = exports.Endpoints = exports.EndpointSlice = exports.Deployment = exports.DaemonSet = exports.CustomResourceDefinition = exports.CronJob = exports.ControllerRevision = exports.ConfigMap = exports.ClusterRoleBinding = exports.ClusterRole = exports.CertificateSigningRequest = exports.CSIDriver = exports.APIService = exports.Event = exports.CoreEvent = void 0;
6
6
  /** a is a collection of K8s types to be used within an action: `When(a.Configmap)` */
7
7
  var client_node_1 = require("@kubernetes/client-node");
8
8
  Object.defineProperty(exports, "CoreEvent", { enumerable: true, get: function () { return client_node_1.CoreV1Event; } });
9
9
  Object.defineProperty(exports, "Event", { enumerable: true, get: function () { return client_node_1.EventsV1Event; } });
10
10
  Object.defineProperty(exports, "APIService", { enumerable: true, get: function () { return client_node_1.V1APIService; } });
11
+ Object.defineProperty(exports, "CSIDriver", { enumerable: true, get: function () { return client_node_1.V1CSIDriver; } });
11
12
  Object.defineProperty(exports, "CertificateSigningRequest", { enumerable: true, get: function () { return client_node_1.V1CertificateSigningRequest; } });
12
13
  Object.defineProperty(exports, "ClusterRole", { enumerable: true, get: function () { return client_node_1.V1ClusterRole; } });
13
14
  Object.defineProperty(exports, "ClusterRoleBinding", { enumerable: true, get: function () { return client_node_1.V1ClusterRoleBinding; } });
14
15
  Object.defineProperty(exports, "ConfigMap", { enumerable: true, get: function () { return client_node_1.V1ConfigMap; } });
15
16
  Object.defineProperty(exports, "ControllerRevision", { enumerable: true, get: function () { return client_node_1.V1ControllerRevision; } });
16
17
  Object.defineProperty(exports, "CronJob", { enumerable: true, get: function () { return client_node_1.V1CronJob; } });
17
- Object.defineProperty(exports, "CSIDriver", { enumerable: true, get: function () { return client_node_1.V1CSIDriver; } });
18
18
  Object.defineProperty(exports, "CustomResourceDefinition", { enumerable: true, get: function () { return client_node_1.V1CustomResourceDefinition; } });
19
19
  Object.defineProperty(exports, "DaemonSet", { enumerable: true, get: function () { return client_node_1.V1DaemonSet; } });
20
20
  Object.defineProperty(exports, "Deployment", { enumerable: true, get: function () { return client_node_1.V1Deployment; } });
21
21
  Object.defineProperty(exports, "EndpointSlice", { enumerable: true, get: function () { return client_node_1.V1EndpointSlice; } });
22
+ Object.defineProperty(exports, "Endpoints", { enumerable: true, get: function () { return client_node_1.V1Endpoints; } });
22
23
  Object.defineProperty(exports, "HorizontalPodAutoscaler", { enumerable: true, get: function () { return client_node_1.V1HorizontalPodAutoscaler; } });
23
24
  Object.defineProperty(exports, "Ingress", { enumerable: true, get: function () { return client_node_1.V1Ingress; } });
24
25
  Object.defineProperty(exports, "IngressClass", { enumerable: true, get: function () { return client_node_1.V1IngressClass; } });
@@ -51,6 +52,5 @@ Object.defineProperty(exports, "SubjectAccessReview", { enumerable: true, get: f
51
52
  Object.defineProperty(exports, "TokenReview", { enumerable: true, get: function () { return client_node_1.V1TokenReview; } });
52
53
  Object.defineProperty(exports, "ValidatingWebhookConfiguration", { enumerable: true, get: function () { return client_node_1.V1ValidatingWebhookConfiguration; } });
53
54
  Object.defineProperty(exports, "VolumeAttachment", { enumerable: true, get: function () { return client_node_1.V1VolumeAttachment; } });
54
- Object.defineProperty(exports, "Endpoints", { enumerable: true, get: function () { return client_node_1.V1Endpoints; } });
55
55
  var types_1 = require("./types");
56
56
  Object.defineProperty(exports, "GenericKind", { enumerable: true, get: function () { return types_1.GenericKind; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kubernetes-fluent-client",
3
- "version": "3.4.10",
3
+ "version": "3.5.1",
4
4
  "description": "A @kubernetes/client-node fluent API wrapper that leverages K8s Server Side Apply.",
5
5
  "bin": "./dist/cli.js",
6
6
  "main": "dist/index.js",
@@ -68,8 +68,8 @@
68
68
  "@types/readable-stream": "4.0.18",
69
69
  "@types/urijs": "^1.19.25",
70
70
  "@types/yargs": "17.0.33",
71
- "@typescript-eslint/eslint-plugin": "8.29.1",
72
- "@typescript-eslint/parser": "8.29.1",
71
+ "@typescript-eslint/eslint-plugin": "8.30.1",
72
+ "@typescript-eslint/parser": "8.30.1",
73
73
  "eslint-plugin-jsdoc": "50.6.9",
74
74
  "globals": "^16.0.0",
75
75
  "husky": "^9.1.6",
@@ -77,7 +77,7 @@
77
77
  "lint-staged": "^15.2.10",
78
78
  "prettier": "3.5.3",
79
79
  "semantic-release": "24.2.3",
80
- "ts-jest": "29.3.1",
80
+ "ts-jest": "29.3.2",
81
81
  "typescript": "5.8.3"
82
82
  },
83
83
  "overrides": {
@@ -25,7 +25,7 @@ export function K8s<T extends GenericClass, K extends KubernetesObject = Instanc
25
25
  model: T,
26
26
  filters: Filters = {},
27
27
  ): K8sInit<T, K> {
28
- const withFilters = { WithField, WithLabel, Get, Delete, Watch, Logs };
28
+ const withFilters = { WithField, WithLabel, Get, Delete, Evict, Watch, Logs };
29
29
  const matchedKind = filters.kindOverride || modelToGroupVersionKind(model.name);
30
30
 
31
31
  /**
@@ -227,6 +227,37 @@ export function K8s<T extends GenericClass, K extends KubernetesObject = Instanc
227
227
  return k8sExec(model, filters, "POST", resource);
228
228
  }
229
229
 
230
+ /**
231
+ * @inheritdoc
232
+ * @see {@link K8sInit.Evict}
233
+ */
234
+ async function Evict(filter?: K | string): Promise<void> {
235
+ if (typeof filter === "string") {
236
+ filters.name = filter;
237
+ } else if (filter) {
238
+ syncFilters(filter);
239
+ }
240
+
241
+ try {
242
+ const evictionPayload = {
243
+ apiVersion: "policy/v1",
244
+ kind: "Eviction",
245
+ metadata: {
246
+ name: filters.name,
247
+ namespace: filters.namespace,
248
+ },
249
+ };
250
+ // Try to evict the resource
251
+ await k8sExec<T, void>(model, filters, "POST", evictionPayload);
252
+ } catch (e) {
253
+ // If the resource doesn't exist, ignore the error
254
+ if (e.status === StatusCodes.NOT_FOUND) {
255
+ return;
256
+ }
257
+ throw e;
258
+ }
259
+ }
260
+
230
261
  /**
231
262
  * @inheritdoc
232
263
  * @see {@link K8sInit.Patch}
@@ -47,15 +47,15 @@ export enum WatchPhase {
47
47
  }
48
48
 
49
49
  export type FetchMethods =
50
- | "GET"
51
50
  | "APPLY"
52
- | "POST"
53
- | "PUT"
54
51
  | "DELETE"
52
+ | "GET"
53
+ | "LOG"
55
54
  | "PATCH"
56
- | "WATCH"
57
55
  | "PATCH_STATUS"
58
- | "LOG";
56
+ | "POST"
57
+ | "PUT"
58
+ | "WATCH";
59
59
 
60
60
  export interface Filters {
61
61
  kindOverride?: GroupVersionKind;
@@ -100,6 +100,13 @@ export type K8sFilteredActions<T extends GenericClass, K extends KubernetesObjec
100
100
  */
101
101
  Delete: (filter?: K | string) => Promise<void>;
102
102
 
103
+ /**
104
+ * Evict the resource matching the filters.
105
+ *
106
+ * @param filter - the resource or resource name to evict
107
+ */
108
+ Evict: (filter?: K | string) => Promise<void>;
109
+
103
110
  /**
104
111
  * Watch the resource matching the filters.
105
112
  *
@@ -11,7 +11,7 @@ import { modelToGroupVersionKind } from "../kinds";
11
11
  import { GenericClass } from "../types";
12
12
  import { ApplyCfg, FetchMethods, Filters, K8sConfigPromise } from "./types";
13
13
  import fs from "fs";
14
-
14
+ import { V1Eviction as Eviction } from "@kubernetes/client-node";
15
15
  const SSA_CONTENT_TYPE = "application/apply-patch+yaml";
16
16
  const K8S_SA_TOKEN_PATH = "/var/run/secrets/kubernetes.io/serviceaccount/token";
17
17
 
@@ -196,6 +196,13 @@ export async function k8sCfg(method: FetchMethods): K8sConfigPromise {
196
196
  return { opts: undiciRequestUnit, serverUrl: cluster.server };
197
197
  }
198
198
 
199
+ const isEvictionPayload = (payload: unknown): payload is Eviction =>
200
+ payload !== null &&
201
+ payload !== undefined &&
202
+ typeof payload === "object" &&
203
+ "kind" in payload &&
204
+ (payload as { kind: string }).kind === "Eviction";
205
+
199
206
  /**
200
207
  * Execute a request against the Kubernetes API server.
201
208
  *
@@ -217,11 +224,18 @@ export async function k8sExec<T extends GenericClass, K>(
217
224
  const reconstruct = async (method: FetchMethods): K8sConfigPromise => {
218
225
  const configMethod = method === "LOG" ? "GET" : method;
219
226
  const { opts, serverUrl } = await k8sCfg(configMethod);
220
- const isPost = method === "POST";
221
- const baseUrl = pathBuilder(serverUrl.toString(), model, filters, isPost);
222
- if (method === "LOG") {
227
+
228
+ // Build the base path once, using excludeName only for standard POST requests
229
+ const shouldExcludeName = method === "POST" && !(payload && isEvictionPayload(payload));
230
+ const baseUrl = pathBuilder(serverUrl.toString(), model, filters, shouldExcludeName);
231
+
232
+ // Append appropriate subresource paths
233
+ if (payload && isEvictionPayload(payload)) {
234
+ baseUrl.pathname = `${baseUrl.pathname}/eviction`;
235
+ } else if (method === "LOG") {
223
236
  baseUrl.pathname = `${baseUrl.pathname}/log`;
224
237
  }
238
+
225
239
  return {
226
240
  serverUrl: baseUrl,
227
241
  opts,
@@ -256,7 +270,6 @@ export async function k8sExec<T extends GenericClass, K>(
256
270
  if (payload) {
257
271
  opts.body = JSON.stringify(payload);
258
272
  }
259
-
260
273
  const resp = await fetch<K>(url, opts);
261
274
 
262
275
  if (resp.ok) {
package/src/upstream.ts CHANGED
@@ -6,17 +6,18 @@ export {
6
6
  CoreV1Event as CoreEvent,
7
7
  EventsV1Event as Event,
8
8
  V1APIService as APIService,
9
+ V1CSIDriver as CSIDriver,
9
10
  V1CertificateSigningRequest as CertificateSigningRequest,
10
11
  V1ClusterRole as ClusterRole,
11
12
  V1ClusterRoleBinding as ClusterRoleBinding,
12
13
  V1ConfigMap as ConfigMap,
13
14
  V1ControllerRevision as ControllerRevision,
14
15
  V1CronJob as CronJob,
15
- V1CSIDriver as CSIDriver,
16
16
  V1CustomResourceDefinition as CustomResourceDefinition,
17
17
  V1DaemonSet as DaemonSet,
18
18
  V1Deployment as Deployment,
19
19
  V1EndpointSlice as EndpointSlice,
20
+ V1Endpoints as Endpoints,
20
21
  V1HorizontalPodAutoscaler as HorizontalPodAutoscaler,
21
22
  V1Ingress as Ingress,
22
23
  V1IngressClass as IngressClass,
@@ -49,6 +50,5 @@ export {
49
50
  V1TokenReview as TokenReview,
50
51
  V1ValidatingWebhookConfiguration as ValidatingWebhookConfiguration,
51
52
  V1VolumeAttachment as VolumeAttachment,
52
- V1Endpoints as Endpoints,
53
53
  } from "@kubernetes/client-node";
54
54
  export { GenericKind } from "./types";