upgrade_helm_chart
Upgrades an existing Helm chart release in Kubernetes by applying new configurations or versions to maintain application deployments.
Instructions
Upgrade an existing Helm chart release
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the Helm release to upgrade | |
| chart | Yes | Chart name or path to chart directory | |
| namespace | Yes | Kubernetes namespace | default |
| context | No | Kubeconfig Context to use for the command (optional - defaults to null) | |
| repo | No | Helm repository URL (optional if using local chart path) | |
| values | No | Custom values to override chart defaults | |
| valuesFile | No | Path to values file (alternative to values object) |
Implementation Reference
- src/tools/helm-operations.ts:383-447 (handler)The primary handler function that executes the 'helm upgrade' command, managing repositories, values files/objects, temporary files, and error handling.export async function upgradeHelmChart( params: HelmUpgradeOperation ): Promise<{ content: { type: string; text: string }[] }> { try { // Add repository if provided if (params.repo) { const repoName = params.chart.split("/")[0]; executeCommand("helm", ["repo", "add", repoName, params.repo]); executeCommand("helm", ["repo", "update"]); } const args = [ "upgrade", params.name, params.chart, "--namespace", params.namespace, ]; // Add values file if provided if (params.valuesFile) { args.push("-f", params.valuesFile); } // Add values object if provided if (params.values) { const valuesContent = dump(params.values); const tempFile = `/tmp/values-${Date.now()}.yaml`; writeFileSync(tempFile, valuesContent); try { args.push("-f", tempFile); executeCommand("helm", args); } finally { unlinkSync(tempFile); } } else { executeCommand("helm", args); } return { content: [ { type: "text", text: JSON.stringify({ status: "upgraded", message: `Helm chart '${params.name}' upgraded successfully in namespace '${params.namespace}'`, }), }, ], }; } catch (error: any) { return { content: [ { type: "text", text: JSON.stringify({ status: "failed", error: `Failed to upgrade Helm chart: ${error.message}`, }), }, ], }; } }
- src/tools/helm-operations.ts:90-124 (schema)The JSON schema defining the input parameters and structure for the upgrade_helm_chart tool.export const upgradeHelmChartSchema = { name: "upgrade_helm_chart", description: "Upgrade an existing Helm chart release", annotations: { destructiveHint: true, }, inputSchema: { type: "object", properties: { name: { type: "string", description: "Name of the Helm release to upgrade", }, chart: { type: "string", description: "Chart name or path to chart directory", }, namespace: namespaceParameter, context: contextParameter, repo: { type: "string", description: "Helm repository URL (optional if using local chart path)", }, values: { type: "object", description: "Custom values to override chart defaults", }, valuesFile: { type: "string", description: "Path to values file (alternative to values object)", }, }, required: ["name", "chart", "namespace"], }, };
- src/index.ts:435-446 (registration)The switch case in the CallToolRequestSchema handler that registers and dispatches execution of the upgrade_helm_chart tool to its handler function.case "upgrade_helm_chart": { return await upgradeHelmChart( input as { name: string; chart: string; repo: string; namespace: string; values?: Record<string, any>; context?: string; } ); }
- src/index.ts:123-123 (registration)Inclusion of the upgradeHelmChartSchema in the allTools array, making it available via ListToolsRequest.upgradeHelmChartSchema,
- src/index.ts:5-11 (registration)Import statement bringing the handler and schema into the main index file for registration.installHelmChart, installHelmChartSchema, upgradeHelmChart, upgradeHelmChartSchema, uninstallHelmChart, uninstallHelmChartSchema, } from "./tools/helm-operations.js";