pv_create
Creates a PersistentVolume in a Kubernetes cluster by specifying context, name, capacity, access modes, storage class, and host path for efficient storage management.
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 |
|---|---|---|---|
| access_modes | Yes | ||
| capacity | Yes | ||
| context_name | Yes | ||
| host_path | Yes | ||
| name | Yes | ||
| storage_class | Yes |
Implementation Reference
- tools/pv.py:26-55 (handler)The pv_create tool handler: creates a PersistentVolume in Kubernetes cluster using the CoreV1Api. Registered via @mcp.tool() decorator.@mcp.tool() @use_current_context @check_readonly_permission 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-26 (registration)Registration of the pv_create tool using the @mcp.tool() decorator.@mcp.tool()