This documentation is for a release that is no longer maintained
See documentation for the latest supported version.7.2. 在 PVC 中请求持久性存储
在以下情况下,您可以选择应用 PersistentVolumeClaim (PVC)来为您的工作区请求 PersistentVolume (PV):
- 并非所有项目开发人员都需要 PV。
- PV 生命周期超出了一个工作区的生命周期。
- PV 中包含的数据在工作区间共享。
即使工作区是临时的,并且其 devfile 包含 controller.devfile.io/storage-type: ephemeral
属性,也可以将 PVC 应用到 Dev Workspace
容器。
先决条件
- 您尚未启动工作区。
-
对目标 OpenShift 集群具有管理权限的活动
oc
会话。请参阅 CLI 入门。 -
在用户项目中创建一个 PVC,以挂载到所有
Dev Workspace
容器。
流程
将
controller.devfile.io/mount-to-devworkspace: true
标签添加到 PVC。oc label persistentvolumeclaim <PVC_name> \ controller.devfile.io/mount-to-devworkspace=true
$ oc label persistentvolumeclaim <PVC_name> \ controller.devfile.io/mount-to-devworkspace=true$ oc label persistentvolumeclaim <PVC_name> \ controller.devfile.io/mount-to-devworkspace=true$ oc label persistentvolumeclaim <PVC_name> \ controller.devfile.io/mount-to-devworkspace=true
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 可选:使用注解来配置如何挂载 PVC:
Expand 表 7.1. 可选注解 注解 描述 controller.devfile.io/mount-path:
PVC 的挂载路径。
默认为
/tmp/<PVC_name>
。controller.devfile.io/read-only:
设置为
'true'
或'false'
,以指定 PVC 被挂载为只读。默认为
'false'
,从而导致 PVC 挂载为读/写。
例 7.2. 挂载只读 PVC