mcp-server-kubernetes 2.9.1 → 2.9.2
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 +1 -253
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -270,259 +270,7 @@ The following destructive operations are disabled:
|
|
|
270
270
|
- `node_management`: Node management operations (can drain nodes)
|
|
271
271
|
- `kubectl_generic`: General kubectl command access (may include destructive operations)
|
|
272
272
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
The `helm_template_apply` tool provides an alternative way to install Helm charts that bypasses authentication issues commonly encountered with certain Kubernetes configurations. This tool is particularly useful when you encounter errors like:
|
|
276
|
-
|
|
277
|
-
```
|
|
278
|
-
WARNING: Kubernetes configuration file is group-readable. This is insecure.
|
|
279
|
-
Error: INSTALLATION FAILED: Kubernetes cluster unreachable: exec plugin: invalid apiVersion "client.authentication.k8s.io/v1alpha1"
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
Instead of using `helm install` directly, this tool:
|
|
283
|
-
|
|
284
|
-
1. Uses `helm template` to generate YAML manifests from the Helm chart
|
|
285
|
-
2. Applies the generated YAML using `kubectl apply`
|
|
286
|
-
3. Handles namespace creation and cleanup automatically
|
|
287
|
-
|
|
288
|
-
#### Usage Example
|
|
289
|
-
|
|
290
|
-
```json
|
|
291
|
-
{
|
|
292
|
-
"name": "helm_template_apply",
|
|
293
|
-
"arguments": {
|
|
294
|
-
"name": "events-exporter",
|
|
295
|
-
"chart": ".",
|
|
296
|
-
"namespace": "kube-event-exporter",
|
|
297
|
-
"valuesFile": "values.yaml",
|
|
298
|
-
"createNamespace": true
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
This is equivalent to running:
|
|
304
|
-
|
|
305
|
-
```bash
|
|
306
|
-
helm template events-exporter . -f values.yaml > events-exporter.yaml
|
|
307
|
-
kubectl create namespace kube-event-exporter
|
|
308
|
-
kubectl apply -f events-exporter.yaml -n kube-event-exporter
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
#### Parameters
|
|
312
|
-
|
|
313
|
-
- `name`: Release name for the Helm chart
|
|
314
|
-
- `chart`: Chart name or path to chart directory
|
|
315
|
-
- `repo`: Chart repository URL (optional if using local chart path)
|
|
316
|
-
- `namespace`: Kubernetes namespace to deploy to
|
|
317
|
-
- `values`: Chart values as an object (optional)
|
|
318
|
-
- `valuesFile`: Path to values.yaml file (optional, alternative to values object)
|
|
319
|
-
- `createNamespace`: Whether to create the namespace if it doesn't exist (default: true)
|
|
320
|
-
|
|
321
|
-
### Pod Cleanup with Existing Tools
|
|
322
|
-
|
|
323
|
-
Pod cleanup can be achieved using the existing `kubectl_get` and `kubectl_delete` tools with field selectors. This approach leverages standard Kubernetes functionality without requiring dedicated cleanup tools.
|
|
324
|
-
|
|
325
|
-
#### Identifying Problematic Pods
|
|
326
|
-
|
|
327
|
-
Use `kubectl_get` with field selectors to identify pods in problematic states:
|
|
328
|
-
|
|
329
|
-
**Get failed pods:**
|
|
330
|
-
|
|
331
|
-
```json
|
|
332
|
-
{
|
|
333
|
-
"name": "kubectl_get",
|
|
334
|
-
"arguments": {
|
|
335
|
-
"resourceType": "pods",
|
|
336
|
-
"namespace": "default",
|
|
337
|
-
"fieldSelector": "status.phase=Failed"
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
```
|
|
341
|
-
|
|
342
|
-
**Get completed pods:**
|
|
343
|
-
|
|
344
|
-
```json
|
|
345
|
-
{
|
|
346
|
-
"name": "kubectl_get",
|
|
347
|
-
"arguments": {
|
|
348
|
-
"resourceType": "pods",
|
|
349
|
-
"namespace": "default",
|
|
350
|
-
"fieldSelector": "status.phase=Succeeded"
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
**Get pods with specific conditions:**
|
|
356
|
-
|
|
357
|
-
```json
|
|
358
|
-
{
|
|
359
|
-
"name": "kubectl_get",
|
|
360
|
-
"arguments": {
|
|
361
|
-
"resourceType": "pods",
|
|
362
|
-
"namespace": "default",
|
|
363
|
-
"fieldSelector": "status.conditions[?(@.type=='Ready')].status=False"
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
#### Deleting Problematic Pods
|
|
369
|
-
|
|
370
|
-
Use `kubectl_delete` with field selectors to delete pods in problematic states:
|
|
371
|
-
|
|
372
|
-
**Delete failed pods:**
|
|
373
|
-
|
|
374
|
-
```json
|
|
375
|
-
{
|
|
376
|
-
"name": "kubectl_delete",
|
|
377
|
-
"arguments": {
|
|
378
|
-
"resourceType": "pods",
|
|
379
|
-
"namespace": "default",
|
|
380
|
-
"fieldSelector": "status.phase=Failed",
|
|
381
|
-
"force": true,
|
|
382
|
-
"gracePeriodSeconds": 0
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
```
|
|
386
|
-
|
|
387
|
-
**Delete completed pods:**
|
|
388
|
-
|
|
389
|
-
```json
|
|
390
|
-
{
|
|
391
|
-
"name": "kubectl_delete",
|
|
392
|
-
"arguments": {
|
|
393
|
-
"resourceType": "pods",
|
|
394
|
-
"namespace": "default",
|
|
395
|
-
"fieldSelector": "status.phase=Succeeded",
|
|
396
|
-
"force": true,
|
|
397
|
-
"gracePeriodSeconds": 0
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
```
|
|
401
|
-
|
|
402
|
-
#### Workflow
|
|
403
|
-
|
|
404
|
-
1. **First, identify problematic pods** using `kubectl_get` with appropriate field selectors
|
|
405
|
-
2. **Review the list** of pods in the response
|
|
406
|
-
3. **Delete the pods** using `kubectl_delete` with the same field selectors
|
|
407
|
-
|
|
408
|
-
#### Available Field Selectors
|
|
409
|
-
|
|
410
|
-
- `status.phase=Failed` - Pods that have failed
|
|
411
|
-
- `status.phase=Succeeded` - Pods that have completed successfully
|
|
412
|
-
- `status.phase=Pending` - Pods that are pending
|
|
413
|
-
- `status.conditions[?(@.type=='Ready')].status=False` - Pods that are not ready
|
|
414
|
-
|
|
415
|
-
#### Safety Features
|
|
416
|
-
|
|
417
|
-
- **Field selectors**: Target specific pod states precisely
|
|
418
|
-
- **Force deletion**: Use `force=true` and `gracePeriodSeconds=0` for immediate deletion
|
|
419
|
-
- **Namespace isolation**: Target specific namespaces or use `allNamespaces=true`
|
|
420
|
-
- **Standard kubectl**: Uses well-established Kubernetes patterns
|
|
421
|
-
|
|
422
|
-
### Node Management Tool
|
|
423
|
-
|
|
424
|
-
The `node_management` tool provides comprehensive node management capabilities for Kubernetes clusters, including cordoning, draining, and uncordoning operations. This is essential for cluster maintenance, scaling, and troubleshooting.
|
|
425
|
-
|
|
426
|
-
#### Operations Available
|
|
427
|
-
|
|
428
|
-
- **`list`**: List all nodes with their status and schedulability
|
|
429
|
-
- **`cordon`**: Mark a node as unschedulable (no new pods will be scheduled)
|
|
430
|
-
- **`drain`**: Safely evict all pods from a node and mark it as unschedulable
|
|
431
|
-
- **`uncordon`**: Mark a node as schedulable again
|
|
432
|
-
|
|
433
|
-
#### Usage Examples
|
|
434
|
-
|
|
435
|
-
**1. List all nodes:**
|
|
436
|
-
|
|
437
|
-
```json
|
|
438
|
-
{
|
|
439
|
-
"name": "node_management",
|
|
440
|
-
"arguments": {
|
|
441
|
-
"operation": "list"
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
```
|
|
445
|
-
|
|
446
|
-
**2. Cordon a node (mark as unschedulable):**
|
|
447
|
-
|
|
448
|
-
```json
|
|
449
|
-
{
|
|
450
|
-
"name": "node_management",
|
|
451
|
-
"arguments": {
|
|
452
|
-
"operation": "cordon",
|
|
453
|
-
"nodeName": "worker-node-1"
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
```
|
|
457
|
-
|
|
458
|
-
**3. Drain a node (dry run first):**
|
|
459
|
-
|
|
460
|
-
```json
|
|
461
|
-
{
|
|
462
|
-
"name": "node_management",
|
|
463
|
-
"arguments": {
|
|
464
|
-
"operation": "drain",
|
|
465
|
-
"nodeName": "worker-node-1",
|
|
466
|
-
"dryRun": true
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
```
|
|
470
|
-
|
|
471
|
-
**4. Drain a node (with confirmation):**
|
|
472
|
-
|
|
473
|
-
```json
|
|
474
|
-
{
|
|
475
|
-
"name": "node_management",
|
|
476
|
-
"arguments": {
|
|
477
|
-
"operation": "drain",
|
|
478
|
-
"nodeName": "worker-node-1",
|
|
479
|
-
"dryRun": false,
|
|
480
|
-
"confirmDrain": true,
|
|
481
|
-
"force": true,
|
|
482
|
-
"ignoreDaemonsets": true,
|
|
483
|
-
"timeout": "5m"
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
```
|
|
487
|
-
|
|
488
|
-
**5. Uncordon a node:**
|
|
489
|
-
|
|
490
|
-
```json
|
|
491
|
-
{
|
|
492
|
-
"name": "node_management",
|
|
493
|
-
"arguments": {
|
|
494
|
-
"operation": "uncordon",
|
|
495
|
-
"nodeName": "worker-node-1"
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
```
|
|
499
|
-
|
|
500
|
-
#### Drain Operation Parameters
|
|
501
|
-
|
|
502
|
-
- `force`: Force the operation even if there are pods not managed by controllers
|
|
503
|
-
- `gracePeriod`: Period of time in seconds given to each pod to terminate gracefully
|
|
504
|
-
- `deleteLocalData`: Delete local data even if emptyDir volumes are used
|
|
505
|
-
- `ignoreDaemonsets`: Ignore DaemonSet-managed pods (default: true)
|
|
506
|
-
- `timeout`: The length of time to wait before giving up (e.g., '5m', '1h')
|
|
507
|
-
- `dryRun`: Show what would be done without actually doing it
|
|
508
|
-
- `confirmDrain`: Explicit confirmation to drain the node (required for actual draining)
|
|
509
|
-
|
|
510
|
-
#### Safety Features
|
|
511
|
-
|
|
512
|
-
- **Dry run by default**: Drain operations default to dry run to show what would be done
|
|
513
|
-
- **Explicit confirmation**: Drain operations require `confirmDrain=true` to proceed
|
|
514
|
-
- **Status tracking**: Shows node status before and after operations
|
|
515
|
-
- **Timeout protection**: Configurable timeouts to prevent hanging operations
|
|
516
|
-
- **Graceful termination**: Configurable grace periods for pod termination
|
|
517
|
-
|
|
518
|
-
#### Common Use Cases
|
|
519
|
-
|
|
520
|
-
1. **Cluster Maintenance**: Cordon nodes before maintenance, drain them, perform maintenance, then uncordon
|
|
521
|
-
2. **Node Scaling**: Drain nodes before removing them from the cluster
|
|
522
|
-
3. **Troubleshooting**: Isolate problematic nodes by cordoning them
|
|
523
|
-
4. **Resource Management**: Drain nodes to redistribute workload
|
|
524
|
-
|
|
525
|
-
For additional advanced features, see the [ADVANCED_README.md](ADVANCED_README.md).
|
|
273
|
+
For additional advanced features, see the [ADVANCED_README.md](ADVANCED_README.md) and also the [docs](https://github.com/Flux159/mcp-server-kubernetes/tree/main/docs) folder for specific information on `helm_install`, `helm_template_apply`, node management & pod cleanup.
|
|
526
274
|
|
|
527
275
|
## Architecture
|
|
528
276
|
|