pod_update
Update Kubernetes pod labels efficiently within specified context and namespace using k8s-pilot. Streamline metadata management across multiple clusters.
Instructions
Update an existing pod's metadata (only labels can be updated for an existing pod).
Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The pod name labels: New labels to apply to the pod
Returns: Information about the updated pod
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context_name | Yes | ||
| labels | No | ||
| name | Yes | ||
| namespace | Yes |
Implementation Reference
- tools/pod.py:243-282 (handler)The pod_update tool handler decorated with @mcp.tool() for registration and permission checks. It reads the existing pod, updates its labels if provided, patches it via Kubernetes API, and returns status info.@mcp.tool() @use_current_context @check_readonly_permission def pod_update(context_name: str, namespace: str, name: str, labels: Optional[Dict[str, str]] = None): """ Update an existing pod's metadata (only labels can be updated for an existing pod). Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The pod name labels: New labels to apply to the pod Returns: Information about the updated pod """ core_v1: CoreV1Api = get_api_clients(context_name)["core"] # Get the current pod pod = core_v1.read_namespaced_pod(name=name, namespace=namespace) # Update pod labels if provided if labels: pod.metadata.labels = labels # Update the pod in Kubernetes updated_pod = core_v1.patch_namespaced_pod( name=name, namespace=namespace, body={"metadata": {"labels": labels}} ) result = { "name": updated_pod.metadata.name, "namespace": updated_pod.metadata.namespace, "status": updated_pod.status.phase, "labels": updated_pod.metadata.labels, } return result
- tools/pod.py:243-243 (registration)The @mcp.tool() decorator registers the pod_update function as an MCP tool.@mcp.tool()