mcp-server-kubernetes 2.7.0 → 2.9.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 +251 -2
- package/dist/index.d.ts +190 -27
- package/dist/index.js +7 -0
- package/dist/models/common-parameters.d.ts +15 -0
- package/dist/models/common-parameters.js +15 -0
- package/dist/models/helm-models.d.ts +18 -5
- package/dist/models/kubectl-models.d.ts +2 -0
- package/dist/tools/exec_in_pod.d.ts +7 -1
- package/dist/tools/exec_in_pod.js +7 -5
- package/dist/tools/helm-operations.d.ts +89 -11
- package/dist/tools/helm-operations.js +297 -106
- package/dist/tools/kubectl-apply.d.ts +12 -6
- package/dist/tools/kubectl-apply.js +9 -10
- package/dist/tools/kubectl-create.d.ts +12 -6
- package/dist/tools/kubectl-create.js +9 -10
- package/dist/tools/kubectl-delete.d.ts +9 -3
- package/dist/tools/kubectl-delete.js +8 -5
- package/dist/tools/kubectl-describe.d.ts +9 -3
- package/dist/tools/kubectl-describe.js +7 -5
- package/dist/tools/kubectl-generic.d.ts +7 -1
- package/dist/tools/kubectl-generic.js +7 -5
- package/dist/tools/kubectl-get.d.ts +9 -3
- package/dist/tools/kubectl-get.js +7 -5
- package/dist/tools/kubectl-logs.d.ts +9 -3
- package/dist/tools/kubectl-logs.js +11 -5
- package/dist/tools/kubectl-operations.d.ts +10 -0
- package/dist/tools/kubectl-operations.js +13 -0
- package/dist/tools/kubectl-patch.d.ts +8 -2
- package/dist/tools/kubectl-patch.js +9 -10
- package/dist/tools/kubectl-rollout.d.ts +7 -1
- package/dist/tools/kubectl-rollout.js +8 -5
- package/dist/tools/kubectl-scale.d.ts +7 -1
- package/dist/tools/kubectl-scale.js +8 -5
- package/dist/tools/node-management.d.ts +100 -0
- package/dist/tools/node-management.js +291 -0
- package/dist/utils/sse.js +21 -0
- package/dist/utils/streamable-http.js +21 -0
- package/package.json +1 -1
|
@@ -1,227 +1,418 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool: install_helm_chart
|
|
3
|
+
* Install a Helm chart with support for both standard Helm install and template-based installation.
|
|
4
|
+
* Template mode bypasses authentication issues and kubeconfig API version mismatches.
|
|
5
|
+
* Supports local chart paths, remote repositories, and custom values.
|
|
6
|
+
*/
|
|
1
7
|
import { execFileSync } from "child_process";
|
|
2
8
|
import { writeFileSync, unlinkSync } from "fs";
|
|
3
|
-
import
|
|
9
|
+
import { dump } from "js-yaml";
|
|
4
10
|
import { getSpawnMaxBuffer } from "../config/max-buffer.js";
|
|
11
|
+
import { contextParameter, namespaceParameter } from "../models/common-parameters.js";
|
|
12
|
+
/**
|
|
13
|
+
* Schema for install_helm_chart tool.
|
|
14
|
+
* - name: Release name
|
|
15
|
+
* - chart: Chart name or path to chart directory
|
|
16
|
+
* - namespace: Target namespace
|
|
17
|
+
* - repo: (Optional) Helm repository URL
|
|
18
|
+
* - values: (Optional) Custom values object
|
|
19
|
+
* - valuesFile: (Optional) Path to values file
|
|
20
|
+
* - useTemplate: (Optional) Use template mode instead of helm install
|
|
21
|
+
* - createNamespace: (Optional) Create namespace if it doesn't exist
|
|
22
|
+
*/
|
|
5
23
|
export const installHelmChartSchema = {
|
|
6
24
|
name: "install_helm_chart",
|
|
7
|
-
description: "Install a Helm chart",
|
|
25
|
+
description: "Install a Helm chart with support for both standard and template-based installation",
|
|
8
26
|
inputSchema: {
|
|
9
27
|
type: "object",
|
|
10
28
|
properties: {
|
|
11
29
|
name: {
|
|
12
30
|
type: "string",
|
|
13
|
-
description: "
|
|
31
|
+
description: "Name of the Helm release",
|
|
14
32
|
},
|
|
15
33
|
chart: {
|
|
16
34
|
type: "string",
|
|
17
|
-
description: "Chart name",
|
|
35
|
+
description: "Chart name (e.g., 'nginx') or path to chart directory",
|
|
18
36
|
},
|
|
37
|
+
namespace: namespaceParameter,
|
|
38
|
+
context: contextParameter,
|
|
19
39
|
repo: {
|
|
20
40
|
type: "string",
|
|
21
|
-
description: "
|
|
22
|
-
},
|
|
23
|
-
namespace: {
|
|
24
|
-
type: "string",
|
|
25
|
-
description: "Kubernetes namespace",
|
|
41
|
+
description: "Helm repository URL (optional if using local chart path)",
|
|
26
42
|
},
|
|
27
43
|
values: {
|
|
28
44
|
type: "object",
|
|
29
|
-
description: "
|
|
30
|
-
|
|
31
|
-
|
|
45
|
+
description: "Custom values to override chart defaults",
|
|
46
|
+
},
|
|
47
|
+
valuesFile: {
|
|
48
|
+
type: "string",
|
|
49
|
+
description: "Path to values file (alternative to values object)",
|
|
50
|
+
},
|
|
51
|
+
useTemplate: {
|
|
52
|
+
type: "boolean",
|
|
53
|
+
description: "Use helm template + kubectl apply instead of helm install (bypasses auth issues)",
|
|
54
|
+
default: false,
|
|
55
|
+
},
|
|
56
|
+
createNamespace: {
|
|
57
|
+
type: "boolean",
|
|
58
|
+
description: "Create namespace if it doesn't exist",
|
|
59
|
+
default: true,
|
|
32
60
|
},
|
|
33
61
|
},
|
|
34
|
-
required: ["name", "chart", "
|
|
62
|
+
required: ["name", "chart", "namespace"],
|
|
35
63
|
},
|
|
36
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* Schema for upgrade_helm_chart tool.
|
|
67
|
+
* - name: Release name
|
|
68
|
+
* - chart: Chart name or path
|
|
69
|
+
* - namespace: Target namespace
|
|
70
|
+
* - repo: (Optional) Helm repository URL
|
|
71
|
+
* - values: (Optional) Custom values object
|
|
72
|
+
* - valuesFile: (Optional) Path to values file
|
|
73
|
+
*/
|
|
37
74
|
export const upgradeHelmChartSchema = {
|
|
38
75
|
name: "upgrade_helm_chart",
|
|
39
|
-
description: "Upgrade
|
|
76
|
+
description: "Upgrade an existing Helm chart release",
|
|
40
77
|
inputSchema: {
|
|
41
78
|
type: "object",
|
|
42
79
|
properties: {
|
|
43
80
|
name: {
|
|
44
81
|
type: "string",
|
|
45
|
-
description: "
|
|
82
|
+
description: "Name of the Helm release to upgrade",
|
|
46
83
|
},
|
|
47
84
|
chart: {
|
|
48
85
|
type: "string",
|
|
49
|
-
description: "Chart name",
|
|
86
|
+
description: "Chart name or path to chart directory",
|
|
50
87
|
},
|
|
88
|
+
namespace: namespaceParameter,
|
|
89
|
+
context: contextParameter,
|
|
51
90
|
repo: {
|
|
52
91
|
type: "string",
|
|
53
|
-
description: "
|
|
54
|
-
},
|
|
55
|
-
namespace: {
|
|
56
|
-
type: "string",
|
|
57
|
-
description: "Kubernetes namespace",
|
|
92
|
+
description: "Helm repository URL (optional if using local chart path)",
|
|
58
93
|
},
|
|
59
94
|
values: {
|
|
60
95
|
type: "object",
|
|
61
|
-
description: "
|
|
62
|
-
|
|
63
|
-
|
|
96
|
+
description: "Custom values to override chart defaults",
|
|
97
|
+
},
|
|
98
|
+
valuesFile: {
|
|
99
|
+
type: "string",
|
|
100
|
+
description: "Path to values file (alternative to values object)",
|
|
64
101
|
},
|
|
65
102
|
},
|
|
66
|
-
required: ["name", "chart", "
|
|
103
|
+
required: ["name", "chart", "namespace"],
|
|
67
104
|
},
|
|
68
105
|
};
|
|
106
|
+
/**
|
|
107
|
+
* Schema for uninstall_helm_chart tool.
|
|
108
|
+
* - name: Release name
|
|
109
|
+
* - namespace: Target namespace
|
|
110
|
+
*/
|
|
69
111
|
export const uninstallHelmChartSchema = {
|
|
70
112
|
name: "uninstall_helm_chart",
|
|
71
|
-
description: "Uninstall a Helm release",
|
|
113
|
+
description: "Uninstall a Helm chart release",
|
|
72
114
|
inputSchema: {
|
|
73
115
|
type: "object",
|
|
74
116
|
properties: {
|
|
75
117
|
name: {
|
|
76
118
|
type: "string",
|
|
77
|
-
description: "
|
|
78
|
-
},
|
|
79
|
-
namespace: {
|
|
80
|
-
type: "string",
|
|
81
|
-
description: "Kubernetes namespace",
|
|
119
|
+
description: "Name of the Helm release to uninstall",
|
|
82
120
|
},
|
|
121
|
+
namespace: namespaceParameter,
|
|
122
|
+
context: contextParameter,
|
|
83
123
|
},
|
|
84
124
|
required: ["name", "namespace"],
|
|
85
125
|
},
|
|
86
126
|
};
|
|
87
|
-
|
|
127
|
+
/**
|
|
128
|
+
* Execute a command using child_process.execFileSync with proper error handling.
|
|
129
|
+
* @param command - The command to execute
|
|
130
|
+
* @param args - Array of command arguments
|
|
131
|
+
* @returns The command output as a string
|
|
132
|
+
* @throws Error if command execution fails
|
|
133
|
+
*/
|
|
134
|
+
const executeCommand = (command, args) => {
|
|
88
135
|
try {
|
|
89
|
-
// Add a generous timeout of 60 seconds for Helm operations
|
|
90
136
|
return execFileSync(command, args, {
|
|
91
137
|
encoding: "utf8",
|
|
92
|
-
timeout:
|
|
138
|
+
timeout: 300000, // 5 minutes timeout
|
|
93
139
|
maxBuffer: getSpawnMaxBuffer(),
|
|
94
140
|
env: { ...process.env, KUBECONFIG: process.env.KUBECONFIG },
|
|
95
141
|
});
|
|
96
142
|
}
|
|
97
143
|
catch (error) {
|
|
98
|
-
throw new Error(
|
|
144
|
+
throw new Error(`${command} command failed: ${error.message}`);
|
|
99
145
|
}
|
|
100
146
|
};
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
147
|
+
/**
|
|
148
|
+
* Install a Helm chart using template mode (helm template + kubectl apply).
|
|
149
|
+
* This mode bypasses authentication issues and kubeconfig API version mismatches.
|
|
150
|
+
* @param params - Installation parameters
|
|
151
|
+
* @returns Promise with installation result
|
|
152
|
+
*/
|
|
153
|
+
async function installHelmChartTemplate(params) {
|
|
154
|
+
const steps = [];
|
|
107
155
|
try {
|
|
108
|
-
// Add helm repository if provided
|
|
156
|
+
// Step 1: Add helm repository if provided
|
|
109
157
|
if (params.repo) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
158
|
+
steps.push(`Adding helm repository: ${params.repo}`);
|
|
159
|
+
executeCommand("helm", ["repo", "add", "temp-repo", params.repo]);
|
|
160
|
+
executeCommand("helm", ["repo", "update"]);
|
|
161
|
+
}
|
|
162
|
+
// Step 2: Create namespace
|
|
163
|
+
steps.push(`Creating namespace: ${params.namespace}`);
|
|
164
|
+
try {
|
|
165
|
+
executeCommand("kubectl", ["create", "namespace", params.namespace]);
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
if (!error.message.includes("already exists")) {
|
|
169
|
+
throw error;
|
|
170
|
+
}
|
|
171
|
+
steps.push(`Namespace ${params.namespace} already exists`);
|
|
172
|
+
}
|
|
173
|
+
// Step 3: Prepare values
|
|
174
|
+
let valuesContent = "";
|
|
175
|
+
if (params.valuesFile) {
|
|
176
|
+
steps.push(`Using values file: ${params.valuesFile}`);
|
|
177
|
+
valuesContent = executeCommand("cat", [params.valuesFile]);
|
|
178
|
+
}
|
|
179
|
+
else if (params.values) {
|
|
180
|
+
steps.push("Using provided values object");
|
|
181
|
+
valuesContent = dump(params.values);
|
|
113
182
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
183
|
+
// Step 4: Generate YAML using helm template
|
|
184
|
+
steps.push("Generating YAML using helm template");
|
|
185
|
+
const templateArgs = [
|
|
186
|
+
"template",
|
|
117
187
|
params.name,
|
|
118
188
|
params.chart,
|
|
119
|
-
"--namespace",
|
|
120
|
-
params.namespace,
|
|
121
|
-
"--create-namespace",
|
|
189
|
+
"--namespace", params.namespace
|
|
122
190
|
];
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
191
|
+
if (params.repo) {
|
|
192
|
+
templateArgs.push("--repo", params.repo);
|
|
193
|
+
}
|
|
194
|
+
if (valuesContent) {
|
|
195
|
+
const tempValuesFile = `/tmp/values-${Date.now()}.yaml`;
|
|
196
|
+
writeFileSync(tempValuesFile, valuesContent);
|
|
197
|
+
templateArgs.push("-f", tempValuesFile);
|
|
198
|
+
const yamlOutput = executeCommand("helm", templateArgs);
|
|
199
|
+
// Clean up temp file
|
|
200
|
+
unlinkSync(tempValuesFile);
|
|
201
|
+
// Step 5: Apply YAML using kubectl
|
|
202
|
+
steps.push("Applying YAML using kubectl");
|
|
203
|
+
const tempYamlFile = `/tmp/helm-template-${Date.now()}.yaml`;
|
|
204
|
+
writeFileSync(tempYamlFile, yamlOutput);
|
|
127
205
|
try {
|
|
128
|
-
|
|
206
|
+
executeCommand("kubectl", ["apply", "-f", tempYamlFile]);
|
|
207
|
+
steps.push("Helm chart installed successfully using template mode");
|
|
129
208
|
}
|
|
130
209
|
finally {
|
|
131
|
-
//
|
|
132
|
-
unlinkSync(
|
|
210
|
+
// Clean up temp file
|
|
211
|
+
unlinkSync(tempYamlFile);
|
|
133
212
|
}
|
|
134
213
|
}
|
|
135
214
|
else {
|
|
136
|
-
|
|
215
|
+
const yamlOutput = executeCommand("helm", templateArgs);
|
|
216
|
+
// Step 5: Apply YAML using kubectl
|
|
217
|
+
steps.push("Applying YAML using kubectl");
|
|
218
|
+
const tempYamlFile = `/tmp/helm-template-${Date.now()}.yaml`;
|
|
219
|
+
writeFileSync(tempYamlFile, yamlOutput);
|
|
220
|
+
try {
|
|
221
|
+
executeCommand("kubectl", ["apply", "-f", tempYamlFile]);
|
|
222
|
+
steps.push("Helm chart installed successfully using template mode");
|
|
223
|
+
}
|
|
224
|
+
finally {
|
|
225
|
+
// Clean up temp file
|
|
226
|
+
unlinkSync(tempYamlFile);
|
|
227
|
+
}
|
|
137
228
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
229
|
+
return {
|
|
230
|
+
content: [
|
|
231
|
+
{
|
|
232
|
+
type: "text",
|
|
233
|
+
text: JSON.stringify({
|
|
234
|
+
status: "installed",
|
|
235
|
+
message: `Helm chart '${params.name}' installed successfully using template mode`,
|
|
236
|
+
steps: steps
|
|
237
|
+
})
|
|
238
|
+
}
|
|
239
|
+
]
|
|
141
240
|
};
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
return {
|
|
244
|
+
content: [
|
|
245
|
+
{
|
|
246
|
+
type: "text",
|
|
247
|
+
text: JSON.stringify({
|
|
248
|
+
status: "failed",
|
|
249
|
+
error: `Failed to install Helm chart using template mode: ${error.message}`,
|
|
250
|
+
steps: steps
|
|
251
|
+
})
|
|
252
|
+
}
|
|
253
|
+
]
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Install a Helm chart using standard helm install command.
|
|
259
|
+
* @param params - Installation parameters
|
|
260
|
+
* @returns Promise with installation result
|
|
261
|
+
*/
|
|
262
|
+
export async function installHelmChart(params) {
|
|
263
|
+
// Use template mode if requested
|
|
264
|
+
if (params.useTemplate) {
|
|
265
|
+
return installHelmChartTemplate(params);
|
|
266
|
+
}
|
|
267
|
+
try {
|
|
268
|
+
// Add repository if provided
|
|
269
|
+
if (params.repo) {
|
|
270
|
+
const repoName = params.chart.split("/")[0];
|
|
271
|
+
executeCommand("helm", ["repo", "add", repoName, params.repo]);
|
|
272
|
+
executeCommand("helm", ["repo", "update"]);
|
|
273
|
+
}
|
|
274
|
+
const args = ["install", params.name, params.chart, "--namespace", params.namespace];
|
|
275
|
+
// Add create namespace flag if requested
|
|
276
|
+
if (params.createNamespace !== false) {
|
|
277
|
+
args.push("--create-namespace");
|
|
278
|
+
}
|
|
279
|
+
// Add values file if provided
|
|
280
|
+
if (params.valuesFile) {
|
|
281
|
+
args.push("-f", params.valuesFile);
|
|
282
|
+
}
|
|
283
|
+
// Add values object if provided
|
|
284
|
+
if (params.values) {
|
|
285
|
+
const valuesContent = dump(params.values);
|
|
286
|
+
const tempFile = `/tmp/values-${Date.now()}.yaml`;
|
|
287
|
+
writeFileSync(tempFile, valuesContent);
|
|
288
|
+
try {
|
|
289
|
+
args.push("-f", tempFile);
|
|
290
|
+
executeCommand("helm", args);
|
|
291
|
+
}
|
|
292
|
+
finally {
|
|
293
|
+
unlinkSync(tempFile);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
executeCommand("helm", args);
|
|
298
|
+
}
|
|
142
299
|
return {
|
|
143
300
|
content: [
|
|
144
301
|
{
|
|
145
302
|
type: "text",
|
|
146
|
-
text: JSON.stringify(
|
|
147
|
-
|
|
148
|
-
|
|
303
|
+
text: JSON.stringify({
|
|
304
|
+
status: "installed",
|
|
305
|
+
message: `Helm chart '${params.name}' installed successfully in namespace '${params.namespace}'`
|
|
306
|
+
})
|
|
307
|
+
}
|
|
308
|
+
]
|
|
149
309
|
};
|
|
150
310
|
}
|
|
151
311
|
catch (error) {
|
|
152
|
-
|
|
312
|
+
return {
|
|
313
|
+
content: [
|
|
314
|
+
{
|
|
315
|
+
type: "text",
|
|
316
|
+
text: JSON.stringify({
|
|
317
|
+
status: "failed",
|
|
318
|
+
error: `Failed to install Helm chart: ${error.message}`
|
|
319
|
+
})
|
|
320
|
+
}
|
|
321
|
+
]
|
|
322
|
+
};
|
|
153
323
|
}
|
|
154
324
|
}
|
|
325
|
+
/**
|
|
326
|
+
* Upgrade an existing Helm chart release.
|
|
327
|
+
* @param params - Upgrade parameters
|
|
328
|
+
* @returns Promise with upgrade result
|
|
329
|
+
*/
|
|
155
330
|
export async function upgradeHelmChart(params) {
|
|
156
331
|
try {
|
|
157
|
-
// Add
|
|
332
|
+
// Add repository if provided
|
|
158
333
|
if (params.repo) {
|
|
159
334
|
const repoName = params.chart.split("/")[0];
|
|
160
|
-
|
|
161
|
-
|
|
335
|
+
executeCommand("helm", ["repo", "add", repoName, params.repo]);
|
|
336
|
+
executeCommand("helm", ["repo", "update"]);
|
|
162
337
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
params.
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
params.namespace,
|
|
170
|
-
];
|
|
171
|
-
// Handle values if provided
|
|
338
|
+
const args = ["upgrade", params.name, params.chart, "--namespace", params.namespace];
|
|
339
|
+
// Add values file if provided
|
|
340
|
+
if (params.valuesFile) {
|
|
341
|
+
args.push("-f", params.valuesFile);
|
|
342
|
+
}
|
|
343
|
+
// Add values object if provided
|
|
172
344
|
if (params.values) {
|
|
173
|
-
const
|
|
174
|
-
|
|
345
|
+
const valuesContent = dump(params.values);
|
|
346
|
+
const tempFile = `/tmp/values-${Date.now()}.yaml`;
|
|
347
|
+
writeFileSync(tempFile, valuesContent);
|
|
175
348
|
try {
|
|
176
|
-
|
|
349
|
+
args.push("-f", tempFile);
|
|
350
|
+
executeCommand("helm", args);
|
|
177
351
|
}
|
|
178
352
|
finally {
|
|
179
|
-
|
|
180
|
-
unlinkSync(valuesFile);
|
|
353
|
+
unlinkSync(tempFile);
|
|
181
354
|
}
|
|
182
355
|
}
|
|
183
356
|
else {
|
|
184
|
-
|
|
357
|
+
executeCommand("helm", args);
|
|
185
358
|
}
|
|
186
|
-
const response = {
|
|
187
|
-
status: "upgraded",
|
|
188
|
-
message: `Successfully upgraded ${params.name}`,
|
|
189
|
-
};
|
|
190
359
|
return {
|
|
191
360
|
content: [
|
|
192
361
|
{
|
|
193
362
|
type: "text",
|
|
194
|
-
text: JSON.stringify(
|
|
195
|
-
|
|
196
|
-
|
|
363
|
+
text: JSON.stringify({
|
|
364
|
+
status: "upgraded",
|
|
365
|
+
message: `Helm chart '${params.name}' upgraded successfully in namespace '${params.namespace}'`
|
|
366
|
+
})
|
|
367
|
+
}
|
|
368
|
+
]
|
|
197
369
|
};
|
|
198
370
|
}
|
|
199
371
|
catch (error) {
|
|
200
|
-
|
|
372
|
+
return {
|
|
373
|
+
content: [
|
|
374
|
+
{
|
|
375
|
+
type: "text",
|
|
376
|
+
text: JSON.stringify({
|
|
377
|
+
status: "failed",
|
|
378
|
+
error: `Failed to upgrade Helm chart: ${error.message}`
|
|
379
|
+
})
|
|
380
|
+
}
|
|
381
|
+
]
|
|
382
|
+
};
|
|
201
383
|
}
|
|
202
384
|
}
|
|
385
|
+
/**
|
|
386
|
+
* Uninstall a Helm chart release.
|
|
387
|
+
* @param params - Uninstall parameters
|
|
388
|
+
* @returns Promise with uninstall result
|
|
389
|
+
*/
|
|
203
390
|
export async function uninstallHelmChart(params) {
|
|
204
391
|
try {
|
|
205
|
-
|
|
206
|
-
"uninstall",
|
|
207
|
-
params.name,
|
|
208
|
-
"--namespace",
|
|
209
|
-
params.namespace,
|
|
210
|
-
]);
|
|
211
|
-
const response = {
|
|
212
|
-
status: "uninstalled",
|
|
213
|
-
message: `Successfully uninstalled ${params.name}`,
|
|
214
|
-
};
|
|
392
|
+
executeCommand("helm", ["uninstall", params.name, "--namespace", params.namespace]);
|
|
215
393
|
return {
|
|
216
394
|
content: [
|
|
217
395
|
{
|
|
218
396
|
type: "text",
|
|
219
|
-
text: JSON.stringify(
|
|
220
|
-
|
|
221
|
-
|
|
397
|
+
text: JSON.stringify({
|
|
398
|
+
status: "uninstalled",
|
|
399
|
+
message: `Helm chart '${params.name}' uninstalled successfully from namespace '${params.namespace}'`
|
|
400
|
+
})
|
|
401
|
+
}
|
|
402
|
+
]
|
|
222
403
|
};
|
|
223
404
|
}
|
|
224
405
|
catch (error) {
|
|
225
|
-
|
|
406
|
+
return {
|
|
407
|
+
content: [
|
|
408
|
+
{
|
|
409
|
+
type: "text",
|
|
410
|
+
text: JSON.stringify({
|
|
411
|
+
status: "failed",
|
|
412
|
+
error: `Failed to uninstall Helm chart: ${error.message}`
|
|
413
|
+
})
|
|
414
|
+
}
|
|
415
|
+
]
|
|
416
|
+
};
|
|
226
417
|
}
|
|
227
418
|
}
|
|
@@ -14,20 +14,25 @@ export declare const kubectlApplySchema: {
|
|
|
14
14
|
readonly description: "Path to a YAML file to apply (optional - use either manifest or filename)";
|
|
15
15
|
};
|
|
16
16
|
readonly namespace: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
type: "string";
|
|
18
|
+
description: string;
|
|
19
|
+
default: string;
|
|
20
20
|
};
|
|
21
21
|
readonly dryRun: {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
type: "boolean";
|
|
23
|
+
description: string;
|
|
24
|
+
default: boolean;
|
|
25
25
|
};
|
|
26
26
|
readonly force: {
|
|
27
27
|
readonly type: "boolean";
|
|
28
28
|
readonly description: "If true, immediately remove resources from API and bypass graceful deletion";
|
|
29
29
|
readonly default: false;
|
|
30
30
|
};
|
|
31
|
+
readonly context: {
|
|
32
|
+
type: "string";
|
|
33
|
+
description: string;
|
|
34
|
+
default: string;
|
|
35
|
+
};
|
|
31
36
|
};
|
|
32
37
|
readonly required: readonly [];
|
|
33
38
|
};
|
|
@@ -38,6 +43,7 @@ export declare function kubectlApply(k8sManager: KubernetesManager, input: {
|
|
|
38
43
|
namespace?: string;
|
|
39
44
|
dryRun?: boolean;
|
|
40
45
|
force?: boolean;
|
|
46
|
+
context?: string;
|
|
41
47
|
}): Promise<{
|
|
42
48
|
content: {
|
|
43
49
|
type: string;
|
|
@@ -4,6 +4,7 @@ import * as fs from "fs";
|
|
|
4
4
|
import * as path from "path";
|
|
5
5
|
import * as os from "os";
|
|
6
6
|
import { getSpawnMaxBuffer } from "../config/max-buffer.js";
|
|
7
|
+
import { contextParameter, namespaceParameter, dryRunParameter } from "../models/common-parameters.js";
|
|
7
8
|
export const kubectlApplySchema = {
|
|
8
9
|
name: "kubectl_apply",
|
|
9
10
|
description: "Apply a Kubernetes YAML manifest from a string or file",
|
|
@@ -18,21 +19,14 @@ export const kubectlApplySchema = {
|
|
|
18
19
|
type: "string",
|
|
19
20
|
description: "Path to a YAML file to apply (optional - use either manifest or filename)",
|
|
20
21
|
},
|
|
21
|
-
namespace:
|
|
22
|
-
|
|
23
|
-
description: "Namespace to apply the resource to (optional)",
|
|
24
|
-
default: "default",
|
|
25
|
-
},
|
|
26
|
-
dryRun: {
|
|
27
|
-
type: "boolean",
|
|
28
|
-
description: "If true, only validate the resource, don't apply it",
|
|
29
|
-
default: false,
|
|
30
|
-
},
|
|
22
|
+
namespace: namespaceParameter,
|
|
23
|
+
dryRun: dryRunParameter,
|
|
31
24
|
force: {
|
|
32
25
|
type: "boolean",
|
|
33
26
|
description: "If true, immediately remove resources from API and bypass graceful deletion",
|
|
34
27
|
default: false,
|
|
35
28
|
},
|
|
29
|
+
context: contextParameter,
|
|
36
30
|
},
|
|
37
31
|
required: [],
|
|
38
32
|
},
|
|
@@ -45,6 +39,7 @@ export async function kubectlApply(k8sManager, input) {
|
|
|
45
39
|
const namespace = input.namespace || "default";
|
|
46
40
|
const dryRun = input.dryRun || false;
|
|
47
41
|
const force = input.force || false;
|
|
42
|
+
const context = input.context || "";
|
|
48
43
|
let command = "kubectl";
|
|
49
44
|
let args = ["apply"];
|
|
50
45
|
let tempFile = null;
|
|
@@ -69,6 +64,10 @@ export async function kubectlApply(k8sManager, input) {
|
|
|
69
64
|
if (force) {
|
|
70
65
|
args.push("--force");
|
|
71
66
|
}
|
|
67
|
+
// Add context if provided
|
|
68
|
+
if (context) {
|
|
69
|
+
args.push("--context", context);
|
|
70
|
+
}
|
|
72
71
|
// Execute the command
|
|
73
72
|
try {
|
|
74
73
|
const result = execFileSync(command, args, {
|
|
@@ -6,9 +6,9 @@ export declare const kubectlCreateSchema: {
|
|
|
6
6
|
readonly type: "object";
|
|
7
7
|
readonly properties: {
|
|
8
8
|
readonly dryRun: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
type: "boolean";
|
|
10
|
+
description: string;
|
|
11
|
+
default: boolean;
|
|
12
12
|
};
|
|
13
13
|
readonly output: {
|
|
14
14
|
readonly type: "string";
|
|
@@ -38,9 +38,9 @@ export declare const kubectlCreateSchema: {
|
|
|
38
38
|
readonly description: "Name of the resource to create";
|
|
39
39
|
};
|
|
40
40
|
readonly namespace: {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
type: "string";
|
|
42
|
+
description: string;
|
|
43
|
+
default: string;
|
|
44
44
|
};
|
|
45
45
|
readonly fromLiteral: {
|
|
46
46
|
readonly type: "array";
|
|
@@ -116,6 +116,11 @@ export declare const kubectlCreateSchema: {
|
|
|
116
116
|
};
|
|
117
117
|
readonly description: "Annotations to apply to the resource (e.g. [\"key1=value1\", \"key2=value2\"])";
|
|
118
118
|
};
|
|
119
|
+
readonly context: {
|
|
120
|
+
type: "string";
|
|
121
|
+
description: string;
|
|
122
|
+
default: string;
|
|
123
|
+
};
|
|
119
124
|
};
|
|
120
125
|
readonly required: readonly [];
|
|
121
126
|
};
|
|
@@ -142,6 +147,7 @@ export declare function kubectlCreate(k8sManager: KubernetesManager, input: {
|
|
|
142
147
|
annotations?: string[];
|
|
143
148
|
schedule?: string;
|
|
144
149
|
suspend?: boolean;
|
|
150
|
+
context?: string;
|
|
145
151
|
}): Promise<{
|
|
146
152
|
content: {
|
|
147
153
|
type: string;
|