我创建了一个PersistentVolume,它源于我已经格式化并提供数据的Google Compute Engine永久磁盘.Kubernetes说PersistentVolume可用.
I created a PersistentVolume sourced from a Google Compute Engine persistent disk that I already formatted and provision with data. Kubernetes says the PersistentVolume is available.
kind: PersistentVolume apiVersion: v1 metadata: name: models-1-0-0 labels: name: models-1-0-0 spec: capacity: storage: 200Gi accessModes: - ReadOnlyMany gcePersistentDisk: pdName: models-1-0-0 fsType: ext4 readOnly: true然后我创建了一个PersistentVolumeClaim,以便可以将此卷附加到多个节点上的多个Pod.但是,kubernetes无限期地表示它处于挂起状态.
I then created a PersistentVolumeClaim so that I could attach this volume to multiple pods across multiple nodes. However, kubernetes indefinitely says it is in a pending state.
kind: PersistentVolumeClaim apiVersion: v1 metadata: name: models-1-0-0-claim spec: accessModes: - ReadOnlyMany resources: requests: storage: 200Gi selector: matchLabels: name: models-1-0-0有什么见解?我觉得选择器可能有问题...
Any insights? I feel there may be something wrong with the selector...
是否甚至可以用数据预配置永久性磁盘,并使跨多个节点的Pod都可以从中读取数据?
Is it even possible to preconfigure a persistent disk with data and have pods across multiple nodes all be able to read from it?
推荐答案我很快意识到,如果未指定,PersistentVolumeClaim将 storageClassName 字段默认为 standard .但是,在创建PersistentVolume时, storageClassName 没有默认值,因此选择器找不到匹配项.
I quickly realized that PersistentVolumeClaim defaults the storageClassName field to standard when not specified. However, when creating a PersistentVolume, storageClassName does not have a default, so the selector doesn't find a match.
以下内容对我有用:
kind: PersistentVolume apiVersion: v1 metadata: name: models-1-0-0 labels: name: models-1-0-0 spec: capacity: storage: 200Gi storageClassName: standard accessModes: - ReadOnlyMany gcePersistentDisk: pdName: models-1-0-0 fsType: ext4 readOnly: true --- kind: PersistentVolumeClaim apiVersion: v1 metadata: name: models-1-0-0-claim spec: accessModes: - ReadOnlyMany resources: requests: storage: 200Gi selector: matchLabels: name: models-1-0-0更多推荐
Kubernetes持久卷在未决状态下无限期主张
发布评论