k8s_scale_deployment
Scale Kubernetes deployments to adjust replica counts for managing application capacity and resource allocation in your cluster.
Instructions
Scale a deployment to a specified number of replicas
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Deployment name | |
| namespace | No | Kubernetes namespace (default: 'default') | |
| replicas | Yes | Desired number of replicas |
Implementation Reference
- The actual implementation of the tool, performing the scale operation via Kubernetes API patch.
export async function scaleDeployment(args: Record<string, unknown>): Promise<string> { const api = getAppsV1Api(); const namespace = (args.namespace as string) || "default"; const name = args.name as string; const replicas = args.replicas as number; if (!name) throw new Error("Deployment name is required"); if (replicas === undefined) throw new Error("Replicas count is required"); const patch = { spec: { replicas } }; await api.patchNamespacedDeployment( name, namespace, patch, undefined, undefined, undefined, undefined, undefined, { headers: { "Content-Type": "application/strategic-merge-patch+json" } } ); return `Deployment '${name}' scaled to ${replicas} replicas in namespace '${namespace}'.`; } - src/tools/kubernetes/index.ts:127-138 (registration)Tool registration definition for "k8s_scale_deployment" including its input schema.
name: "k8s_scale_deployment", description: "Scale a deployment to a specified number of replicas", inputSchema: { type: "object" as const, properties: { name: { type: "string", description: "Deployment name" }, namespace: { type: "string", description: "Kubernetes namespace (default: 'default')" }, replicas: { type: "number", description: "Desired number of replicas" }, }, required: ["name", "replicas"], }, },