io.k8s.api.core.v1.PersistenVolumeClaim

时间:2018-09-07 08:00:41

标签: kubernetes

我的pvc.yaml

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

microk8s中运行kubectl apply -f pvc.yaml时出现以下错误:

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上复制文本时,存储缩进错误:(,现在可以正常工作

2 个答案:

答案 0 :(得分: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 :(得分: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