在一次申明pv和pvc时,发现两者怎么都无法绑定,以下是两个文件
申明pv
apiVersion: v1
kind: PersistentVolume
metadata:
name: my-pv
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Recycle
storageClassName: nfs
nfs:
path: /data/nfs
server: 192.168.195.111
申明pvc
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: minio-data-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: nfs # 对应上面 PV 中的 storageClassName
resources:
requests:
storage: 4Gi # Adjust size as needed
原因是pv和pvc的accessModes的类型不同,导致了两者无法绑定,只需将下方的pvc更改一下accessModes的策略即可。
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: minio-data-pvc
spec:
accessModes:
- ReadWriteMany #此处需要与pv类型保持一致
storageClassName: nfs # 对应上面 PV 中的 storageClassName
resources:
requests:
storage: 4Gi # Adjust size as needed
标签:storageClassName,pv,绑定,accessModes,pvc,nfs,k8s
From: https://www.cnblogs.com/syq520/p/18324680