pvc_create
Create PersistentVolumeClaims in Kubernetes namespaces to allocate storage for applications using specified size, access modes, and storage class.
Instructions
Create a PersistentVolumeClaim in the specified namespace.
Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The PersistentVolumeClaim name storage: The storage size (e.g., "10Gi") access_modes: List of access modes (e.g., ["ReadWriteOnce"]) storage_class: The storage class name (optional)
Returns: Status of the creation operation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context_name | Yes | ||
| namespace | Yes | ||
| name | Yes | ||
| storage | Yes | ||
| access_modes | Yes | ||
| storage_class | No |
Implementation Reference
- tools/pvc.py:30-55 (handler)The pvc_create function implements the core logic of the tool: it constructs a V1PersistentVolumeClaim object using the provided parameters and uses the Kubernetes CoreV1Api to create it in the specified namespace.def pvc_create(context_name: str, namespace: str, name: str, storage: str, access_modes: list, storage_class: str = None): """ Create a PersistentVolumeClaim in the specified namespace. Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The PersistentVolumeClaim name storage: The storage size (e.g., "10Gi") access_modes: List of access modes (e.g., ["ReadWriteOnce"]) storage_class: The storage class name (optional) Returns: Status of the creation operation """ core_v1: CoreV1Api = get_api_clients(context_name)["core"] pvc = V1PersistentVolumeClaim( metadata=V1ObjectMeta(name=name), spec=V1PersistentVolumeClaimSpec( access_modes=access_modes, resources=V1ResourceRequirements(requests={"storage": storage}), storage_class_name=storage_class ) ) created_pvc = core_v1.create_namespaced_persistent_volume_claim(namespace=namespace, body=pvc) return {"name": created_pvc.metadata.name, "status": "Created"}
- tools/pvc.py:27-27 (registration)The @mcp.tool() decorator registers the pvc_create function as an MCP tool.@mcp.tool()
- tools/pvc.py:29-29 (helper)The @check_readonly_permission decorator ensures appropriate permissions for the tool.@check_readonly_permission
- tools/pvc.py:28-28 (helper)The @use_current_context decorator provides the current context for the tool.@use_current_context