28.2.2. 创建持久性卷
在 OpenShift Container Platform 中创建 PV 对象前,定义了持久性卷(PV)文件:
例 28.1. 使用 NFS 的持久性卷对象定义
apiVersion: v1 kind: PersistentVolume metadata: name: nfs-pv 1 spec: capacity: storage: 1Gi 2 accessModes: - ReadWriteMany 3 persistentVolumeReclaimPolicy: Retain 4 nfs: 5 path: /opt/nfs 6 server: nfs.f22 7 readOnly: false
将 PV 定义保存到文件中,如 nfs-pv.yaml 并创建持久性卷:
# oc create -f nfs-pv.yaml persistentvolume "nfs-pv" created
验证持久性卷是否已创建:
# oc get pv NAME LABELS CAPACITY ACCESSMODES STATUS CLAIM REASON AGE nfs-pv <none> 1Gi RWX Available 37s