unknown field "storage" in io.k8s.api.core.v1.PersistentVolumeClaim

9/7/2018

my pvc.yaml

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: database-disk
  labels:
    stage: production
    name: database
    app: mysql
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi

running kubectl apply -f pvc.yaml in microk8s got following error:

error validating data:ValidationData(PersistentVolumeClaim): unknown field "storage" in io.k8s.api.core.v1.PersistenVolumeClaim if choose to ignore these errors turn validation off with --validate=false

Edit: storage indentation wrong when I copied text on my VM :( ,its working fine now

-- invariant
kubernetes

2 Answers

9/7/2018

You forgot to specify the volumeMode. Add the volumeMode option and it should work.

Like this:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: database-disk
  labels:
    stage: production
    name: database
    app: mysql
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 20Gi
-- bn4t
Source: StackOverflow

9/7/2018

If you're using a storageClass, define one as default to be used or specify in the claim the storageClassName.

I have defined this in GCloud:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  annotations:
    storageclass.beta.kubernetes.io/is-default-class: "true"
  name: slow 
parameters:
  type: pd-standard
provisioner: kubernetes.io/gce-pd
reclaimPolicy: Delete
volumeBindingMode: Immediate
-- Nicola Ben
Source: StackOverflow