Skip to main content
Glama

cordon_node

Mark a Kubernetes node as unschedulable to prevent new pods from being scheduled on it, useful for maintenance or troubleshooting operations.

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
NameRequiredDescriptionDefault
context_nameYes
node_nameYes

Implementation Reference

  • The cordon_node tool handler: decorates with @mcp.tool() and @use_current_context, reads the node, checks if already cordoned, patches spec.unschedulable to True if not, returns JSON status.
    @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)
  • tools/node.py:355-355 (registration)
    Registers the cordon_node function as an MCP tool using the @mcp.tool() decorator.
    @mcp.tool()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bourbonkk/k8s-pilot'

If you have feedback or need assistance with the MCP directory API, please join our Discord server