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
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export const listDeploymentsSchema = {
|
|
2
|
-
name: "list_deployments",
|
|
3
|
-
description: "List deployments in a namespace",
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object",
|
|
6
|
-
properties: {
|
|
7
|
-
namespace: { type: "string", default: "default" },
|
|
8
|
-
},
|
|
9
|
-
required: ["namespace"],
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
export async function listDeployments(k8sManager, input) {
|
|
13
|
-
const namespace = input.namespace || "default";
|
|
14
|
-
const { body } = await k8sManager.getAppsApi().listNamespacedDeployment(namespace);
|
|
15
|
-
const deployments = body.items.map((deployment) => ({
|
|
16
|
-
name: deployment.metadata?.name || "",
|
|
17
|
-
namespace: deployment.metadata?.namespace || "",
|
|
18
|
-
replicas: deployment.spec?.replicas || 0,
|
|
19
|
-
availableReplicas: deployment.status?.availableReplicas || 0,
|
|
20
|
-
createdAt: deployment.metadata?.creationTimestamp,
|
|
21
|
-
}));
|
|
22
|
-
return {
|
|
23
|
-
content: [
|
|
24
|
-
{
|
|
25
|
-
type: "text",
|
|
26
|
-
text: JSON.stringify({ deployments }, null, 2),
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
};
|
|
30
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { KubernetesManager } from "../types.js";
|
|
2
|
-
export declare const listJobsSchema: {
|
|
3
|
-
readonly name: "list_jobs";
|
|
4
|
-
readonly description: "List Jobs in a namespace, optionally filtered by a CronJob parent";
|
|
5
|
-
readonly inputSchema: {
|
|
6
|
-
readonly type: "object";
|
|
7
|
-
readonly properties: {
|
|
8
|
-
readonly namespace: {
|
|
9
|
-
readonly type: "string";
|
|
10
|
-
readonly default: "default";
|
|
11
|
-
};
|
|
12
|
-
readonly cronJobName: {
|
|
13
|
-
readonly type: "string";
|
|
14
|
-
readonly description: "Optional: Filter jobs created by a specific CronJob";
|
|
15
|
-
readonly optional: true;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
readonly required: readonly ["namespace"];
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
export declare function listJobs(k8sManager: KubernetesManager, input: {
|
|
22
|
-
namespace: string;
|
|
23
|
-
cronJobName?: string;
|
|
24
|
-
}): Promise<{
|
|
25
|
-
content: {
|
|
26
|
-
type: string;
|
|
27
|
-
text: string;
|
|
28
|
-
}[];
|
|
29
|
-
}>;
|
package/dist/tools/list_jobs.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
export const listJobsSchema = {
|
|
2
|
-
name: "list_jobs",
|
|
3
|
-
description: "List Jobs in a namespace, optionally filtered by a CronJob parent",
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object",
|
|
6
|
-
properties: {
|
|
7
|
-
namespace: { type: "string", default: "default" },
|
|
8
|
-
cronJobName: {
|
|
9
|
-
type: "string",
|
|
10
|
-
description: "Optional: Filter jobs created by a specific CronJob",
|
|
11
|
-
optional: true,
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
required: ["namespace"],
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
export async function listJobs(k8sManager, input) {
|
|
18
|
-
try {
|
|
19
|
-
const namespace = input.namespace;
|
|
20
|
-
const batchV1Api = k8sManager.getBatchApi();
|
|
21
|
-
// Set up label selector if cronJobName is provided
|
|
22
|
-
let labelSelector;
|
|
23
|
-
if (input.cronJobName) {
|
|
24
|
-
labelSelector = `cronjob-name=${input.cronJobName}`;
|
|
25
|
-
}
|
|
26
|
-
// Get jobs with optional filtering
|
|
27
|
-
const { body } = await batchV1Api.listNamespacedJob(namespace, undefined, // pretty
|
|
28
|
-
undefined, // allowWatchBookmarks
|
|
29
|
-
undefined, // _continue
|
|
30
|
-
undefined, // fieldSelector
|
|
31
|
-
labelSelector // labelSelector
|
|
32
|
-
);
|
|
33
|
-
// Sort jobs by creation time (newest first)
|
|
34
|
-
const jobs = body.items.sort((a, b) => {
|
|
35
|
-
const aTime = a.metadata?.creationTimestamp
|
|
36
|
-
? new Date(a.metadata.creationTimestamp)
|
|
37
|
-
: new Date(0);
|
|
38
|
-
const bTime = b.metadata?.creationTimestamp
|
|
39
|
-
? new Date(b.metadata.creationTimestamp)
|
|
40
|
-
: new Date(0);
|
|
41
|
-
return bTime.getTime() - aTime.getTime();
|
|
42
|
-
});
|
|
43
|
-
// Transform job data to a more readable format
|
|
44
|
-
const formattedJobs = jobs.map((job) => ({
|
|
45
|
-
name: job.metadata?.name || "",
|
|
46
|
-
namespace: job.metadata?.namespace || "",
|
|
47
|
-
creationTime: job.metadata?.creationTimestamp || "",
|
|
48
|
-
labels: job.metadata?.labels || {},
|
|
49
|
-
completions: job.spec?.completions || 1,
|
|
50
|
-
parallelism: job.spec?.parallelism || 1,
|
|
51
|
-
status: {
|
|
52
|
-
active: job.status?.active || 0,
|
|
53
|
-
succeeded: job.status?.succeeded || 0,
|
|
54
|
-
failed: job.status?.failed || 0,
|
|
55
|
-
completionTime: job.status?.completionTime || null,
|
|
56
|
-
startTime: job.status?.startTime || null,
|
|
57
|
-
conditions: job.status?.conditions || [],
|
|
58
|
-
},
|
|
59
|
-
}));
|
|
60
|
-
return {
|
|
61
|
-
content: [
|
|
62
|
-
{
|
|
63
|
-
type: "text",
|
|
64
|
-
text: JSON.stringify({ jobs: formattedJobs }, null, 2),
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
console.error("Error listing Jobs:", {
|
|
71
|
-
status: error.response?.statusCode,
|
|
72
|
-
message: error.response?.body?.message || error.message,
|
|
73
|
-
details: error.response?.body,
|
|
74
|
-
});
|
|
75
|
-
throw error;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { KubernetesManager } from "../types.js";
|
|
2
|
-
export declare const listNodesSchema: {
|
|
3
|
-
readonly name: "list_nodes";
|
|
4
|
-
readonly description: "List all nodes in the cluster";
|
|
5
|
-
readonly inputSchema: {
|
|
6
|
-
readonly type: "object";
|
|
7
|
-
readonly properties: {};
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
export declare function listNodes(k8sManager: KubernetesManager): Promise<{
|
|
11
|
-
content: {
|
|
12
|
-
type: string;
|
|
13
|
-
text: string;
|
|
14
|
-
}[];
|
|
15
|
-
}>;
|
package/dist/tools/list_nodes.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export const listNodesSchema = {
|
|
2
|
-
name: "list_nodes",
|
|
3
|
-
description: "List all nodes in the cluster",
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object",
|
|
6
|
-
properties: {},
|
|
7
|
-
},
|
|
8
|
-
};
|
|
9
|
-
export async function listNodes(k8sManager) {
|
|
10
|
-
const { body } = await k8sManager.getCoreApi().listNode();
|
|
11
|
-
return {
|
|
12
|
-
content: [
|
|
13
|
-
{
|
|
14
|
-
type: "text",
|
|
15
|
-
text: JSON.stringify({
|
|
16
|
-
nodes: body.items,
|
|
17
|
-
}, null, 2),
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
};
|
|
21
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { KubernetesManager } from "../types.js";
|
|
2
|
-
export declare const listPodsSchema: {
|
|
3
|
-
readonly name: "list_pods";
|
|
4
|
-
readonly description: "List pods in a namespace";
|
|
5
|
-
readonly inputSchema: {
|
|
6
|
-
readonly type: "object";
|
|
7
|
-
readonly properties: {
|
|
8
|
-
readonly namespace: {
|
|
9
|
-
readonly type: "string";
|
|
10
|
-
readonly default: "default";
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
readonly required: readonly ["namespace"];
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export declare function listPods(k8sManager: KubernetesManager, input: {
|
|
17
|
-
namespace?: string;
|
|
18
|
-
}): Promise<{
|
|
19
|
-
content: {
|
|
20
|
-
type: string;
|
|
21
|
-
text: string;
|
|
22
|
-
}[];
|
|
23
|
-
}>;
|
package/dist/tools/list_pods.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export const listPodsSchema = {
|
|
2
|
-
name: "list_pods",
|
|
3
|
-
description: "List pods in a namespace",
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object",
|
|
6
|
-
properties: {
|
|
7
|
-
namespace: { type: "string", default: "default" },
|
|
8
|
-
},
|
|
9
|
-
required: ["namespace"],
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
export async function listPods(k8sManager, input) {
|
|
13
|
-
const namespace = input.namespace || "default";
|
|
14
|
-
const { body } = await k8sManager.getCoreApi().listNamespacedPod(namespace);
|
|
15
|
-
const pods = body.items.map((pod) => ({
|
|
16
|
-
name: pod.metadata?.name || "",
|
|
17
|
-
namespace: pod.metadata?.namespace || "",
|
|
18
|
-
phase: pod.status?.phase,
|
|
19
|
-
createdAt: pod.metadata?.creationTimestamp,
|
|
20
|
-
}));
|
|
21
|
-
return {
|
|
22
|
-
content: [
|
|
23
|
-
{
|
|
24
|
-
type: "text",
|
|
25
|
-
text: JSON.stringify({ pods }, null, 2),
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
};
|
|
29
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { KubernetesManager } from "../types.js";
|
|
2
|
-
export declare const listServicesSchema: {
|
|
3
|
-
readonly name: "list_services";
|
|
4
|
-
readonly description: "List services in a namespace";
|
|
5
|
-
readonly inputSchema: {
|
|
6
|
-
readonly type: "object";
|
|
7
|
-
readonly properties: {
|
|
8
|
-
readonly namespace: {
|
|
9
|
-
readonly type: "string";
|
|
10
|
-
readonly default: "default";
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
readonly required: readonly ["namespace"];
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export declare function listServices(k8sManager: KubernetesManager, input: {
|
|
17
|
-
namespace?: string;
|
|
18
|
-
}): Promise<{
|
|
19
|
-
content: {
|
|
20
|
-
type: string;
|
|
21
|
-
text: string;
|
|
22
|
-
}[];
|
|
23
|
-
}>;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export const listServicesSchema = {
|
|
2
|
-
name: "list_services",
|
|
3
|
-
description: "List services in a namespace",
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object",
|
|
6
|
-
properties: {
|
|
7
|
-
namespace: { type: "string", default: "default" },
|
|
8
|
-
},
|
|
9
|
-
required: ["namespace"],
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
export async function listServices(k8sManager, input) {
|
|
13
|
-
const namespace = input.namespace || "default";
|
|
14
|
-
const { body } = await k8sManager.getCoreApi().listNamespacedService(namespace);
|
|
15
|
-
const services = body.items.map((service) => ({
|
|
16
|
-
name: service.metadata?.name || "",
|
|
17
|
-
namespace: service.metadata?.namespace || "",
|
|
18
|
-
type: service.spec?.type,
|
|
19
|
-
clusterIP: service.spec?.clusterIP,
|
|
20
|
-
ports: service.spec?.ports || [],
|
|
21
|
-
createdAt: service.metadata?.creationTimestamp,
|
|
22
|
-
}));
|
|
23
|
-
return {
|
|
24
|
-
content: [
|
|
25
|
-
{
|
|
26
|
-
type: "text",
|
|
27
|
-
text: JSON.stringify({ services }, null, 2),
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
};
|
|
31
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
export const scaleDeploymentSchema = {
|
|
2
|
-
name: "scale_deployment",
|
|
3
|
-
description: "Scale a Kubernetes deployment",
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object",
|
|
6
|
-
properties: {
|
|
7
|
-
name: { type: "string" },
|
|
8
|
-
namespace: { type: "string" },
|
|
9
|
-
replicas: { type: "number" }
|
|
10
|
-
},
|
|
11
|
-
required: ["name", "namespace", "replicas"]
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
export async function scaleDeployment(k8sManager, input) {
|
|
15
|
-
try {
|
|
16
|
-
const scale = k8sManager.getAppsApi().readNamespacedDeploymentScale(input.name, input.namespace);
|
|
17
|
-
(await scale).body.spec.replicas = input.replicas;
|
|
18
|
-
const result = await k8sManager.getAppsApi().replaceNamespacedDeploymentScale(input.name, input.namespace, (await scale).body);
|
|
19
|
-
if (result.response?.statusCode !== undefined && result.response.statusCode >= 200 && result.response.statusCode < 300) {
|
|
20
|
-
return {
|
|
21
|
-
content: [
|
|
22
|
-
{
|
|
23
|
-
success: true,
|
|
24
|
-
message: `Scaled deployment ${input.name} to ${input.replicas} replicas`
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return {
|
|
31
|
-
content: [
|
|
32
|
-
{
|
|
33
|
-
success: false,
|
|
34
|
-
message: `Failed to scale deployment ${input.name} to ${input.replicas} replicas`
|
|
35
|
-
}
|
|
36
|
-
]
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
return {
|
|
42
|
-
content: [
|
|
43
|
-
{
|
|
44
|
-
success: false,
|
|
45
|
-
message: `Failed to scale deployment ${error.message}`
|
|
46
|
-
}
|
|
47
|
-
]
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { KubernetesManager } from "../types.js";
|
|
2
|
-
export declare const setCurrentContextSchema: {
|
|
3
|
-
readonly name: "set_current_context";
|
|
4
|
-
readonly description: "Set the current Kubernetes context";
|
|
5
|
-
readonly inputSchema: {
|
|
6
|
-
readonly type: "object";
|
|
7
|
-
readonly properties: {
|
|
8
|
-
readonly name: {
|
|
9
|
-
readonly type: "string";
|
|
10
|
-
readonly description: "Name of the context to set as current";
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
readonly required: readonly ["name"];
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export declare function setCurrentContext(k8sManager: KubernetesManager, input: {
|
|
17
|
-
name: string;
|
|
18
|
-
}): Promise<{
|
|
19
|
-
content: {
|
|
20
|
-
type: string;
|
|
21
|
-
text: string;
|
|
22
|
-
}[];
|
|
23
|
-
}>;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export const setCurrentContextSchema = {
|
|
2
|
-
name: "set_current_context",
|
|
3
|
-
description: "Set the current Kubernetes context",
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object",
|
|
6
|
-
properties: {
|
|
7
|
-
name: {
|
|
8
|
-
type: "string",
|
|
9
|
-
description: "Name of the context to set as current"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
required: ["name"],
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
export async function setCurrentContext(k8sManager, input) {
|
|
16
|
-
try {
|
|
17
|
-
// Set the current context
|
|
18
|
-
k8sManager.setCurrentContext(input.name);
|
|
19
|
-
return {
|
|
20
|
-
content: [
|
|
21
|
-
{
|
|
22
|
-
type: "text",
|
|
23
|
-
text: JSON.stringify({
|
|
24
|
-
success: true,
|
|
25
|
-
message: `Current context set to '${input.name}'`,
|
|
26
|
-
context: input.name
|
|
27
|
-
}, null, 2),
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
throw new Error(`Failed to set current context: ${error.message}`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { KubernetesManager } from "../types.js";
|
|
2
|
-
export declare const UpdateConfigMapSchema: {
|
|
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
|
-
data: {
|
|
15
|
-
type: string;
|
|
16
|
-
ConfigData: {
|
|
17
|
-
type: string;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
required: string[];
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
export declare function updateConfigMap(k8sManager: KubernetesManager, input: {
|
|
25
|
-
name: string;
|
|
26
|
-
namespace: string;
|
|
27
|
-
data: Record<string, string>;
|
|
28
|
-
}): Promise<{
|
|
29
|
-
content: {
|
|
30
|
-
success: boolean;
|
|
31
|
-
message: string;
|
|
32
|
-
}[];
|
|
33
|
-
}>;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
export const UpdateConfigMapSchema = {
|
|
2
|
-
name: "update_configmap",
|
|
3
|
-
description: "Update an existing Kubernetes ConfigMap",
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object",
|
|
6
|
-
properties: {
|
|
7
|
-
name: { type: "string" },
|
|
8
|
-
namespace: { type: "string" },
|
|
9
|
-
data: {
|
|
10
|
-
type: "object",
|
|
11
|
-
ConfigData: { type: "string" },
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
required: ["name", "namespace", "data"],
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
export async function updateConfigMap(k8sManager, input) {
|
|
18
|
-
try {
|
|
19
|
-
// Fetch the existing ConfigMap
|
|
20
|
-
const existing = await k8sManager.getCoreApi().readNamespacedConfigMap(input.name, input.namespace);
|
|
21
|
-
if (!existing.body || !existing.body.metadata) {
|
|
22
|
-
return {
|
|
23
|
-
content: [
|
|
24
|
-
{
|
|
25
|
-
success: false,
|
|
26
|
-
message: `ConfigMap ${input.name} in namespace ${input.namespace} not found.`,
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
// Update the data
|
|
32
|
-
const updatedConfigMap = {
|
|
33
|
-
...existing.body,
|
|
34
|
-
data: input.data,
|
|
35
|
-
};
|
|
36
|
-
const response = await k8sManager.getCoreApi().replaceNamespacedConfigMap(input.name, input.namespace, updatedConfigMap);
|
|
37
|
-
if (response.response?.statusCode !== undefined &&
|
|
38
|
-
(response.response.statusCode === 200 ||
|
|
39
|
-
response.response.statusCode === 201 ||
|
|
40
|
-
response.response.statusCode === 202)) {
|
|
41
|
-
return {
|
|
42
|
-
content: [
|
|
43
|
-
{
|
|
44
|
-
success: true,
|
|
45
|
-
message: `Updated ConfigMap ${input.name} in namespace ${input.namespace}`,
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
return {
|
|
52
|
-
content: [
|
|
53
|
-
{
|
|
54
|
-
success: false,
|
|
55
|
-
message: `Failed to update ConfigMap ${input.name} in namespace ${input.namespace}`,
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
return {
|
|
63
|
-
content: [
|
|
64
|
-
{
|
|
65
|
-
success: false,
|
|
66
|
-
message: `Failed to update ConfigMap ${input.name} in namespace ${input.namespace}. Error: ${error.message}`,
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { KubernetesManager } from "../types.js";
|
|
2
|
-
import { CustomContainerConfigType } from "../config/container-templates.js";
|
|
3
|
-
export declare const updateDeploymentSchema: {
|
|
4
|
-
name: string;
|
|
5
|
-
description: string;
|
|
6
|
-
inputSchema: {
|
|
7
|
-
type: string;
|
|
8
|
-
required: string[];
|
|
9
|
-
properties: {
|
|
10
|
-
name: {
|
|
11
|
-
type: string;
|
|
12
|
-
};
|
|
13
|
-
namespace: {
|
|
14
|
-
type: string;
|
|
15
|
-
};
|
|
16
|
-
template: {
|
|
17
|
-
type: string;
|
|
18
|
-
enum: ["ubuntu", "nginx", "busybox", "alpine", "custom"];
|
|
19
|
-
};
|
|
20
|
-
containerName: {
|
|
21
|
-
type: string;
|
|
22
|
-
description: string;
|
|
23
|
-
};
|
|
24
|
-
replicas: {
|
|
25
|
-
type: string;
|
|
26
|
-
};
|
|
27
|
-
customConfig: {
|
|
28
|
-
type: string;
|
|
29
|
-
properties: {
|
|
30
|
-
image: {
|
|
31
|
-
type: string;
|
|
32
|
-
};
|
|
33
|
-
command: {
|
|
34
|
-
type: string;
|
|
35
|
-
items: {
|
|
36
|
-
type: string;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
args: {
|
|
40
|
-
type: string;
|
|
41
|
-
items: {
|
|
42
|
-
type: string;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
ports: {
|
|
46
|
-
type: string;
|
|
47
|
-
items: {
|
|
48
|
-
type: string;
|
|
49
|
-
properties: {
|
|
50
|
-
containerPort: {
|
|
51
|
-
type: string;
|
|
52
|
-
};
|
|
53
|
-
name: {
|
|
54
|
-
type: string;
|
|
55
|
-
};
|
|
56
|
-
protocol: {
|
|
57
|
-
type: string;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
resources: {
|
|
63
|
-
type: string;
|
|
64
|
-
properties: {
|
|
65
|
-
limits: {
|
|
66
|
-
type: string;
|
|
67
|
-
additionalProperties: {
|
|
68
|
-
type: string;
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
requests: {
|
|
72
|
-
type: string;
|
|
73
|
-
additionalProperties: {
|
|
74
|
-
type: string;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
env: {
|
|
80
|
-
type: string;
|
|
81
|
-
items: {
|
|
82
|
-
type: string;
|
|
83
|
-
properties: {
|
|
84
|
-
name: {
|
|
85
|
-
type: string;
|
|
86
|
-
};
|
|
87
|
-
value: {
|
|
88
|
-
type: string;
|
|
89
|
-
};
|
|
90
|
-
valueFrom: {
|
|
91
|
-
type: string;
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
export declare function updateDeployment(k8sManager: KubernetesManager, params: {
|
|
102
|
-
name: string;
|
|
103
|
-
namespace: string;
|
|
104
|
-
template: string;
|
|
105
|
-
containerName?: string;
|
|
106
|
-
replicas?: number;
|
|
107
|
-
customConfig?: CustomContainerConfigType;
|
|
108
|
-
}): Promise<{
|
|
109
|
-
content: {
|
|
110
|
-
type: string;
|
|
111
|
-
text: string;
|
|
112
|
-
}[];
|
|
113
|
-
}>;
|