apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: custom-csi-storageclass
provisioner: cinder.csi.openstack.org
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
parameters:
availability: <availability_zone_name>
在 Red Hat OpenStack Platform (RHOSP) 上安装集群后,您可以使用特定可用区中的 Cinder 卷作为注册表存储。
创建一个 YAML 文件,指定要使用的存储类和可用区。例如
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: custom-csi-storageclass
provisioner: cinder.csi.openstack.org
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
parameters:
availability: <availability_zone_name>
OpenShift Container Platform 不会验证您选择的可用区是否存在。应用配置之前,请验证可用区名称。 |
从命令行应用配置
$ oc apply -f <storage_class_file_name>
storageclass.storage.k8s.io/custom-csi-storageclass created
创建一个 YAML 文件,指定使用您的存储类和 `openshift-image-registry` 命名空间的持久卷声明 (PVC)。例如
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: csi-pvc-imageregistry
namespace: openshift-image-registry (1)
annotations:
imageregistry.openshift.io: "true"
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: 100Gi (2)
storageClassName: <your_custom_storage_class> (3)
1 | 进入 `openshift-image-registry` 命名空间。此命名空间允许集群镜像注册表操作员使用 PVC。 |
2 | 可选:调整卷大小。 |
3 | 输入您创建的存储类的名称。 |
从命令行应用配置
$ oc apply -f <pvc_file_name>
persistentvolumeclaim/csi-pvc-imageregistry created
将镜像注册表配置中的原始持久卷声明替换为新的声明
$ oc patch configs.imageregistry.operator.openshift.io/cluster --type 'json' -p='[{"op": "replace", "path": "/spec/storage/pvc/claim", "value": "csi-pvc-imageregistry"}]'
config.imageregistry.operator.openshift.io/cluster patched
接下来几分钟内,配置将更新。
要确认注册表是否正在使用您定义的资源
验证 PVC 声明值是否与您在 PVC 定义中提供的名称相同
$ oc get configs.imageregistry.operator.openshift.io/cluster -o yaml
...
status:
...
managementState: Managed
pvc:
claim: csi-pvc-imageregistry
...
验证 PVC 的状态是否为 `Bound`
$ oc get pvc -n openshift-image-registry csi-pvc-imageregistry
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
csi-pvc-imageregistry Bound pvc-72a8f9c9-f462-11e8-b6b6-fa163e18b7b5 100Gi RWO custom-csi-storageclass 11m