create-ephemeral-container
Debug Kubernetes pods by creating temporary containers to run diagnostic commands and troubleshoot issues without restarting the pod.
Instructions
Create an ephemeral debug container in a pod
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pod | Yes | The name of the pod | |
| image | Yes | The container image to use for debugging | |
| name | Yes | The name of the ephemeral container | |
| namespace | No | The namespace of the pod (optional, defaults to current context namespace) | |
| command | No | The command to run in the container |
Implementation Reference
- server.js:2213-2222 (handler)The handler function for the 'create-ephemeral-container' tool. It destructures the arguments, constructs a kubectl debug command with ephemeral container options, executes it via execAsync, and returns the stdout or a success message.case "create-ephemeral-container": { const { pod, image, name, namespace, command } = args; const nsArg = namespace ? `-n ${namespace}` : ""; const commandArg = command ? `-- ${command}` : ""; const cmd = `kubectl debug ${pod} ${nsArg} --image=${image} --container=${name} --ephemeral-containers ${commandArg}`; const { stdout } = await execAsync(cmd); return { content: [{ type: "text", text: stdout || `Ephemeral container ${name} created in pod ${pod}` }] }; }
- server.js:1326-1354 (registration)The tool registration entry in the tools array, which includes the name, description, and inputSchema. This is returned by the ListToolsRequestHandler.name: "create-ephemeral-container", description: "Create an ephemeral debug container in a pod", inputSchema: { type: "object", properties: { pod: { type: "string", description: "The name of the pod" }, image: { type: "string", description: "The container image to use for debugging" }, name: { type: "string", description: "The name of the ephemeral container" }, namespace: { type: "string", description: "The namespace of the pod (optional, defaults to current context namespace)" }, command: { type: "string", description: "The command to run in the container" } }, required: ["pod", "image", "name"] } },
- server.js:1328-1353 (schema)The inputSchema defining the parameters for the create-ephemeral-container tool, including required fields pod, image, name.inputSchema: { type: "object", properties: { pod: { type: "string", description: "The name of the pod" }, image: { type: "string", description: "The container image to use for debugging" }, name: { type: "string", description: "The name of the ephemeral container" }, namespace: { type: "string", description: "The namespace of the pod (optional, defaults to current context namespace)" }, command: { type: "string", description: "The command to run in the container" } }, required: ["pod", "image", "name"] }