This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.4.4. 使用 Cinder 的持久性存储
OpenShift Container Platform 支持 OpenStack Cinder。我们假设您对 Kubernetes 和 OpenStack 有一定的了解。
Cinder 卷可以动态置备。持久性卷不与某个特定项目或命名空间相关联,它们可以在 OpenShift Container Platform 集群间共享。持久性卷声明是针对某个项目或者命名空间的,相应的用户可请求它。
OpenShift Container Platform 默认使用 in-tree(非 CSI)插件来置备 Cinder 存储。
在以后的 OpenShift Container Platform 版本中,计划使用现有树内插件置备的卷迁移到对应的 CSI 驱动程序。CSI 自动迁移应该可以无缝进行。迁移不会改变您使用所有现有 API 对象的方式,如持久性卷、持久性卷声明和存储类。有关迁移的更多信息,请参阅 CSI 自动迁移。
完全迁移后,未来的 OpenShift Container Platform 版本将最终删除树内插件。
4.4.1. 使用 Cinder 手动置备
当存储可以被挂载为 OpenShift Container Platform 中的卷之前,它必须已存在于底层的存储系统中。
先决条件
- 为 Red Hat OpenStack Platform(RHOSP)配置 OpenShift Container Platform
- Cinder 卷 ID
4.4.1.1. 创建持久性卷
您必须在对象定义中定义持久性卷 (PV) ,然后才能在 OpenShift Container Platform 中创建它:
流程
- 将对象定义保存到文件中。 - cinder-persistentvolume.yaml - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 重要- 在卷被格式化并置备后,不要更改 - fstype参数的值。更改此值可能会导致数据丢失和 pod 失败。
- 创建在上一步中保存的对象定义文件。 - oc create -f cinder-persistentvolume.yaml - $ oc create -f cinder-persistentvolume.yaml- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
4.4.1.2. 持久性卷格式化
因为 OpenShift Container Platform 在首次使用卷前会进行格式化,所以可以使用未格式化的 Cinder 卷作为 PV。
						在 OpenShift Container Platform 挂载卷并将其传递给容器之前,它会检查在 PV 定义中是否包含由 fsType 参数指定的文件系统。如果没有使用文件系统格式化该设备,该设备中的所有数据都会被删除,并使用指定的文件系统自动格式化该设备。
					
4.4.1.3. Cinder 卷安全
如果在应用程序中使用 Cinder PV,请在其部署配置中配置安全性。
先决条件
- 
								必须创建一个使用适当 fsGroup策略的 SCC。
流程
- 创建一个服务帐户并将其添加到 SCC: - oc create serviceaccount <service_account> - $ oc create serviceaccount <service_account>- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - oc adm policy add-scc-to-user <new_scc> -z <service_account> -n <project> - $ oc adm policy add-scc-to-user <new_scc> -z <service_account> -n <project>- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- 在应用程序的部署配置中,提供服务帐户名称和 - securityContext:- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow