remove_annotation
Remove specific annotations from Kubernetes resources, such as pods, services, or deployments, by specifying the resource type, name, and annotation key. Simplifies Kubernetes management through targeted cleanup.
Instructions
Remove an annotation from a Kubernetes resource
Args:
resource_type: Type of the resource (e.g., pod, service, deployment)
resource_name: Name of the resource to remove the annotation from
annotation_key: Key of the annotation to remove
namespace: Namespace of the resource
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| annotation_key | Yes | ||
| namespace | No | default | |
| resource_name | Yes | ||
| resource_type | Yes |
Implementation Reference
- kubernetes.py:261-278 (handler)The main handler function for the 'remove_annotation' MCP tool. Decorated with @mcp.tool() which registers it. Executes kubectl annotate command with the annotation key suffixed by '-' to remove the annotation from the specified Kubernetes resource.@mcp.tool() async def remove_annotation(resource_type: str, resource_name: str, annotation_key: str, namespace: str = "default") -> dict: """Remove an annotation from a Kubernetes resource Args: resource_type: Type of the resource (e.g., pod, service, deployment) resource_name: Name of the resource to remove the annotation from annotation_key: Key of the annotation to remove namespace: Namespace of the resource """ try: cmd = ["kubectl", "annotate", resource_type, resource_name, f"{annotation_key}-", "-n", namespace, "--overwrite"] result = subprocess.run(cmd, capture_output=True, text=True, check=True) return {"message": f"Annotation {annotation_key} removed from resource {resource_type}/{resource_name} in namespace {namespace}", "details": result.stdout} except subprocess.CalledProcessError as e: return {"error": f"Failed to remove annotation: {str(e)}"}