Skip to main content
Glama

remove_node_taint

Remove taints from Kubernetes nodes to allow pod scheduling by specifying context, node name, and taint key for cluster management.

Instructions

Remove a taint from a node.

Args: context_name: The Kubernetes context name node_name: The name of the node to modify taint_key: The taint key to remove

Returns: JSON string containing the updated node taints

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
context_nameYes
node_nameYes
taint_keyYes

Implementation Reference

  • The remove_node_taint tool handler function. It removes a specified taint from a Kubernetes node by patching the node's spec taints list after filtering out the matching taint key. Includes decorators for MCP tool registration (@mcp.tool()) and context usage (@use_current_context). Returns JSON with updated taints or messages if not found/no taints.
    @mcp.tool()
    @use_current_context
    def remove_node_taint(context_name: str, node_name: str, taint_key: str):
        """
        Remove a taint from a node.
    
        Args:
            context_name: The Kubernetes context name
            node_name: The name of the node to modify
            taint_key: The taint key to remove
    
        Returns:
            JSON string containing the updated node taints
        """
        core_v1: CoreV1Api = get_api_clients(context_name)["core"]
    
        # Get the current node
        node = core_v1.read_node(node_name)
    
        # Check if the node has taints
        if not node.spec.taints:
            result = {
                "name": node_name,
                "taints": [],
                "message": "Node has no taints"
            }
            return json.dumps(result)
    
        # Filter out the taint to remove
        updated_taints = [taint for taint in node.spec.taints if taint.key != taint_key]
    
        # Check if taint was found
        if len(updated_taints) == len(node.spec.taints):
            result = {
                "name": node_name,
                "taints": [{"key": taint.key, "value": taint.value, "effect": taint.effect}
                           for taint in node.spec.taints],
                "message": f"Taint with key '{taint_key}' not found"
            }
            return json.dumps(result)
    
        # Apply the patch
        body = {
            "spec": {
                "taints": [
                    {
                        "key": taint.key,
                        "value": taint.value,
                        "effect": taint.effect
                    } for taint in updated_taints
                ]
            }
        }
    
        patched_node = core_v1.patch_node(node_name, body)
    
        # Format the taints for response
        response_taints = []
        if patched_node.spec.taints:
            response_taints = [
                {
                    "key": taint.key,
                    "value": taint.value,
                    "effect": taint.effect
                } for taint in patched_node.spec.taints
            ]
    
        result = {
            "name": patched_node.metadata.name,
            "taints": response_taints
        }
    
        return json.dumps(result)

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