Kubernetes持久卷在未决状态下无限期主张 [英] Kubernetes Persistent Volume Claim Indefinitely in Pending State

查看:54
本文介绍了Kubernetes持久卷在未决状态下无限期主张的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个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持久卷在未决状态下无限期主张的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆