我的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上复制文本时存储缩进错误:(,它现在工作正常
你忘了指定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
如果您正在使用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