hostPath PersistentVolume和spec.capacity.storage属性 [英] hostPath PersistentVolume and spec.capacity.storage attribute
问题描述
我正在使用hostPath
作为已部署的Postgres数据库的持久卷,在虚拟机中运行单个主/节点Kubernetes.
I'm running a single master/node Kubernetes in a Virtual Machine, using hostPath
as a persistent volume for a deployed Postgres database.
我的PersistentVolume
具有以下配置:
apiVersion: v1
kind: PersistentVolume
metadata:
annotations:
volume.beta.kubernetes.io/storage-class: postgres
labels:
type: local
name: postgres-storage
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 1Gi
hostPath:
path: /data/postgres
此外,我目前有一个PersistentVolumeClaim
绑定到该卷,要求所有容量(spec.resources.requests.storage: 1Gi
).
Also, I have a PersistentVolumeClaim
currently bounded to that volume, requesting all the capacity (spec.resources.requests.storage: 1Gi
).
最近,Postgres数据库的大小超过了spec.capacity.storage
,但是没有引起任何问题:
Recently, the Postgres database exceeded the spec.capacity.storage
in size, however, without causing any problems:
$ du -hs /data/postgres # Powers of 1024
1.2G /data/postgres
$ du -hs /data/postgres --si # Powers of 1000
1.3G /data/postgres
我的问题是:
-
spec.capacity.storage
在使用hostPath
卷,或者该卷实际上受基础分区的限制 大小? - 当卷使用量超过其
capacity
时会发生什么? (即Kubernetes将如何处理此问题)
- The
spec.capacity.storage
really matters when using ahostPath
volume, or the volume is in fact caped by the underlying partition size? - What should happen when the volume usage exceeds his
capacity
? (i.e., how Kubernetes will handle this)
推荐答案
根据Kubernetes GitHub页面上的@ wongma7:
According to @wongma7 on the Kubernetes GitHub page:
这按预期工作,kube无法/不会强制执行 PV,PV上的容量字段只是一个标签.取决于 管理员",即PV的创建者,以便对其进行准确标记 当用户创建需要> = X Gi的PVC时,他们得到的是 想要.
this is working as intended, kube can't/won't enforce the capacity of PVs, the capacity field on PVs is just a label. It's up to the "administrator" i.e. the creator of the PV to label it accurately so that when users create PVCs that needs >= X Gi, they get what they want.
您可以在此处找到原始讨论.
You can find the original discussion here.
此外,它也在官方卷/资源中进行了介绍文档:
Also, it's covered in the official Volume/Resources documentation:
emptyDir
或hostPath
卷可以容纳多少空间没有限制 ,并且容器之间或容器之间没有隔离.
There is no limit on how much space an
emptyDir
orhostPath
volume can consume, and no isolation between Containers or between Pods.
将来,我们预计emptyDir和hostPath卷将是 能够使用资源请求一定数量的空间 规范,以及选择要用于集群的媒体类型 有几种媒体类型.
In the future, we expect that emptyDir and hostPath volumes will be able to request a certain amount of space using a resource specification, and to select the type of media to use, for clusters that have several media types.
这篇关于hostPath PersistentVolume和spec.capacity.storage属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!