pod_delete
Delete Kubernetes pods from specified namespaces using the k8s-pilot server to manage cluster resources and maintain operational efficiency.
Instructions
Delete a pod from the specified namespace.
Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The pod name to delete
Returns: Status of the deletion operation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context_name | Yes | ||
| namespace | Yes | ||
| name | Yes |
Implementation Reference
- tools/pod.py:285-331 (handler)The main handler function for the 'pod_delete' tool. It uses the Kubernetes CoreV1Api to delete a pod in the specified namespace and context. Includes decorators for MCP tool registration (@mcp.tool()), current context usage (@use_current_context), and readonly permission check (@check_readonly_permission). Returns a status dictionary indicating success, failure, or error.@mcp.tool() @use_current_context @check_readonly_permission def pod_delete(context_name: str, namespace: str, name: str): """ Delete a pod from the specified namespace. Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The pod name to delete Returns: Status of the deletion operation """ core_v1: CoreV1Api = get_api_clients(context_name)["core"] try: # Delete the pod api_response = core_v1.delete_namespaced_pod( name=name, namespace=namespace, body={} # Default deletion options ) # Check if the response indicates success if api_response.status == "Success": return { "name": name, "namespace": namespace, "status": "Deleted", "message": f"Pod {name} deleted successfully" } else: return { "name": name, "namespace": namespace, "status": "Failed", "message": f"Failed to delete pod {name}: {api_response.status}" } except Exception as e: return { "name": name, "namespace": namespace, "status": "Error", "message": f"An error occurred while deleting pod {name}: {str(e)}" }
- tools/pod.py:285-285 (registration)The @mcp.tool() decorator registers the pod_delete function as an MCP tool.@mcp.tool()