cordon_node
Mark a Kubernetes node as unschedulable by cordoning it using the 'k8s-pilot' MCP server. Specify context and node name to isolate the node for maintenance or updates.
Instructions
Cordon a node (mark as unschedulable).
Args: context_name: The Kubernetes context name node_name: The name of the node to cordon
Returns: JSON string containing the result of the operation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context_name | Yes | ||
| node_name | Yes |
Implementation Reference
- tools/node.py:355-397 (handler)The main handler function for the 'cordon_node' tool. It is decorated with @mcp.tool() which registers it as an MCP tool. The function cords a Kubernetes node by setting spec.unschedulable to True via the Kubernetes API, after checking if it's already cordoned.@mcp.tool() @use_current_context def cordon_node(context_name: str, node_name: str): """ Cordon a node (mark as unschedulable). Args: context_name: The Kubernetes context name node_name: The name of the node to cordon Returns: JSON string containing the result of the operation """ core_v1: CoreV1Api = get_api_clients(context_name)["core"] # Get the current node node = core_v1.read_node(node_name) # Check if already cordoned if node.spec.unschedulable: result = { "name": node_name, "status": "already cordoned", "unschedulable": True } return json.dumps(result) # Apply the patch body = { "spec": { "unschedulable": True } } patched_node = core_v1.patch_node(node_name, body) result = { "name": patched_node.metadata.name, "status": "cordoned", "unschedulable": patched_node.spec.unschedulable } return json.dumps(result)