Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Required value: must specify a volume type when statically provisioning PV

Trying to statically provision a PV with GCP SSD storage. Errors out with the following message:

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

Steps to reproduce:

$ cat storage.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: ssd
provisioner: kubernetes.io/gce-pd
parameters:
  type: pd-ssd
reclaimPolicy: Retain


$ kubectl apply -f storage.yaml
storageclass.storage.k8s.io/ssd created


$ cat pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
  name: monitoring
spec:
  storageClassName: ssd
  capacity:
    storage: 50Gi
  persistentVolumeReclaimPolicy: Retain
  accessModes:
    - ReadWriteOnce


$ kubectl apply -f pv.yaml
The PersistentVolume "monitoring" is invalid: spec: Required value: must specify a volume type

Kubernetes version:

Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.1", GitCommit:"b7394102d6ef778017f2ca4046abbaa23b88c290", GitTreeState:"clean", BuildDate:"2019-04-08T17:11:31Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"12+", GitVersion:"v1.12.6-gke.10", GitCommit:"aaf0906400b5fc1d858ce0566a571e4f3ed06b9f", GitTreeState:"clean", BuildDate:"2019-03-30T19:30:48Z", GoVersion:"go1.10.8b4", Compiler:"gc", Platform:"linux/amd64"}
like image 453
Jaipradeesh Avatar asked May 02 '19 15:05

Jaipradeesh


1 Answers

If using a provisioner, you usually don't create the PV on your own. Just create a PVC requiring that created storage class and GKE will provide the PV with the requested storage size and kind for you:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: my-retain-ssd-storage
  namespace: default
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 50Gi
  storageClassName: ssd
like image 120
jbndlr Avatar answered Sep 18 '22 11:09

jbndlr