简体   繁体   English

如何将PV和PVC用于“可靠”持久卷?

[英]How do I use PV and PVC for *reliable* persistent volumes?

I followed the instructions in this post: how to bound a Persistent volume claim with a gcePersistentDisk? 我按照这篇文章中的说明进行操作: 如何使用gcePersistentDisk绑定持久卷声明?

And when I applied that, my PVC did not bind to the PV, instead I got this error in the event list: 当我应用它时,我的PVC没有绑定到PV,而是在事件列表中得到了此错误:

14s         17s          2         test-pvc.155b8df6bac15b5b   PersistentVolumeClaim               Warning   ProvisioningFailed   persistentvolume-controller   Failed to provision volume with StorageClass "standard": claim.Spec.Selector is not supported for dynamic provisioning on GCE

I found a github posting that suggested something that would fix this: 我发现一个github帖子提出了一些可以解决此问题的建议:

https://github.com/coreos/prometheus-operator/issues/323#issuecomment-299016953 https://github.com/coreos/prometheus-operator/issues/323#issuecomment-299016953

But unfortunately that made no difference. 但是不幸的是,这没有什么区别。

Is there a soup-to-nuts doc somewhere telling us exactly how to use PV and PVC to create truly persistent volumes? 是否在某处提供了从汤到汤的文档,确切地告诉我们如何使用PV和PVC来创建真正的持久卷? Specifically where you can shut down the pv and pvc and restore them later, and get all your content back? 具体来说,您可以在哪里关闭pv和pvc并在以后还原它们,并取回所有内容? Because as it seems right now, if you lose your PVC for whatever reason, you lose connection to your volume and there is no way to get it back again. 因为现在看来,如果由于任何原因丢失了PVC,则会失去与卷的连接,并且无法重新将其恢复。

The default StorageClass is not compatible with a gcePesistentDisk . 默认的StorageClassgcePesistentDisk不兼容。 Something like this would work: 这样的事情会起作用:

$ cat <<EOF | kubectl create -f -
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: slow
provisioner: kubernetes.io/gce-pd
parameters:
  type: pd-standard
  replication-type: none
EOF

then on your PVC: 然后在您的PVC上:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nfs-pvc
  labels:
    app: test
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: "slow" <== specify the storageClass
  resources:
    requests:
      storage: 2Gi
  selector:
    matchLabels:
      app: test

You can also set "slow" as the default storageClass in which case you wouldn't have to specify it on your PVC: 您还可以将“ slow”设置为默认的 storageClass在这种情况下,您不必在PVC上指定它:

$ kubectl patch storageclass slow -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM