简体   繁体   English

kubernetes pv / pvc容量

[英]kubernetes pv / pvc capacity

I have a 3 node coros kubernetes cluster up and running. 我有一个3节点coros kubernetes群集启动并运行。

I want to use persitentvolumes(pv) from a standalone NFS Server. 我想从独立的NFS服务器使用persitentvolumes(pv)。

nfs.yaml nfs.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: kube1
spec:
  capacity:
    storage: 9.5G
  accessModes:
    - ReadWriteMany
  nfs:
    path: /mnt/nfs/kube1
    server: 10.3.0.3

claim.yaml claim.yaml

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: pvc2-1
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 1G

kubecfg get pv

kube1 <none> 9500M RWX Released default/pvc2-1

kubecfg get pvc

pvc2-1 <none> Bound kube1 9500M RWX

So why is the pvc created with the full capacity of pv? 那么为什么pvc是用pv的全部容量创建的呢? As I assumed that pvc is just a part of pv, otherwise it's pretty useless. 因为我认为pvc只是pv的一部分,否则它就没用了。

Regards 问候

cdpb cdpb

As far as I've seen, that's the way it should work. 据我所知,这就是应该运作的方式。 The claim is for the entire volume. 索赔是针对整个卷。 The part that confused me at first as well, was the resources.requests.storage value is only a minimum value that claim requires. 最初让我困惑的部分是resources.requests.storage值,它只是声明所需的最小值。 I use this with Ceph, and when Pods bind to the block device, they take the whole volume. 我在Ceph中使用它,当Pods绑定到块设备时,它们占用整个卷。

So why is the pvc created with the full capacity of pv? 那么为什么pvc是用pv的全部容量创建的呢? As I assumed that pvc is just a part of pv, otherwise it's pretty useless. 因为我认为pvc只是pv的一部分,否则它就没用了。

It's not useless, it's designed to claim the persistent volume. 它并非无用,它旨在声称持久音量。 requests says 'I need at least this much storage', just like it does for compute for pods. requests说'我至少需要这么多存储',就像它对pod的计算一样。

If you had multiple persistent volumes, this is clearer: the pvc won't get a pv of <1G, but would get this 9.5G pv (or another of sufficient size). 如果你有多个持久性卷,那就更清楚了:pvc不会得到<1G的pv,但会获得9.5G pv(或另一个足够大的pv)。

If you want to dynamically provision a specific storage size, you should create a Storage Class, backed by a volume that supports it . 如果要动态设置特定的存储大小,则应创建一个由支持它的卷支持的存储类。 If you want to use NFS, the in-tree plugin doesn't, but there is one in kubernetes-incubator that does. 如果你想使用NFS,那么in-tree插件没有,但kubernetes-incubator中有一个

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

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