create-backup
Back up Kubernetes cluster resources to a specified file, optionally filtering by namespace to protect configurations and data.
Instructions
Create a backup of cluster resources
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| namespace | No | The namespace to backup (optional, backs up all namespaces if not specified) | |
| output | No | Output file path for the backup |
Implementation Reference
- server.js:2237-2244 (handler)The handler logic for the 'create-backup' tool. It executes a kubectl command to get all resources (in specified namespace or all) in YAML format and saves to the provided output file path (defaults to 'backup.yaml'). Returns success message or stdout.
const { namespace, output = "backup.yaml" } = args || {}; const nsArg = namespace ? `-n ${namespace}` : "--all-namespaces"; const cmd = `kubectl get all ${nsArg} -o yaml > ${output}`; const { stdout } = await execAsync(cmd); return { content: [{ type: "text", text: stdout || `Backup created in ${output}` }] }; } - server.js:1373-1388 (registration)Tool registration in the tools list returned by ListToolsRequestHandler, including name, description, and inputSchema.
name: "create-backup", description: "Create a backup of cluster resources", inputSchema: { type: "object", properties: { namespace: { type: "string", description: "The namespace to backup (optional, backs up all namespaces if not specified)" }, output: { type: "string", description: "Output file path for the backup" } } } } - server.js:1376-1387 (schema)Input schema definition for the 'create-backup' tool, defining optional namespace and output file path parameters.
type: "object", properties: { namespace: { type: "string", description: "The namespace to backup (optional, backs up all namespaces if not specified)" }, output: { type: "string", description: "Output file path for the backup" } } }