apiVersion: v1
kind: PersistentVolume #指定资源模板类型
metadata:
name: pv01 #指定PV名称
spec:
capacity:
storage: 2Gi #指定PV的可用大小
accessModes:
- ReadWriteMany #指定访问模式
nfs: #指定使用nfs
path: /var/nfs-data/pv01 #指定NFS上的挂载目录
server: 192.168.40.141
persistentVolumeReclaimPolicy: Retain #指定数据回收策略
|
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: app-cli #PVC名称
spec:
accessModes:
- ReadWriteMany #PVC存储访问模式
resources:
requests:
storage: 2Gi #请求存储大小
|
oc volume dc/app-cli --add \
--type=persistentVolumeClaim \
--claim-name=app-cli \
--mount-path=/opt/app-root/src/uploads
|
apiVersion: v1
kind: PersistentVolume #指定资源模板类型
metadata:
name: pv01 #指定PV名称
spec:
capacity:
storage: 2Gi #指定PV的可用大小
accessModes:
- ReadWriteMany #指定访问模式
nfs: #指定使用nfs
path: /var/nfs-data/pv01 #指定NFS上的挂载目录
server: 192.168.40.141
persistentVolumeReclaimPolicy: Retain #指定数据回收策略
|
[root@ocp ~]#
oc --config ~/admin.kubeconfig create -f pv01.yaml
persistentvolume "pv01" created
|
[root@ocp ~]#
oc get pv
|
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: app-cli #PVC名称
spec:
accessModes:
- ReadWriteMany #PVC存储访问模式
resources:
requests:
storage: 2Gi #请求存储大小
|
[root@ocp ~]#
oc --config ~/admin.kubeconfig create -f app-cli-pvc.yaml
persistentvolumeclaim "app-cli" created
|
[root@ocp ~]#
oc get pvc
|
oc volume dc/app-cli --add \
--type=persistentVolumeClaim \
--claim-name=app-cli \
--mount-path=/opt/app-root/src/uploads
|