io.k8s.api.core.v1.PersistenVolumeClaim中的未知字段“storage”

问题描述 投票:0回答:2

我的pvc.yaml

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

kubectl apply -f pvc.yaml中运行microk8s得到以下错误:

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

编辑:当我在我的VM上复制文本时存储缩进错误:(,它现在工作正常

kubernetes
2个回答
4
投票

你忘了指定volumeMode。添加volumeMode选项,它应该工作。

像这样:

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

1
投票

如果您正在使用storageClass,请将其中一个定义为默认使用,或在声明中指定storageClassName

我在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
© www.soinside.com 2019 - 2024. All rights reserved.