pv_create
Create PersistentVolumes in Kubernetes clusters to provide storage resources for applications, specifying capacity, access modes, and storage class.
Instructions
Create a PersistentVolume in the cluster.
Args: context_name: The Kubernetes context name name: The PersistentVolume name capacity: The storage capacity (e.g., "10Gi") access_modes: List of access modes (e.g., ["ReadWriteOnce"]) storage_class: The storage class name host_path: The host path for the volume
Returns: Status of the creation operation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context_name | Yes | ||
| name | Yes | ||
| capacity | Yes | ||
| access_modes | Yes | ||
| storage_class | Yes | ||
| host_path | Yes |
Implementation Reference
- tools/pv.py:29-55 (handler)The handler function for the 'pv_create' tool. It creates a Kubernetes PersistentVolume with the specified parameters using the CoreV1Api.def pv_create(context_name: str, name: str, capacity: str, access_modes: list, storage_class: str, host_path: str): """ Create a PersistentVolume in the cluster. Args: context_name: The Kubernetes context name name: The PersistentVolume name capacity: The storage capacity (e.g., "10Gi") access_modes: List of access modes (e.g., ["ReadWriteOnce"]) storage_class: The storage class name host_path: The host path for the volume Returns: Status of the creation operation """ core_v1: CoreV1Api = get_api_clients(context_name)["core"] pv = V1PersistentVolume( metadata=V1ObjectMeta(name=name), spec=V1PersistentVolumeSpec( capacity={"storage": capacity}, access_modes=access_modes, storage_class_name=storage_class, host_path={"path": host_path} ) ) created_pv = core_v1.create_persistent_volume(body=pv) return {"name": created_pv.metadata.name, "status": "Created"}
- tools/pv.py:26-28 (registration)Decorators registering and configuring the 'pv_create' tool with MCP, context usage, and read-only permission check.@mcp.tool() @use_current_context @check_readonly_permission