> ## Documentation Index
> Fetch the complete documentation index at: https://docs.siflow.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 使用静态存储卷

> 为已有后端存储创建 PV，并通过 PVC 将该存储提供给命名空间中的工作负载使用。

静态存储卷适用于后端存储已经存在，或存储资源需要提前由管理员准备的场景。您需要先为后端存储创建 PV，再创建 PVC 与该 PV 绑定。

## 操作前确认

* 已准备可供 CKS 集群使用的后端存储卷。
* 已获取创建 PV 所需的容量、访问模式、CSI 驱动名称和唯一卷标识等信息。具体字段和值由存储后端或存储管理员提供。

## 创建 PV

1. 登录 [GPU 云服务控制台](https://console.siflow.cn/gpu-cloud/home)，进入 **集群** 页面。

2. 在 **集群** 页面单击目标集群名称，进入集群工作台。

3. 在左侧导航中进入 **存储** 页面，切换到 **PV** 页签，单击 **创建**。

4. 设置 **Name**，并在 **Spec (YAML)** 中填写 PV 配置。

   | 配置项 | 说明 |
   | - | - |
   | `capacity.storage` | 设置 PV 提供的容量。 |
   | `accessModes` | 设置存储卷支持的访问模式，必须与后续 PVC 的申请兼容。 |
   | `persistentVolumeReclaimPolicy` | 设置 PVC 释放后 PV 的回收方式。需要保留数据时，选择 `Retain`。 |
   | `storageClassName` | 设置用于筛选和匹配 PVC 的存储类值。使用静态存储卷时，PV 和 PVC 中的值应保持一致；该字段不会自动创建 PV。 |
   | `csi.driver` | 填写实际 CSI 驱动名称。 |
   | `csi.volumeHandle` | 填写后端存储卷的唯一标识。 |

   以下 YAML 展示 CSI PV 的基本结构。请将占位符替换为存储后端提供的实际值，并按存储插件要求补充其他字段。

   ```yaml theme={null}
   metadata:
     labels: {}
     annotations: {}
   spec:
     capacity:
       storage: 100Gi
     accessModes:
       - ReadWriteMany
     persistentVolumeReclaimPolicy: Retain
     storageClassName: manual
     volumeMode: Filesystem
     csi:
       driver: <CSI_DRIVER_NAME>
       volumeHandle: <UNIQUE_VOLUME_ID>
   ```

5. 单击 **Create**。

<img src="https://mintcdn.com/siflow/Z3oydoQ8jnJ7q_Ig/gpu-cloud/media/cluster-create-pv.png?fit=max&auto=format&n=Z3oydoQ8jnJ7q_Ig&q=85&s=56d808ad4cfc07ce7771bce152144bab" alt="创建 PV" width="3296" height="1674" data-path="gpu-cloud/media/cluster-create-pv.png" />

## 创建 PVC 并绑定 PV

1. 在 **存储** 页面切换到 **PVC** 页签，单击 **创建**。

2. 配置 PVC。

   | 参数 | 说明 |
   | - | - |
   | **Name** | 设置 PVC 名称。工作负载通过该名称引用 PVC。 |
   | **Namespace** | 选择 PVC 所属命名空间。 |
   | **Spec (YAML)** | 填写 PVC 的 `metadata` 和 `spec`。不要填写 `apiVersion` 或 `kind`。 |

   `volumeName` 应填写前一步创建的 PV 名称。申请容量不能大于 PV 容量，`accessModes`、`storageClassName` 和 `volumeMode` 应与 PV 兼容。

   ```yaml theme={null}
   metadata:
     labels: {}
     annotations: {}
   spec:
     accessModes:
       - ReadWriteMany
     resources:
       requests:
         storage: 100Gi
     storageClassName: manual
     volumeName: training-data-pv
     volumeMode: Filesystem
   ```

3. 单击 **Create**。

4. 返回 **PVC** 页签，确认 PVC 状态变为 `Bound`；同时在 **PV** 页签确认目标 PV 已与该 PVC 绑定。

## 后续操作

PVC 状态为 `Bound` 后，可以[为工作负载挂载持久化存储](/gpu-cloud/cluster/mount-persistent-storage-to-workload)。不再需要 PVC 或 PV 时，参考[清理持久化存储资源](/gpu-cloud/cluster/cleanup-persistent-storage-resources)。

## 常见问题

<Accordion defaultOpen title="PVC 无法与指定 PV 绑定怎么办？">
  确认 `volumeName` 与 PV 名称完全一致，并检查申请容量、访问模式、`storageClassName` 和 `volumeMode` 是否与 PV 兼容。目标 PV 还必须处于可绑定状态，不能已经绑定到其他 PVC。
</Accordion>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.