kubernetes - PersistentVolume 无效 : spec: Required value: must specify a volume type

标签 kubernetes kubernetes-helm kubernetes-rook rook-storage

我正在尝试在现有存储类名称之上/基于现有存储类名称创建一个持久卷。然后我想把PVC贴在上面;使他们被束缚。运行下面的代码,会给我我想要的“sftp-pv-claim”,但它没有绑定(bind)到我的 PV(“sftp-pv-storage”)。它的状态是“待定”。

我收到的错误消息是:“PersistentVolume “sftp-pv-storage”无效:规范:必需值:必须指定卷类型”。如果有人能指出我为什么会收到错误消息的正确方向,我们将不胜感激。

规范:

我正在使用 Helm 图创建 PV 和 PVC。

我正在使用 Rancher UI 来查看它们是否被绑定(bind)以及是否生成了 PV。

我使用的存储是带有 Rook 的 Ceph(允许动态配置 PV)。

错误:

我收到的错误消息是:“PersistentVolume “sftp-pv-storage”无效:规范:必需值:必须指定卷类型”。

尝试:

我试过使用 claimRef 和 matchLabels 无济于事。

我在我的 PV 规范中添加了“volumetype: none”。

如果我将 "hostPath: path: "/mnt/data""作为规范添加到 PV,它将显示为可用 PV(具有本地节点路径),但我的 PVC 未绑定(bind)到它。 (另外,出于部署目的,我不想使用 hostPath。

## Create Persistent Storage for SFTP
## Ref: https://www.cloudtechnologyexperts.com/kubernetes-persistent-volume-with-rook/

kind: PersistentVolume
apiVersion: v1
metadata:
  name: sftp-pv-storage
  labels:
    type: local
    name: sftp-pv-storage
spec:
  storageClassName: rook-ceph-block
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  allowVolumeExpansion: true
  volumetype: none

---
## Create Claim (links user to PV)
##  ==> If pod is created, need to automatically create PVC for user (without their input)

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: sftp-pv-claim
spec:
  storageClassName: sftp-pv-storage
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi

最佳答案

PersistentVolume“sftp-pv-storage”无效:spec:Requiredvalue:必须指定卷类型。

在 PV list 中,您必须提供卷的类型。描述了所有支持类型的列表here .
当您使用 Ceph我假设你会使用 CephFS .

A cephfs volume allows an existing CephFS volume to be mounted into your Pod. Unlike emptyDir, which is erased when a Pod is removed, the contents of a cephfs volume are preserved and the volume is merely unmounted. This means that a CephFS volume can be pre-populated with data, and that data can be “handed off” between Pods. CephFS can be mounted by multiple writers simultaneously.


CephFS 的示例您可以在 Github 中找到.

如果我将 "hostPath: path: "/mnt/data""作为规范添加到 PV,它将显示为可用 PV(具有本地节点路径),但我的 PVC 未绑定(bind)到它。

如果您要查看 Official Kubernetes docs关于 storageClassName .

A claim can request a particular class by specifying the name of a StorageClass using the attribute storageClassName. Only PVs of the requested class, ones with the same storageClassName as the PVC, can be bound to the PVC.


storageClassName您的PVPVC是不同的。

光伏:
spec:
  storageClassName: rook-ceph-block

PVC:
spec:
  storageClassName: sftp-pv-storage

希望它会有所帮助。

关于kubernetes - PersistentVolume 无效 : spec: Required value: must specify a volume type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58226536/

相关文章:

kubernetes - 为每个命名空间设置Helm RBAC

redis - 如何从 Kubernetes 集群中的应用程序连接 Redis 集群?

amazon-web-services - 需要有关 kubernetes 卷挂载问题的帮助

JupyterHub Helm 安装 : function "dig" not defined

kubernetes - Rookv1.2不会在CrushMap上添加标签

kubernetes - 如何在 Kubernetes 中指定 pod 到节点的亲和性

kubernetes - 找出集群中使用 ConfigMap 值的位置

kubernetes - 单节点集群(minikube)上的 rook ceph 中出现 1 pg 尺寸过小的健康警告

kubernetes - k8s volume.attachments中的节点字段意味着什么?

postgresql - 无法从外部机器连接到 Postgres(通过 Kubernetes Helm 安装)服务,连接被拒绝