The PersistentVolume is invalid: spec: Required value: must specify a volume type

10/3/2019

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
-- CodeNewb
kubernetes
kubernetes-helm
kubernetes-rook
rook-storage

2 Answers

10/4/2019

Try this spec for your persistent volume claim-

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

I have just added volume name there, I guess this would get it bound. If this even doesn't work, try to add appropriate volumeMode in this spec too

-- Tushar Mahajan
Source: StackOverflow

10/9/2019

The PersistentVolume "sftp-pv-storage" is invalid: spec: Requiredvalue: must specify a volume type.

In PV manifest you must provide type of volume. List of all supported types are described here. As you are using Ceph I assume you will use 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.

Example of CephFS you can find in Github.

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.

If you will check Official Kubernetes docs about 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 of your PV and PVC are different.

PV:

spec:
  storageClassName: rook-ceph-block

PVC:

spec:
  storageClassName: sftp-pv-storage

Hope it will help.

-- PjoterS
Source: StackOverflow