7

I'm trying to create a Persistent Volume on top of/based off of an existing Storage Class Name. Then I want to attach the PVC to it; so that they are bound. Running the code below, will give me the "sftp-pv-claim" I want, but it is not bound to my PV ("sftp-pv-storage"). It's status is "pending".

The error message I receive is: "The PersistentVolume "sftp-pv-storage" is invalid: spec: Required value: must specify a volume type". If anyone can point me in the right direction as to why I'm getting the error message, it'd be much appreciated.

Specs:

I'm creating the PV and PVC using a helm chart.

I'm using the Rancher UI to see if they are bound or not and if the PV is generated.

The storage I'm using is Ceph with Rook (to allow for dynamic provisioning of PVs).

Error:

The error message I receive is: "The PersistentVolume "sftp-pv-storage" is invalid: spec: Required value: must specify a volume type".

Attempts:

I've tried using claimRef and matchLabels to no avail.

I've added "volumetype: none" to my PV specs.

If I add "hostPath: path: "/mnt/data"" as a spec to the PV, it will show up as an Available PV (with a local node path), but my PVC is not bonded to it. (Also, for deployment purposes I don't want to use 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
4

2 回答 2

3

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

在 PV 清单中,您必须提供卷的类型。此处描述了所有受支持类型的列表。当您使用时,Ceph我假设您将使用 CephFS.

cephfs 卷允许将现有的 CephFS 卷挂载到 Pod 中。与删除 Pod 时会擦除的 emptyDir 不同,cephfs 卷的内容被保留,而卷只是被卸载。这意味着 CephFS 卷可以预先填充数据,并且可以在 Pod 之间“传递”数据。CephFS 可以由多个写入器同时挂载。

CephFS您可以在Github中找到示例。

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

如果您要查看有关storageClassName.

声明可以通过使用属性 storageClassName 指定 StorageClass 的名称来请求特定类。只有请求类的 PV,即 storageClassName 与 PVC 相同的 PV,才能绑定到 PVC。

storageClassName你的PVPVC不同的。

光伏:

spec:
  storageClassName: rook-ceph-block

PVC:

spec:
  storageClassName: sftp-pv-storage

希望它会有所帮助。

于 2019-10-09T11:51:33.133 回答
-1

您没有在 PersistentVolume 中指定“hostPath:”添加它,错误应该得到解决。请参阅下面的示例

主机路径

于 2020-11-14T15:49:49.657 回答