27.3.6.2. 动态置备
要启用动态置备,首先请创建一个
StorageClass
对象定义。以下定义基于本示例与 OpenShift Container Platform 搭配使用所需的最低要求。如需了解更多参数和规格定义,请参阅动态置备和创建存储类。kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: glusterfs provisioner: kubernetes.io/glusterfs parameters: resturl: "http://10.42.0.0:8080" 1 restauthenabled: "false" 2
在 OpenShift Container Platform master 主机上创建 StorageClass:
# oc create -f gluster-storage-class.yaml storageclass "glusterfs" created
使用新创建的 StorageClass 创建 PVC。例如:
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: gluster1 spec: accessModes: - ReadWriteMany resources: requests: storage: 30Gi storageClassName: glusterfs
在 OpenShift Container Platform master 主机上创建 PVC:
# oc create -f glusterfs-dyn-pvc.yaml persistentvolumeclaim "gluster1" created
查看 PVC,查看卷是否动态创建并绑定到 PVC:
# oc get pvc NAME STATUS VOLUME CAPACITY ACCESSMODES STORAGECLASS AGE gluster1 Bound pvc-78852230-d8e2-11e6-a3fa-0800279cf26f 30Gi RWX glusterfs 42s