This documentation is for a release that is no longer maintained
See documentation for the latest supported version.第 7 章 为工作区请求持久性存储
OpenShift Dev Spaces 工作区和工作区数据是临时的,并在工作区停止时丢失。
要在工作区停止期间将工作区状态保留在持久性存储中,请为您的机构 OpenShift Dev Spaces 实例的 OpenShift 集群中的 Dev Workspace
容器请求 Kubernetes PersistentVolume (PV)。
您可以使用 devfile 或 Kubernetes PersistentVolumeClaim (PVC)来请求 PV。
PV 的示例是工作区的 /projects/
目录,对于非临时工作区默认挂载它。
持久性卷以成本为:附加一个持久性卷会减慢工作空间启动的速度。
启动另一个,使用 ReadWriteOnce
PV 同时运行工作区可能会失败。
7.1. 在 devfile 中请求持久性存储 复制链接链接已复制到粘贴板!
当工作区需要自己的持久性存储时,在 devfile 中请求 PersistentVolume (PV),OpenShift Dev Spaces 将自动管理必要的 PersistentVolumeClaim。
先决条件
- 您尚未启动工作区。
流程
在 devfile 中添加
卷
组件:Copy to Clipboard Copied! Toggle word wrap Toggle overflow 在 devfile 中为相关
容器
添加volumeMount
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
例 7.1. 为容器置备 PV 的 devfile
当使用以下 devfile 启动工作区时,缓存
PV 会置备到 ./cache
容器路径中的 golang
容器: