mcp-server-kubernetes 1.6.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -22
- package/dist/config/container-templates.d.ts +2 -2
- package/dist/index.d.ts +314 -736
- package/dist/index.js +93 -200
- package/dist/models/resource-models.d.ts +6 -6
- package/dist/tools/kubectl-apply.d.ts +46 -0
- package/dist/tools/kubectl-apply.js +110 -0
- package/dist/tools/kubectl-context.d.ts +49 -0
- package/dist/tools/kubectl-context.js +233 -0
- package/dist/tools/kubectl-create.d.ts +150 -0
- package/dist/tools/kubectl-create.js +321 -0
- package/dist/tools/kubectl-delete.d.ts +77 -0
- package/dist/tools/kubectl-delete.js +177 -0
- package/dist/tools/kubectl-describe.d.ts +47 -0
- package/dist/tools/kubectl-describe.js +96 -0
- package/dist/tools/kubectl-generic.d.ts +71 -0
- package/dist/tools/kubectl-generic.js +121 -0
- package/dist/tools/kubectl-get.d.ts +72 -0
- package/dist/tools/kubectl-get.js +251 -0
- package/dist/tools/kubectl-list.d.ts +61 -0
- package/dist/tools/kubectl-list.js +189 -0
- package/dist/tools/{get_logs.d.ts → kubectl-logs.d.ts} +35 -19
- package/dist/tools/kubectl-logs.js +312 -0
- package/dist/tools/kubectl-patch.d.ts +57 -0
- package/dist/tools/kubectl-patch.js +128 -0
- package/dist/tools/kubectl-rollout.d.ts +67 -0
- package/dist/tools/kubectl-rollout.js +115 -0
- package/dist/tools/{scale_deployment.d.ts → kubectl-scale.d.ts} +13 -3
- package/dist/tools/kubectl-scale.js +73 -0
- package/dist/utils/kubernetes-manager.d.ts +4 -0
- package/dist/utils/kubernetes-manager.js +21 -3
- package/package.json +1 -1
- package/dist/tools/create_configmap.d.ts +0 -33
- package/dist/tools/create_configmap.js +0 -66
- package/dist/tools/create_cronjob.d.ts +0 -47
- package/dist/tools/create_cronjob.js +0 -93
- package/dist/tools/create_deployment.d.ts +0 -135
- package/dist/tools/create_deployment.js +0 -162
- package/dist/tools/create_namespace.d.ts +0 -22
- package/dist/tools/create_namespace.js +0 -48
- package/dist/tools/create_pod.d.ts +0 -130
- package/dist/tools/create_pod.js +0 -153
- package/dist/tools/create_service.d.ts +0 -74
- package/dist/tools/create_service.js +0 -102
- package/dist/tools/delete_configmap.d.ts +0 -26
- package/dist/tools/delete_configmap.js +0 -49
- package/dist/tools/delete_cronjob.d.ts +0 -26
- package/dist/tools/delete_cronjob.js +0 -48
- package/dist/tools/delete_deployment.d.ts +0 -31
- package/dist/tools/delete_deployment.js +0 -47
- package/dist/tools/delete_namespace.d.ts +0 -27
- package/dist/tools/delete_namespace.js +0 -44
- package/dist/tools/delete_pod.d.ts +0 -31
- package/dist/tools/delete_pod.js +0 -45
- package/dist/tools/delete_service.d.ts +0 -32
- package/dist/tools/delete_service.js +0 -46
- package/dist/tools/describe_cronjob.d.ts +0 -27
- package/dist/tools/describe_cronjob.js +0 -83
- package/dist/tools/describe_deployment.d.ts +0 -26
- package/dist/tools/describe_deployment.js +0 -40
- package/dist/tools/describe_node.d.ts +0 -22
- package/dist/tools/describe_node.js +0 -84
- package/dist/tools/describe_pod.d.ts +0 -33
- package/dist/tools/describe_pod.js +0 -81
- package/dist/tools/describe_service.d.ts +0 -34
- package/dist/tools/describe_service.js +0 -85
- package/dist/tools/get_configmap.d.ts +0 -27
- package/dist/tools/get_configmap.js +0 -48
- package/dist/tools/get_current_context.d.ts +0 -23
- package/dist/tools/get_current_context.js +0 -55
- package/dist/tools/get_events.d.ts +0 -28
- package/dist/tools/get_events.js +0 -66
- package/dist/tools/get_job_logs.d.ts +0 -40
- package/dist/tools/get_job_logs.js +0 -104
- package/dist/tools/get_logs.js +0 -150
- package/dist/tools/list_contexts.d.ts +0 -23
- package/dist/tools/list_contexts.js +0 -39
- package/dist/tools/list_cronjobs.d.ts +0 -23
- package/dist/tools/list_cronjobs.js +0 -35
- package/dist/tools/list_deployments.d.ts +0 -23
- package/dist/tools/list_deployments.js +0 -30
- package/dist/tools/list_jobs.d.ts +0 -29
- package/dist/tools/list_jobs.js +0 -77
- package/dist/tools/list_nodes.d.ts +0 -15
- package/dist/tools/list_nodes.js +0 -21
- package/dist/tools/list_pods.d.ts +0 -23
- package/dist/tools/list_pods.js +0 -29
- package/dist/tools/list_services.d.ts +0 -23
- package/dist/tools/list_services.js +0 -31
- package/dist/tools/scale_deployment.js +0 -50
- package/dist/tools/set_current_context.d.ts +0 -23
- package/dist/tools/set_current_context.js +0 -35
- package/dist/tools/update_configmap.d.ts +0 -33
- package/dist/tools/update_configmap.js +0 -71
- package/dist/tools/update_deployment.d.ts +0 -113
- package/dist/tools/update_deployment.js +0 -155
- package/dist/tools/update_service.d.ts +0 -72
- package/dist/tools/update_service.js +0 -125
package/dist/tools/create_pod.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
-
import { ContainerTemplate, containerTemplates, CustomContainerConfig, } from "../config/container-templates.js";
|
|
3
|
-
export const createPodSchema = {
|
|
4
|
-
name: "create_pod",
|
|
5
|
-
description: "Create a new Kubernetes pod",
|
|
6
|
-
inputSchema: {
|
|
7
|
-
type: "object",
|
|
8
|
-
properties: {
|
|
9
|
-
name: { type: "string" },
|
|
10
|
-
namespace: { type: "string" },
|
|
11
|
-
template: {
|
|
12
|
-
type: "string",
|
|
13
|
-
enum: ContainerTemplate.options,
|
|
14
|
-
},
|
|
15
|
-
command: {
|
|
16
|
-
type: "array",
|
|
17
|
-
items: { type: "string" },
|
|
18
|
-
optional: true,
|
|
19
|
-
},
|
|
20
|
-
customConfig: {
|
|
21
|
-
type: "object",
|
|
22
|
-
optional: true,
|
|
23
|
-
properties: {
|
|
24
|
-
image: { type: "string" },
|
|
25
|
-
command: { type: "array", items: { type: "string" } },
|
|
26
|
-
args: { type: "array", items: { type: "string" } },
|
|
27
|
-
ports: {
|
|
28
|
-
type: "array",
|
|
29
|
-
items: {
|
|
30
|
-
type: "object",
|
|
31
|
-
properties: {
|
|
32
|
-
containerPort: { type: "number" },
|
|
33
|
-
name: { type: "string" },
|
|
34
|
-
protocol: { type: "string" },
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
resources: {
|
|
39
|
-
type: "object",
|
|
40
|
-
properties: {
|
|
41
|
-
limits: {
|
|
42
|
-
type: "object",
|
|
43
|
-
additionalProperties: { type: "string" },
|
|
44
|
-
},
|
|
45
|
-
requests: {
|
|
46
|
-
type: "object",
|
|
47
|
-
additionalProperties: { type: "string" },
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
env: {
|
|
52
|
-
type: "array",
|
|
53
|
-
items: {
|
|
54
|
-
type: "object",
|
|
55
|
-
properties: {
|
|
56
|
-
name: { type: "string" },
|
|
57
|
-
value: { type: "string" },
|
|
58
|
-
valueFrom: { type: "object" },
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
volumeMounts: {
|
|
63
|
-
type: "array",
|
|
64
|
-
items: {
|
|
65
|
-
type: "object",
|
|
66
|
-
properties: {
|
|
67
|
-
name: { type: "string" },
|
|
68
|
-
mountPath: { type: "string" },
|
|
69
|
-
readOnly: { type: "boolean" },
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
required: ["name", "namespace", "template"],
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
export async function createPod(k8sManager, input) {
|
|
80
|
-
const templateConfig = containerTemplates[input.template];
|
|
81
|
-
// If using custom template, validate and merge custom config
|
|
82
|
-
let containerConfig;
|
|
83
|
-
if (input.template === "custom") {
|
|
84
|
-
if (!input.customConfig) {
|
|
85
|
-
throw new McpError(ErrorCode.InvalidRequest, "Custom container configuration is required when using 'custom' template");
|
|
86
|
-
}
|
|
87
|
-
// Validate custom config against schema
|
|
88
|
-
const validatedConfig = CustomContainerConfig.parse(input.customConfig);
|
|
89
|
-
// Create a new container config with all fields explicitly set
|
|
90
|
-
containerConfig = {
|
|
91
|
-
name: "main",
|
|
92
|
-
image: validatedConfig.image,
|
|
93
|
-
command: validatedConfig.command,
|
|
94
|
-
args: validatedConfig.args,
|
|
95
|
-
ports: validatedConfig.ports || [],
|
|
96
|
-
resources: validatedConfig.resources || {
|
|
97
|
-
limits: {},
|
|
98
|
-
requests: {},
|
|
99
|
-
},
|
|
100
|
-
env: validatedConfig.env || [],
|
|
101
|
-
volumeMounts: validatedConfig.volumeMounts || [],
|
|
102
|
-
livenessProbe: templateConfig.livenessProbe,
|
|
103
|
-
readinessProbe: templateConfig.readinessProbe,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
containerConfig = {
|
|
108
|
-
...templateConfig,
|
|
109
|
-
...(input.command && {
|
|
110
|
-
command: input.command,
|
|
111
|
-
args: undefined, // Clear default args when command is overridden
|
|
112
|
-
}),
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
const pod = {
|
|
116
|
-
apiVersion: "v1",
|
|
117
|
-
kind: "Pod",
|
|
118
|
-
metadata: {
|
|
119
|
-
name: input.name,
|
|
120
|
-
namespace: input.namespace,
|
|
121
|
-
labels: {
|
|
122
|
-
"mcp-managed": "true",
|
|
123
|
-
app: input.name,
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
spec: {
|
|
127
|
-
containers: [containerConfig],
|
|
128
|
-
},
|
|
129
|
-
};
|
|
130
|
-
const response = await k8sManager
|
|
131
|
-
.getCoreApi()
|
|
132
|
-
.createNamespacedPod(input.namespace, pod)
|
|
133
|
-
.catch((error) => {
|
|
134
|
-
console.error("Pod creation error:", {
|
|
135
|
-
status: error.response?.statusCode,
|
|
136
|
-
message: error.response?.body?.message || error.message,
|
|
137
|
-
details: error.response?.body,
|
|
138
|
-
});
|
|
139
|
-
throw error;
|
|
140
|
-
});
|
|
141
|
-
k8sManager.trackResource("Pod", input.name, input.namespace);
|
|
142
|
-
return {
|
|
143
|
-
content: [
|
|
144
|
-
{
|
|
145
|
-
type: "text",
|
|
146
|
-
text: JSON.stringify({
|
|
147
|
-
podName: response.body.metadata.name,
|
|
148
|
-
status: "created",
|
|
149
|
-
}, null, 2),
|
|
150
|
-
},
|
|
151
|
-
],
|
|
152
|
-
};
|
|
153
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { KubernetesManager } from "../types.js";
|
|
2
|
-
export declare const createServiceSchema: {
|
|
3
|
-
readonly name: "create_service";
|
|
4
|
-
readonly description: "Create a new Kubernetes service";
|
|
5
|
-
readonly inputSchema: {
|
|
6
|
-
readonly type: "object";
|
|
7
|
-
readonly properties: {
|
|
8
|
-
readonly name: {
|
|
9
|
-
readonly type: "string";
|
|
10
|
-
};
|
|
11
|
-
readonly namespace: {
|
|
12
|
-
readonly type: "string";
|
|
13
|
-
readonly default: "default";
|
|
14
|
-
};
|
|
15
|
-
readonly type: {
|
|
16
|
-
readonly type: "string";
|
|
17
|
-
readonly enum: readonly ["ClusterIP", "NodePort", "LoadBalancer"];
|
|
18
|
-
readonly default: "ClusterIP";
|
|
19
|
-
};
|
|
20
|
-
readonly selector: {
|
|
21
|
-
readonly type: "object";
|
|
22
|
-
readonly additionalProperties: {
|
|
23
|
-
readonly type: "string";
|
|
24
|
-
};
|
|
25
|
-
readonly default: {};
|
|
26
|
-
};
|
|
27
|
-
readonly ports: {
|
|
28
|
-
readonly type: "array";
|
|
29
|
-
readonly items: {
|
|
30
|
-
readonly type: "object";
|
|
31
|
-
readonly properties: {
|
|
32
|
-
readonly port: {
|
|
33
|
-
readonly type: "number";
|
|
34
|
-
};
|
|
35
|
-
readonly targetPort: {
|
|
36
|
-
readonly type: "number";
|
|
37
|
-
};
|
|
38
|
-
readonly protocol: {
|
|
39
|
-
readonly type: "string";
|
|
40
|
-
readonly enum: readonly ["TCP", "UDP"];
|
|
41
|
-
readonly default: "TCP";
|
|
42
|
-
};
|
|
43
|
-
readonly name: {
|
|
44
|
-
readonly type: "string";
|
|
45
|
-
};
|
|
46
|
-
readonly nodePort: {
|
|
47
|
-
readonly type: "number";
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
readonly required: readonly ["port"];
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
readonly required: readonly ["name", "ports"];
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
export declare function createService(k8sManager: KubernetesManager, input: {
|
|
58
|
-
name: string;
|
|
59
|
-
namespace?: string;
|
|
60
|
-
type?: "ClusterIP" | "NodePort" | "LoadBalancer";
|
|
61
|
-
selector?: Record<string, string>;
|
|
62
|
-
ports: Array<{
|
|
63
|
-
port: number;
|
|
64
|
-
targetPort?: number;
|
|
65
|
-
protocol?: string;
|
|
66
|
-
name?: string;
|
|
67
|
-
nodePort?: number;
|
|
68
|
-
}>;
|
|
69
|
-
}): Promise<{
|
|
70
|
-
content: {
|
|
71
|
-
type: string;
|
|
72
|
-
text: string;
|
|
73
|
-
}[];
|
|
74
|
-
}>;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
export const createServiceSchema = {
|
|
2
|
-
name: "create_service",
|
|
3
|
-
description: "Create a new Kubernetes service",
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object",
|
|
6
|
-
properties: {
|
|
7
|
-
name: { type: "string" },
|
|
8
|
-
namespace: { type: "string", default: "default" },
|
|
9
|
-
type: {
|
|
10
|
-
type: "string",
|
|
11
|
-
enum: ["ClusterIP", "NodePort", "LoadBalancer"],
|
|
12
|
-
default: "ClusterIP"
|
|
13
|
-
},
|
|
14
|
-
selector: {
|
|
15
|
-
type: "object",
|
|
16
|
-
additionalProperties: { type: "string" },
|
|
17
|
-
default: {}
|
|
18
|
-
},
|
|
19
|
-
ports: {
|
|
20
|
-
type: "array",
|
|
21
|
-
items: {
|
|
22
|
-
type: "object",
|
|
23
|
-
properties: {
|
|
24
|
-
port: { type: "number" },
|
|
25
|
-
targetPort: { type: "number" },
|
|
26
|
-
protocol: {
|
|
27
|
-
type: "string",
|
|
28
|
-
enum: ["TCP", "UDP"],
|
|
29
|
-
default: "TCP"
|
|
30
|
-
},
|
|
31
|
-
name: { type: "string" },
|
|
32
|
-
nodePort: { type: "number" }
|
|
33
|
-
},
|
|
34
|
-
required: ["port"]
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
required: ["name", "ports"],
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
export async function createService(k8sManager, input) {
|
|
42
|
-
const namespace = input.namespace || "default";
|
|
43
|
-
const serviceType = input.type || "ClusterIP";
|
|
44
|
-
// Convert ports to k8s.V1ServicePort format
|
|
45
|
-
const servicePorts = input.ports.map((portConfig, index) => {
|
|
46
|
-
return {
|
|
47
|
-
port: portConfig.port,
|
|
48
|
-
targetPort: portConfig.targetPort !== undefined ? portConfig.targetPort : portConfig.port,
|
|
49
|
-
protocol: portConfig.protocol || "TCP",
|
|
50
|
-
name: portConfig.name || `port-${index}`,
|
|
51
|
-
...(serviceType === "NodePort" && portConfig.nodePort ? { nodePort: portConfig.nodePort } : {})
|
|
52
|
-
};
|
|
53
|
-
});
|
|
54
|
-
// Default selector
|
|
55
|
-
const selector = input.selector || { app: input.name };
|
|
56
|
-
const service = {
|
|
57
|
-
apiVersion: "v1",
|
|
58
|
-
kind: "Service",
|
|
59
|
-
metadata: {
|
|
60
|
-
name: input.name,
|
|
61
|
-
namespace: namespace,
|
|
62
|
-
labels: {
|
|
63
|
-
"mcp-managed": "true",
|
|
64
|
-
app: input.name,
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
spec: {
|
|
68
|
-
type: serviceType,
|
|
69
|
-
selector: selector,
|
|
70
|
-
ports: servicePorts
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
try {
|
|
74
|
-
const response = await k8sManager
|
|
75
|
-
.getCoreApi()
|
|
76
|
-
.createNamespacedService(namespace, service);
|
|
77
|
-
k8sManager.trackResource("Service", input.name, namespace);
|
|
78
|
-
return {
|
|
79
|
-
content: [
|
|
80
|
-
{
|
|
81
|
-
type: "text",
|
|
82
|
-
text: JSON.stringify({
|
|
83
|
-
serviceName: response.body.metadata.name,
|
|
84
|
-
namespace: response.body.metadata.namespace,
|
|
85
|
-
type: response.body.spec.type,
|
|
86
|
-
clusterIP: response.body.spec.clusterIP,
|
|
87
|
-
ports: response.body.spec.ports,
|
|
88
|
-
status: "created",
|
|
89
|
-
}, null, 2),
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
console.error("Service creation error:", {
|
|
96
|
-
status: error.response?.statusCode,
|
|
97
|
-
message: error.response?.body?.message || error.message,
|
|
98
|
-
details: error.response?.body,
|
|
99
|
-
});
|
|
100
|
-
throw error;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { KubernetesManager } from "../types.js";
|
|
2
|
-
export declare const DeleteConfigMapSchema: {
|
|
3
|
-
name: string;
|
|
4
|
-
description: string;
|
|
5
|
-
inputSchema: {
|
|
6
|
-
type: string;
|
|
7
|
-
properties: {
|
|
8
|
-
name: {
|
|
9
|
-
type: string;
|
|
10
|
-
};
|
|
11
|
-
namespace: {
|
|
12
|
-
type: string;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
required: string[];
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
export declare function deleteConfigMap(k8sManager: KubernetesManager, input: {
|
|
19
|
-
name: string;
|
|
20
|
-
namespace: string;
|
|
21
|
-
}): Promise<{
|
|
22
|
-
content: {
|
|
23
|
-
success: boolean;
|
|
24
|
-
message: string;
|
|
25
|
-
}[];
|
|
26
|
-
}>;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
export const DeleteConfigMapSchema = {
|
|
2
|
-
name: "delete_configmap",
|
|
3
|
-
description: "Delete a Kubernetes ConfigMap",
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object",
|
|
6
|
-
properties: {
|
|
7
|
-
name: { type: "string" },
|
|
8
|
-
namespace: { type: "string" },
|
|
9
|
-
},
|
|
10
|
-
required: ["name", "namespace"],
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
export async function deleteConfigMap(k8sManager, input) {
|
|
14
|
-
try {
|
|
15
|
-
const response = await k8sManager.getCoreApi().deleteNamespacedConfigMap(input.name, input.namespace);
|
|
16
|
-
if (response.response?.statusCode !== undefined &&
|
|
17
|
-
(response.response.statusCode === 200 ||
|
|
18
|
-
response.response.statusCode === 202)) {
|
|
19
|
-
return {
|
|
20
|
-
content: [
|
|
21
|
-
{
|
|
22
|
-
success: true,
|
|
23
|
-
message: `Deleted ConfigMap ${input.name} in namespace ${input.namespace}`,
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
return {
|
|
30
|
-
content: [
|
|
31
|
-
{
|
|
32
|
-
success: false,
|
|
33
|
-
message: `Failed to delete ConfigMap ${input.name} in namespace ${input.namespace}`,
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
return {
|
|
41
|
-
content: [
|
|
42
|
-
{
|
|
43
|
-
success: false,
|
|
44
|
-
message: `Failed to delete ConfigMap ${input.name} in namespace ${input.namespace}. Error: ${error.message}`,
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { KubernetesManager } from "../types.js";
|
|
2
|
-
export declare const DeleteCronJobSchema: {
|
|
3
|
-
readonly name: "delete_cronjob";
|
|
4
|
-
readonly description: "Delete a Kubernetes CronJob";
|
|
5
|
-
readonly inputSchema: {
|
|
6
|
-
readonly type: "object";
|
|
7
|
-
readonly properties: {
|
|
8
|
-
readonly name: {
|
|
9
|
-
readonly type: "string";
|
|
10
|
-
};
|
|
11
|
-
readonly namespace: {
|
|
12
|
-
readonly type: "string";
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
readonly required: readonly ["name", "namespace"];
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
export declare function DeleteCronJob(k8sManager: KubernetesManager, input: {
|
|
19
|
-
name: string;
|
|
20
|
-
namespace: string;
|
|
21
|
-
}): Promise<{
|
|
22
|
-
content: {
|
|
23
|
-
success: boolean;
|
|
24
|
-
message: string;
|
|
25
|
-
}[];
|
|
26
|
-
}>;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export const DeleteCronJobSchema = {
|
|
2
|
-
name: "delete_cronjob",
|
|
3
|
-
description: "Delete a Kubernetes CronJob",
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object",
|
|
6
|
-
properties: {
|
|
7
|
-
name: { type: "string" },
|
|
8
|
-
namespace: { type: "string" }
|
|
9
|
-
},
|
|
10
|
-
required: ["name", "namespace"]
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
export async function DeleteCronJob(k8sManager, input) {
|
|
14
|
-
try {
|
|
15
|
-
const response = await k8sManager.getBatchApi().deleteNamespacedCronJob(input.name, input.namespace);
|
|
16
|
-
if (response.response?.statusCode !== undefined && (response.response.statusCode === 200 || response.response.statusCode === 202)) {
|
|
17
|
-
return {
|
|
18
|
-
content: [
|
|
19
|
-
{
|
|
20
|
-
success: true,
|
|
21
|
-
message: `Deleted cronjob ${input.name} in namespace ${input.namespace}.` +
|
|
22
|
-
(response.body?.details ? ` Details: ${response.body.details}` : "")
|
|
23
|
-
}
|
|
24
|
-
]
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
return {
|
|
29
|
-
content: [
|
|
30
|
-
{
|
|
31
|
-
success: false,
|
|
32
|
-
message: `Failed to delete cronjob ${input.name} in namespace ${input.namespace}.` + (response.body?.details ? ` Details: ${response.body.details}` : "")
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
return {
|
|
40
|
-
content: [
|
|
41
|
-
{
|
|
42
|
-
success: false,
|
|
43
|
-
message: `Failed to delete cronjob: ${error.message}`
|
|
44
|
-
}
|
|
45
|
-
]
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { KubernetesManager } from "../types.js";
|
|
2
|
-
export declare const deleteDeploymentSchema: {
|
|
3
|
-
readonly name: "delete_deployment";
|
|
4
|
-
readonly description: "Delete a Kubernetes deployment";
|
|
5
|
-
readonly inputSchema: {
|
|
6
|
-
readonly type: "object";
|
|
7
|
-
readonly properties: {
|
|
8
|
-
readonly name: {
|
|
9
|
-
readonly type: "string";
|
|
10
|
-
};
|
|
11
|
-
readonly namespace: {
|
|
12
|
-
readonly type: "string";
|
|
13
|
-
};
|
|
14
|
-
readonly ignoreNotFound: {
|
|
15
|
-
readonly type: "boolean";
|
|
16
|
-
readonly default: false;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
readonly required: readonly ["name", "namespace"];
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
export declare function deleteDeployment(k8sManager: KubernetesManager, input: {
|
|
23
|
-
name: string;
|
|
24
|
-
namespace: string;
|
|
25
|
-
ignoreNotFound?: boolean;
|
|
26
|
-
}): Promise<{
|
|
27
|
-
content: {
|
|
28
|
-
type: string;
|
|
29
|
-
text: string;
|
|
30
|
-
}[];
|
|
31
|
-
}>;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export const deleteDeploymentSchema = {
|
|
2
|
-
name: "delete_deployment",
|
|
3
|
-
description: "Delete a Kubernetes deployment",
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object",
|
|
6
|
-
properties: {
|
|
7
|
-
name: { type: "string" },
|
|
8
|
-
namespace: { type: "string" },
|
|
9
|
-
ignoreNotFound: { type: "boolean", default: false },
|
|
10
|
-
},
|
|
11
|
-
required: ["name", "namespace"],
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
export async function deleteDeployment(k8sManager, input) {
|
|
15
|
-
try {
|
|
16
|
-
await k8sManager
|
|
17
|
-
.getAppsApi()
|
|
18
|
-
.deleteNamespacedDeployment(input.name, input.namespace);
|
|
19
|
-
return {
|
|
20
|
-
content: [
|
|
21
|
-
{
|
|
22
|
-
type: "text",
|
|
23
|
-
text: JSON.stringify({
|
|
24
|
-
success: true,
|
|
25
|
-
status: "deleted",
|
|
26
|
-
}, null, 2),
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
if (input.ignoreNotFound && error.response?.statusCode === 404) {
|
|
33
|
-
return {
|
|
34
|
-
content: [
|
|
35
|
-
{
|
|
36
|
-
type: "text",
|
|
37
|
-
text: JSON.stringify({
|
|
38
|
-
success: true,
|
|
39
|
-
status: "not_found",
|
|
40
|
-
}, null, 2),
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
throw error;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { KubernetesManager } from "../types.js";
|
|
2
|
-
export declare const deleteNamespaceSchema: {
|
|
3
|
-
readonly name: "delete_namespace";
|
|
4
|
-
readonly description: "Delete a Kubernetes namespace";
|
|
5
|
-
readonly inputSchema: {
|
|
6
|
-
readonly type: "object";
|
|
7
|
-
readonly properties: {
|
|
8
|
-
readonly name: {
|
|
9
|
-
readonly type: "string";
|
|
10
|
-
};
|
|
11
|
-
readonly ignoreNotFound: {
|
|
12
|
-
readonly type: "boolean";
|
|
13
|
-
readonly default: false;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
readonly required: readonly ["name"];
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
export declare function deleteNamespace(k8sManager: KubernetesManager, input: {
|
|
20
|
-
name: string;
|
|
21
|
-
ignoreNotFound?: boolean;
|
|
22
|
-
}): Promise<{
|
|
23
|
-
content: {
|
|
24
|
-
type: string;
|
|
25
|
-
text: string;
|
|
26
|
-
}[];
|
|
27
|
-
}>;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export const deleteNamespaceSchema = {
|
|
2
|
-
name: "delete_namespace",
|
|
3
|
-
description: "Delete a Kubernetes namespace",
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object",
|
|
6
|
-
properties: {
|
|
7
|
-
name: { type: "string" },
|
|
8
|
-
ignoreNotFound: { type: "boolean", default: false },
|
|
9
|
-
},
|
|
10
|
-
required: ["name"],
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
export async function deleteNamespace(k8sManager, input) {
|
|
14
|
-
try {
|
|
15
|
-
await k8sManager.getCoreApi().deleteNamespace(input.name);
|
|
16
|
-
return {
|
|
17
|
-
content: [
|
|
18
|
-
{
|
|
19
|
-
type: "text",
|
|
20
|
-
text: JSON.stringify({
|
|
21
|
-
success: true,
|
|
22
|
-
status: "deleted",
|
|
23
|
-
}, null, 2),
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
if (input.ignoreNotFound && error.response?.statusCode === 404) {
|
|
30
|
-
return {
|
|
31
|
-
content: [
|
|
32
|
-
{
|
|
33
|
-
type: "text",
|
|
34
|
-
text: JSON.stringify({
|
|
35
|
-
success: true,
|
|
36
|
-
status: "not_found",
|
|
37
|
-
}, null, 2),
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
throw error;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { KubernetesManager } from "../types.js";
|
|
2
|
-
export declare const deletePodSchema: {
|
|
3
|
-
readonly name: "delete_pod";
|
|
4
|
-
readonly description: "Delete a Kubernetes pod";
|
|
5
|
-
readonly inputSchema: {
|
|
6
|
-
readonly type: "object";
|
|
7
|
-
readonly properties: {
|
|
8
|
-
readonly name: {
|
|
9
|
-
readonly type: "string";
|
|
10
|
-
};
|
|
11
|
-
readonly namespace: {
|
|
12
|
-
readonly type: "string";
|
|
13
|
-
};
|
|
14
|
-
readonly ignoreNotFound: {
|
|
15
|
-
readonly type: "boolean";
|
|
16
|
-
readonly default: false;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
readonly required: readonly ["name", "namespace"];
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
export declare function deletePod(k8sManager: KubernetesManager, input: {
|
|
23
|
-
name: string;
|
|
24
|
-
namespace: string;
|
|
25
|
-
ignoreNotFound?: boolean;
|
|
26
|
-
}): Promise<{
|
|
27
|
-
content: {
|
|
28
|
-
type: string;
|
|
29
|
-
text: string;
|
|
30
|
-
}[];
|
|
31
|
-
}>;
|