pvc_update
Update metadata such as labels on an existing PersistentVolumeClaim in Kubernetes to manage storage resource organization and access control.
Instructions
Update an existing PersistentVolumeClaim's metadata (e.g., labels).
Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The PersistentVolumeClaim name labels: New labels to apply to the PersistentVolumeClaim
Returns: Status of the update operation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context_name | Yes | ||
| namespace | Yes | ||
| name | Yes | ||
| labels | Yes |
Implementation Reference
- tools/pvc.py:83-103 (handler)The handler function for the 'pvc_update' MCP tool. It updates the labels on a specified PersistentVolumeClaim (PVC) in a Kubernetes namespace using the Kubernetes CoreV1 API. Decorated with @mcp.tool() for registration.@mcp.tool() @use_current_context @check_readonly_permission def pvc_update(context_name: str, namespace: str, name: str, labels: dict): """ Update an existing PersistentVolumeClaim's metadata (e.g., labels). Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The PersistentVolumeClaim name labels: New labels to apply to the PersistentVolumeClaim Returns: Status of the update operation """ core_v1: CoreV1Api = get_api_clients(context_name)["core"] pvc = core_v1.read_namespaced_persistent_volume_claim(name=name, namespace=namespace) pvc.metadata.labels = labels updated_pvc = core_v1.patch_namespaced_persistent_volume_claim(name=name, namespace=namespace, body={"metadata": {"labels": labels}}) return {"name": updated_pvc.metadata.name, "status": "Updated", "labels": updated_pvc.metadata.labels}