我创建了一个PV,并通过PVC声明了PV。我看到创建了PV,但PVC绑定状态停留在挂起状态。当我查看describe pvc输出时,我发现没有可用于该声明的持久卷,也没有设置存储类。从文档中,我了解到存储类不是强制性的。因此,不确定PVC文件中缺少什么。
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-ghost
labels:
pv: pv-ghost
spec:
accessModes:
- ReadWriteMany
capacity:
storage: 3Gi
hostPath:
path: /ghost/data
--------------------------
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-ghost
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi
selector:
matchLabels:
pv: pv-ghost
无法描述PV和PVC
kubectl describe pv pv-ghost
Name: pv-ghost
Labels: pv=pv-ghost
Annotations: <none>
Finalizers: [kubernetes.io/pv-protection]
StorageClass:
Status: Available
Claim:
Reclaim Policy: Retain
Access Modes: RWX
Capacity: 3Gi
Node Affinity: <none>
Message:
Source:
Type: HostPath (bare host directory volume)
Path: /ghost/data
HostPathType:
Events: <none>
kubectl describe pvc pvc-ghost
Name: pvc-ghost
Namespace: default
StorageClass:
Status: Pending
Volume:
Labels: <none>
Annotations: <none>
Finalizers: [kubernetes.io/pvc-protection]
Capacity:
Access Modes:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal FailedBinding 8m44s (x8 over 10m) persistentvolume-controller no persistent volumes available for this claim and no storage class is set
Normal FailedBinding 61s (x5 over 2m3s) persistentvolume-controller no persistent volumes available for this claim and no storage class is set
Mounted By: <none>
答案 0 :(得分:0)
您需要手动指定卷源。
ReadWriteMany仅适用于AzureFile
,CephFS
,Glusterfs
,Quobyte
,NFS
,PortworxVolume
。
Flexvolume
取决于驱动程序,VsphereVolume
可以在并置Pod时工作。
您可以在Kubernetes文档中阅读有关Volume Mode
aws的PV示例如下:
apiVersion: v1
kind: PersistentVolume
metadata:
name: efs-volume
spec:
capacity:
storage: 15Gi # Doesn't really matter, as EFS does not enforce it anyway
volumeMode: Filesystem
accessModes:
- ReadWriteMany
mountOptions:
- hard
- nfsvers=4.1
- rsize=1048576
- wsize=1048576
- timeo=300
- retrans=2
nfs:
path: /
server: fs-XXX.efs.eu-central-2.amazonaws.com
答案 1 :(得分:0)
在以上问题中,
Capacity
小于持久卷声明的容量。尝试将“持久性”卷中的Capacity
数增加到 5Gi ,或将“持久性”卷声明中的Capacity
数减少到 3Gi 。accessModes
应该为ReadWriteOnce
。答案 2 :(得分:0)
由于多节点群集中当前不支持Hostpath方法,因此结束了此问题。